| 805 | } |
| 806 | |
| 807 | bool VerifySignature(const void* signature) { |
| 808 | // verify decryption properties are set |
| 809 | if (file_decryptor_ == nullptr) { |
| 810 | throw ParquetException("Decryption not set properly. cannot verify signature"); |
| 811 | } |
| 812 | // serialize the footer |
| 813 | uint8_t* serialized_data; |
| 814 | uint32_t serialized_len = metadata_len_; |
| 815 | ThriftSerializer serializer; |
| 816 | serializer.SerializeToBuffer(metadata_.get(), &serialized_len, &serialized_data); |
| 817 | std::span<const uint8_t> serialized_data_span(serialized_data, serialized_len); |
| 818 | |
| 819 | // encrypt with nonce |
| 820 | std::span<const uint8_t> nonce(reinterpret_cast<const uint8_t*>(signature), |
| 821 | encryption::kNonceLength); |
| 822 | auto tag = reinterpret_cast<const uint8_t*>(signature) + encryption::kNonceLength; |
| 823 | |
| 824 | const SecureString& key = file_decryptor_->GetFooterKey(); |
| 825 | const std::string& aad = encryption::CreateFooterAad(file_decryptor_->file_aad()); |
| 826 | |
| 827 | auto aes_encryptor = encryption::AesEncryptor::Make(file_decryptor_->algorithm(), |
| 828 | static_cast<int>(key.size()), |
| 829 | true, false /*write_length*/); |
| 830 | |
| 831 | std::shared_ptr<Buffer> encrypted_buffer = AllocateBuffer( |
| 832 | file_decryptor_->pool(), aes_encryptor->CiphertextLength(serialized_len)); |
| 833 | int32_t encrypted_len = aes_encryptor->SignedFooterEncrypt( |
| 834 | serialized_data_span, key.as_span(), str2span(aad), nonce, |
| 835 | encrypted_buffer->mutable_span_as<uint8_t>()); |
| 836 | return 0 == |
| 837 | memcmp(encrypted_buffer->data() + encrypted_len - encryption::kGcmTagLength, |
| 838 | tag, encryption::kGcmTagLength); |
| 839 | } |
| 840 | |
| 841 | inline uint32_t size() const { return metadata_len_; } |
| 842 | inline int num_columns() const { return schema_.num_columns(); } |
nothing calls this directly
no test coverage detected