MCPcopy Create free account
hub / github.com/apache/arrow / EncryptKeyLocally

Function EncryptKeyLocally

cpp/src/parquet/encryption/key_toolkit_internal.cc:34–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32static constexpr const int32_t kAcceptableDataKeyLengths[] = {128, 192, 256};
33
34std::string EncryptKeyLocally(const SecureString& key_bytes,
35 const SecureString& master_key, const std::string& aad) {
36 AesEncryptor key_encryptor(ParquetCipher::AES_GCM_V1,
37 static_cast<int>(master_key.size()), false,
38 false /*write_length*/);
39
40 int32_t encrypted_key_len =
41 key_encryptor.CiphertextLength(static_cast<int64_t>(key_bytes.size()));
42 std::string encrypted_key(encrypted_key_len, '\0');
43 std::span<uint8_t> encrypted_key_span(reinterpret_cast<uint8_t*>(&encrypted_key[0]),
44 encrypted_key_len);
45
46 encrypted_key_len = key_encryptor.Encrypt(key_bytes.as_span(), master_key.as_span(),
47 str2span(aad), encrypted_key_span);
48
49 return ::arrow::util::base64_encode(
50 ::std::string_view(encrypted_key.data(), encrypted_key_len));
51}
52
53SecureString DecryptKeyLocally(const std::string& encoded_encrypted_key,
54 const SecureString& master_key, const std::string& aad) {

Callers 3

WrapKeyMethod · 0.85
WrapKeyMethod · 0.85

Calls 6

str2spanFunction · 0.85
as_spanMethod · 0.80
sizeMethod · 0.45
CiphertextLengthMethod · 0.45
EncryptMethod · 0.45
dataMethod · 0.45

Tested by 1

WrapKeyMethod · 0.68