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

Method Encrypt

cpp/src/parquet/encryption/encryption_internal.cc:201–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199}
200
201int32_t AesEncryptor::AesEncryptorImpl::Encrypt(std::span<const uint8_t> plaintext,
202 std::span<const uint8_t> key,
203 std::span<const uint8_t> aad,
204 std::span<uint8_t> ciphertext) {
205 if (static_cast<size_t>(key_length_) != key.size()) {
206 std::stringstream ss;
207 ss << "Wrong key length " << key.size() << ". Should be " << key_length_;
208 throw ParquetException(ss.str());
209 }
210
211 if (ciphertext.size() != plaintext.size() + ciphertext_size_delta_) {
212 std::stringstream ss;
213 ss << "Ciphertext buffer length " << ciphertext.size()
214 << " does not match expected length "
215 << (plaintext.size() + ciphertext_size_delta_);
216 throw ParquetException(ss.str());
217 }
218
219 std::array<uint8_t, kNonceLength> nonce{};
220 // Random nonce
221 RAND_bytes(nonce.data(), kNonceLength);
222
223 if (kGcmMode == aes_mode_) {
224 return GcmEncrypt(plaintext, key, nonce, aad, ciphertext);
225 }
226
227 return CtrEncrypt(plaintext, key, nonce, ciphertext);
228}
229
230int32_t AesEncryptor::AesEncryptorImpl::GcmEncrypt(std::span<const uint8_t> plaintext,
231 std::span<const uint8_t> key,

Callers 8

WriteToMethod · 0.45
FinishMethod · 0.45
SerializeEncryptedObjMethod · 0.45
WriteDictionaryPageMethod · 0.45
WriteDataPageMethod · 0.45
EncryptKeyLocallyFunction · 0.45
EncryptionRoundTripMethod · 0.45

Calls 4

ParquetExceptionFunction · 0.85
strMethod · 0.80
sizeMethod · 0.45
dataMethod · 0.45

Tested by 2

EncryptionRoundTripMethod · 0.36