ggershinsky commented on a change in pull request #8023: URL: https://github.com/apache/arrow/pull/8023#discussion_r497994184
########## File path: cpp/src/parquet/encryption/key_toolkit_internal.h ########## @@ -0,0 +1,52 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include <chrono> +#include <string> + +namespace parquet { +namespace encryption { +namespace internal { + +// "data encryption key" and "master key identifier" are paired together as output when +// parsing from "key material" +class KeyWithMasterId { + public: + KeyWithMasterId(const std::string& key_bytes, const std::string& master_id) + : key_bytes_(key_bytes), master_id_(master_id) {} + + const std::string& data_key() const { return key_bytes_; } + const std::string& master_id() const { return master_id_; } + + private: + const std::string key_bytes_; + const std::string master_id_; +}; + +/// Encrypts "key" with "master_key", using AES-GCM and the "aad" Review comment: We're using two ciphers in Parquet encryption spec - AES-GCM and AES-CTR. Out of these two, GCM is more secure, because it prevents tampering with the cipher text (encrypted key in this case). The "key" size is configurable. The "master_key" is fetched from KMS, so beyond our control. But it would be good indeed to make sure it has an allowed length. @thamht4190 , could you add a check of the master keys, right after they are returned from GetMasterKeyFromServer, to verify their length is either 16, 24 or 32 bytes? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org