ripplehang commented on code in PR #43601:
URL: https://github.com/apache/arrow/pull/43601#discussion_r1738411550
##########
cpp/src/arrow/filesystem/util_internal.cc:
##########
@@ -260,6 +263,44 @@ Result<FileInfoVector> GlobFiles(const
std::shared_ptr<FileSystem>& filesystem,
return out;
}
+bool CalculateSSECKeyMD5(const std::string& base64_encoded_key, std::string&
md5_result,
+ int expect_input_key_size) {
+ if (base64_encoded_key.size() < 2) {
+ return false;
+ }
+ // Check if the string contains only valid Base64 characters
+ for (char c : base64_encoded_key) {
+ if (!std::isalnum(c) && c != '+' && c != '/' && c != '=') {
+ return false;
+ }
+ }
+
+ // Decode the Base64-encoded key to get the raw binary key
+ Aws::Utils::ByteBuffer rawKey =
+ Aws::Utils::HashingUtils::Base64Decode(base64_encoded_key);
+
+ // the key needs to be // 256 bits(32 bytes)according to
+ //
https://docs.aws.amazon.com/AmazonS3/latest/userguide/ServerSideEncryptionCustomerKeys.html#specifying-s3-c-encryption
+ if (rawKey.GetLength() != expect_input_key_size) {
Review Comment:
the expect_input_key_size is exposed via S3Options, so it's possible for
this value to be set as any length.
--
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]