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

Method HandleAadPrefix

cpp/src/parquet/file_reader.cc:721–762  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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