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

Method HandleAadPrefix

cpp/src/parquet/file_reader.cc:717–758  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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