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

Method HandleAadPrefix

cpp/src/parquet/file_reader.cc:718–759  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

716}
717
718std::string SerializedFile::HandleAadPrefix(
719 const std::shared_ptr<FileDecryptionProperties>& file_decryption_properties,
720 const EncryptionAlgorithm& algo) {
721 std::string aad_prefix_in_properties = file_decryption_properties->aad_prefix();
722 std::string aad_prefix = aad_prefix_in_properties;
723 bool file_has_aad_prefix = algo.aad.aad_prefix.empty() ? false : true;
724 std::string aad_prefix_in_file = algo.aad.aad_prefix;
725
726 if (algo.aad.supply_aad_prefix && aad_prefix_in_properties.empty()) {
727 throw ParquetException(
728 "AAD prefix used for file encryption, "
729 "but not stored in file and not supplied "
730 "in decryption properties");
731 }
732
733 if (file_has_aad_prefix) {
734 if (!aad_prefix_in_properties.empty()) {
735 if (aad_prefix_in_properties.compare(aad_prefix_in_file) != 0) {
736 throw ParquetException(
737 "AAD Prefix in file and in properties "
738 "is not the same");
739 }
740 }
741 aad_prefix = aad_prefix_in_file;
742 std::shared_ptr<AADPrefixVerifier> aad_prefix_verifier =
743 file_decryption_properties->aad_prefix_verifier();
744 if (aad_prefix_verifier != nullptr) aad_prefix_verifier->Verify(aad_prefix);
745 } else {
746 if (!algo.aad.supply_aad_prefix && !aad_prefix_in_properties.empty()) {
747 throw ParquetException(
748 "AAD Prefix set in decryption properties, but was not used "
749 "for file encryption");
750 }
751 std::shared_ptr<AADPrefixVerifier> aad_prefix_verifier =
752 file_decryption_properties->aad_prefix_verifier();
753 if (aad_prefix_verifier != nullptr) {
754 throw ParquetException(
755 "AAD Prefix Verifier is set, but AAD Prefix not found in file");
756 }
757 }
758 return aad_prefix + algo.aad.aad_file_unique;
759}
760
761// ----------------------------------------------------------------------
762// ParquetFileReader public API

Callers

nothing calls this directly

Calls 6

ParquetExceptionFunction · 0.85
aad_prefixMethod · 0.80
compareMethod · 0.80
aad_prefix_verifierMethod · 0.80
emptyMethod · 0.45
VerifyMethod · 0.45

Tested by

no test coverage detected