MCPcopy Create free account
hub / github.com/apple/foundationdb / verifyHeaderAuthToken

Method verifyHeaderAuthToken

flow/BlobCipher.cpp:556–586  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

554}
555
556void DecryptBlobCipherAes256Ctr::verifyHeaderAuthToken(const BlobCipherEncryptHeader& header, Arena& arena) {
557 if (header.flags.authTokenMode != ENCRYPT_HEADER_AUTH_TOKEN_MODE_MULTI) {
558 // NoneAuthToken mode; no authToken is generated; nothing to do
559 // SingleAuthToken mode; verification will happen as part of decryption.
560 return;
561 }
562
563 ASSERT_EQ(header.flags.authTokenMode, ENCRYPT_HEADER_AUTH_TOKEN_MODE_MULTI);
564
565 BlobCipherEncryptHeader headerCopy;
566 memcpy(reinterpret_cast<uint8_t*>(&headerCopy),
567 reinterpret_cast<const uint8_t*>(&header),
568 sizeof(BlobCipherEncryptHeader));
569 memset(reinterpret_cast<uint8_t*>(&headerCopy.multiAuthTokens.headerAuthToken), 0, AUTH_TOKEN_SIZE);
570 StringRef computedHeaderAuthToken = computeAuthToken(reinterpret_cast<const uint8_t*>(&headerCopy),
571 sizeof(BlobCipherEncryptHeader),
572 headerCipherKey->rawCipher(),
573 AES_256_KEY_LENGTH,
574 arena);
575 if (memcmp(&header.multiAuthTokens.headerAuthToken[0], computedHeaderAuthToken.begin(), AUTH_TOKEN_SIZE) != 0) {
576 TraceEvent("VerifyEncryptBlobHeader_AuthTokenMismatch")
577 .detail("HeaderVersion", header.flags.headerVersion)
578 .detail("HeaderMode", header.flags.encryptMode)
579 .detail("MultiAuthHeaderAuthToken",
580 StringRef(arena, &header.multiAuthTokens.headerAuthToken[0], AUTH_TOKEN_SIZE).toString())
581 .detail("ComputedHeaderAuthToken", computedHeaderAuthToken.toString());
582 throw encrypt_header_authtoken_mismatch();
583 }
584
585 headerAuthTokenValidationDone = true;
586}
587
588void DecryptBlobCipherAes256Ctr::verifyHeaderSingleAuthToken(const uint8_t* ciphertext,
589 const int ciphertextLen,

Callers 1

doDecryptionMethod · 0.80

Calls 8

memcpyFunction · 0.85
computeAuthTokenFunction · 0.85
TraceEventClass · 0.85
rawCipherMethod · 0.80
detailMethod · 0.80
StringRefClass · 0.50
beginMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected