EnricoMi commented on code in PR #44990:
URL: https://github.com/apache/arrow/pull/44990#discussion_r1880774857
##########
cpp/src/parquet/encryption/encryption_internal.cc:
##########
@@ -52,25 +52,85 @@ constexpr int32_t kBufferSizeLength = 4;
throw ParquetException("Couldn't init ALG decryption"); \
}
-class AesEncryptor::AesEncryptorImpl {
+class AesEncryptionContext {
+ public:
+ AesEncryptionContext(ParquetCipher::type alg_id, int32_t key_len, bool
metadata,
+ bool write_length) {
+ openssl::EnsureInitialized();
+
+ length_buffer_length_ = write_length ? kBufferSizeLength : 0;
+ ciphertext_size_delta_ = length_buffer_length_ + kNonceLength;
+ if (metadata || (ParquetCipher::AES_GCM_V1 == alg_id)) {
+ aes_mode_ = kGcmMode;
+ ciphertext_size_delta_ += kGcmTagLength;
+ } else {
+ aes_mode_ = kCtrMode;
+ }
+
+ if (16 != key_len && 24 != key_len && 32 != key_len) {
+ std::stringstream ss;
+ ss << "Wrong key length: " << key_len;
+ throw ParquetException(ss.str());
+ }
+
+ key_length_ = key_len;
+ };
+
+ virtual ~AesEncryptionContext() = default;
+
+ protected:
+ void InitCipherContext() {
Review Comment:
The constructor cannot call into a virtual method implemented by derived
classes. The constructor will call into the virtual method instead. Only after
the constructor the overloading is available.
Moving away from duplicating the initialized context makes this method
redundant any way.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]