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

Method GetCiphertextLength

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

Source from the content-addressed store, hash-verified

506}
507
508int32_t AesDecryptor::AesDecryptorImpl::GetCiphertextLength(
509 std::span<const uint8_t> ciphertext) const {
510 if (length_buffer_length_ > 0) {
511 // Note: length_buffer_length_ must be either 0 or kBufferSizeLength
512 if (ciphertext.size() < static_cast<size_t>(kBufferSizeLength)) {
513 std::stringstream ss;
514 ss << "Ciphertext buffer length " << ciphertext.size()
515 << " is insufficient to read the ciphertext length."
516 << " At least " << kBufferSizeLength << " bytes are required.";
517 throw ParquetException(ss.str());
518 }
519
520 // Extract ciphertext length
521 uint32_t written_ciphertext_len = (static_cast<uint32_t>(ciphertext[3]) << 24) |
522 (static_cast<uint32_t>(ciphertext[2]) << 16) |
523 (static_cast<uint32_t>(ciphertext[1]) << 8) |
524 (static_cast<uint32_t>(ciphertext[0]));
525
526 if (written_ciphertext_len >
527 static_cast<uint32_t>(std::numeric_limits<int32_t>::max() -
528 length_buffer_length_)) {
529 std::stringstream ss;
530 ss << "Written ciphertext length " << written_ciphertext_len
531 << " plus length buffer length " << length_buffer_length_ << " overflows int32";
532 throw ParquetException(ss.str());
533 } else if (ciphertext.size() <
534 static_cast<size_t>(written_ciphertext_len) + length_buffer_length_) {
535 std::stringstream ss;
536 ss << "Serialized ciphertext length "
537 << (written_ciphertext_len + length_buffer_length_)
538 << " is greater than the provided ciphertext buffer length "
539 << ciphertext.size();
540 throw ParquetException(ss.str());
541 }
542
543 return static_cast<int32_t>(written_ciphertext_len) + length_buffer_length_;
544 } else {
545 if (ciphertext.size() > static_cast<size_t>(std::numeric_limits<int32_t>::max())) {
546 std::stringstream ss;
547 ss << "Ciphertext buffer length " << ciphertext.size() << " overflows int32";
548 throw ParquetException(ss.str());
549 }
550 return static_cast<int32_t>(ciphertext.size());
551 }
552}
553
554int32_t AesDecryptor::AesDecryptorImpl::GcmDecrypt(std::span<const uint8_t> ciphertext,
555 std::span<const uint8_t> key,

Callers

nothing calls this directly

Calls 3

ParquetExceptionFunction · 0.85
strMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected