| 586 | } |
| 587 | |
| 588 | void 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 | |
| 616 | void DecryptBlobCipherAes256Ctr::verifyHeaderMultiAuthToken(const uint8_t* ciphertext, |
| 617 | const int ciphertextLen, |
nothing calls this directly
no test coverage detected