adamreeve commented on code in PR #43195:
URL: https://github.com/apache/arrow/pull/43195#discussion_r1671578299
##########
cpp/src/parquet/encryption/encryption_internal.cc:
##########
@@ -137,30 +156,45 @@
AesEncryptor::AesEncryptorImpl::AesEncryptorImpl(ParquetCipher::type alg_id, int
}
}
-int AesEncryptor::AesEncryptorImpl::SignedFooterEncrypt(
- const uint8_t* footer, int footer_len, const uint8_t* key, int key_len,
- const uint8_t* aad, int aad_len, const uint8_t* nonce, uint8_t*
encrypted_footer) {
- if (key_length_ != key_len) {
+int AesEncryptor::AesEncryptorImpl::SignedFooterEncrypt(span<const uint8_t>
footer,
+ span<const uint8_t>
key,
+ span<const uint8_t>
aad,
+ span<const uint8_t>
nonce,
+ span<uint8_t>
encrypted_footer) {
+ if (static_cast<size_t>(key_length_) != key.size()) {
+ std::stringstream ss;
+ ss << "Wrong key length " << key.size() << ". Should be " << key_length_;
+ throw ParquetException(ss.str());
+ }
+
+ if (encrypted_footer.size() < footer.size() + ciphertext_size_delta_) {
Review Comment:
I don't think there's any need to support larger than necessary buffer
sizes, it looks as if buffers are always allocated with the exact size required
or resized to the size needed, so it probably does make sense to use an
equality check for more robustness.
--
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]