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

Method initKey

flow/BlobCipher.cpp:67–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67void BlobCipherKey::initKey(const EncryptCipherDomainId& domainId,
68 const uint8_t* baseCiph,
69 int baseCiphLen,
70 const EncryptCipherBaseKeyId& baseCiphId,
71 const EncryptCipherRandomSalt& salt) {
72 // Set the base encryption key properties
73 baseCipher = std::make_unique<uint8_t[]>(AES_256_KEY_LENGTH);
74 memset(baseCipher.get(), 0, AES_256_KEY_LENGTH);
75 memcpy(baseCipher.get(), baseCiph, std::min<int>(baseCiphLen, AES_256_KEY_LENGTH));
76 baseCipherLen = baseCiphLen;
77 baseCipherId = baseCiphId;
78 // Set the encryption domain for the base encryption key
79 encryptDomainId = domainId;
80 randomSalt = salt;
81 // derive the encryption key
82 cipher = std::make_unique<uint8_t[]>(AES_256_KEY_LENGTH);
83 memset(cipher.get(), 0, AES_256_KEY_LENGTH);
84 applyHmacSha256Derivation();
85 // update the key creation time
86 creationTime = now();
87
88 TraceEvent("BlobCipherKey")
89 .detail("DomainId", domainId)
90 .detail("BaseCipherId", baseCipherId)
91 .detail("BaseCipherLen", baseCipherLen)
92 .detail("RandomSalt", randomSalt)
93 .detail("CreationTime", creationTime);
94}
95
96void BlobCipherKey::applyHmacSha256Derivation() {
97 Arena arena;

Callers

nothing calls this directly

Calls 5

memcpyFunction · 0.85
nowFunction · 0.85
TraceEventClass · 0.85
detailMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected