From 436cdff91213fe21422858f33e69577b76bcfdd0 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Tue, 20 Sep 2022 21:07:18 -0700 Subject: [PATCH] Remove dead code for applyHmacKeyDerivationFunc --- flow/StreamCipher.cpp | 19 ------------------- flow/include/flow/StreamCipher.h | 3 --- 2 files changed, 22 deletions(-) diff --git a/flow/StreamCipher.cpp b/flow/StreamCipher.cpp index 7b2840c616..8cd4f95c55 100644 --- a/flow/StreamCipher.cpp +++ b/flow/StreamCipher.cpp @@ -113,16 +113,6 @@ void StreamCipher::cleanup() noexcept { } } -void applyHmacKeyDerivationFunc(StreamCipherKey* cipherKey, HmacSha256StreamCipher* hmacGenerator, Arena& arena) { - uint8_t buf[cipherKey->size() + sizeof(uint64_t)]; - memcpy(&buf[0], cipherKey->data(), cipherKey->size()); - uint64_t seed = deterministicRandom()->randomUInt64(); - memcpy(&buf[0] + cipherKey->size(), &seed, sizeof(uint64_t)); - StringRef digest = hmacGenerator->digest(&buf[0], cipherKey->size() + sizeof(uint64_t), arena); - std::copy(digest.begin(), digest.end(), &buf[0]); - cipherKey->initializeKey(&buf[0], cipherKey->size()); -} - EncryptionStreamCipher::EncryptionStreamCipher(const StreamCipherKey* key, const StreamCipher::IV& iv) : cipher(StreamCipher(key->size())) { EVP_EncryptInit_ex(cipher.getCtx(), EVP_aes_256_gcm(), nullptr, nullptr, nullptr); @@ -173,15 +163,6 @@ HmacSha256StreamCipher::HmacSha256StreamCipher() : cipher(EVP_MAX_KEY_LENGTH) { HMAC_Init_ex(cipher.getHmacCtx(), NULL, 0, EVP_sha256(), nullptr); } -StringRef HmacSha256StreamCipher::digest(unsigned char const* data, int len, Arena& arena) { - CODE_PROBE(true, "Digest using StreamCipher"); - unsigned int digestLen = HMAC_size(cipher.getHmacCtx()); - auto digest = new (arena) unsigned char[digestLen]; - HMAC_Update(cipher.getHmacCtx(), data, len); - HMAC_Final(cipher.getHmacCtx(), digest, &digestLen); - return StringRef(digest, digestLen); -} - StringRef HmacSha256StreamCipher::finish(Arena& arena) { unsigned int digestLen = HMAC_size(cipher.getHmacCtx()); auto digest = new (arena) unsigned char[digestLen]; diff --git a/flow/include/flow/StreamCipher.h b/flow/include/flow/StreamCipher.h index 787c31c4c0..6a64593fb6 100644 --- a/flow/include/flow/StreamCipher.h +++ b/flow/include/flow/StreamCipher.h @@ -104,8 +104,5 @@ class HmacSha256StreamCipher final : NonCopyable, public ReferenceCounted