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

Function applyHmacKeyDerivationFunc

flow/StreamCipher.cpp:116–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114}
115
116void applyHmacKeyDerivationFunc(StreamCipherKey* cipherKey, HmacSha256StreamCipher* hmacGenerator, Arena& arena) {
117 uint8_t buf[cipherKey->size() + sizeof(uint64_t)];
118 memcpy(&buf[0], cipherKey->data(), cipherKey->size());
119 uint64_t seed = deterministicRandom()->randomUInt64();
120 memcpy(&buf[0] + cipherKey->size(), &seed, sizeof(uint64_t));
121 StringRef digest = hmacGenerator->digest(&buf[0], cipherKey->size() + sizeof(uint64_t), arena);
122 std::copy(digest.begin(), digest.end(), &buf[0]);
123 cipherKey->initializeKey(&buf[0], cipherKey->size());
124}
125
126EncryptionStreamCipher::EncryptionStreamCipher(const StreamCipherKey* key, const StreamCipher::IV& iv)
127 : cipher(StreamCipher(key->size())) {

Callers

nothing calls this directly

Calls 10

memcpyFunction · 0.85
deterministicRandomFunction · 0.85
copyFunction · 0.85
randomUInt64Method · 0.80
initializeKeyMethod · 0.80
sizeMethod · 0.45
dataMethod · 0.45
digestMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected