| 65 | } |
| 66 | |
| 67 | void 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 | |
| 96 | void BlobCipherKey::applyHmacSha256Derivation() { |
| 97 | Arena arena; |
nothing calls this directly
no test coverage detected