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

Method verifyHeaderSingleAuthToken

flow/BlobCipher.cpp:588–614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

586}
587
588void DecryptBlobCipherAes256Ctr::verifyHeaderSingleAuthToken(const uint8_t* ciphertext,
589 const int ciphertextLen,
590 const BlobCipherEncryptHeader& header,
591 uint8_t* buff,
592 Arena& arena) {
593 // Header authToken not set for single auth-token mode.
594 ASSERT(!headerAuthTokenValidationDone);
595
596 // prepare the payload {cipherText + encryptionHeader}
597 memcpy(&buff[0], ciphertext, ciphertextLen);
598 memcpy(&buff[ciphertextLen], reinterpret_cast<const uint8_t*>(&header), sizeof(BlobCipherEncryptHeader));
599 // ensure the 'authToken' is reset before computing the 'authentication token'
600 BlobCipherEncryptHeader* eHeader = (BlobCipherEncryptHeader*)(&buff[ciphertextLen]);
601 memset(reinterpret_cast<uint8_t*>(&eHeader->singleAuthToken), 0, 2 * AUTH_TOKEN_SIZE);
602
603 StringRef computed = computeAuthToken(
604 buff, ciphertextLen + sizeof(BlobCipherEncryptHeader), headerCipherKey->rawCipher(), AES_256_KEY_LENGTH, arena);
605 if (memcmp(&header.singleAuthToken.authToken[0], computed.begin(), AUTH_TOKEN_SIZE) != 0) {
606 TraceEvent("VerifyEncryptBlobHeader_AuthTokenMismatch")
607 .detail("HeaderVersion", header.flags.headerVersion)
608 .detail("HeaderMode", header.flags.encryptMode)
609 .detail("SingleAuthToken",
610 StringRef(arena, &header.singleAuthToken.authToken[0], AUTH_TOKEN_SIZE).toString())
611 .detail("ComputedSingleAuthToken", computed.toString());
612 throw encrypt_header_authtoken_mismatch();
613 }
614}
615
616void DecryptBlobCipherAes256Ctr::verifyHeaderMultiAuthToken(const uint8_t* ciphertext,
617 const int ciphertextLen,

Callers

nothing calls this directly

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