| 235 | // BlobCipherKeyCache class methods |
| 236 | |
| 237 | Reference<BlobCipherKey> BlobCipherKeyCache::insertCipherKey(const EncryptCipherDomainId& domainId, |
| 238 | const EncryptCipherBaseKeyId& baseCipherId, |
| 239 | const uint8_t* baseCipher, |
| 240 | int baseCipherLen) { |
| 241 | if (domainId == ENCRYPT_INVALID_DOMAIN_ID || baseCipherId == ENCRYPT_INVALID_CIPHER_KEY_ID) { |
| 242 | throw encrypt_invalid_id(); |
| 243 | } |
| 244 | |
| 245 | try { |
| 246 | auto domainItr = domainCacheMap.find(domainId); |
| 247 | if (domainItr == domainCacheMap.end()) { |
| 248 | // Add mapping to track new encryption domain |
| 249 | Reference<BlobCipherKeyIdCache> keyIdCache = makeReference<BlobCipherKeyIdCache>(domainId); |
| 250 | Reference<BlobCipherKey> cipherKey = |
| 251 | keyIdCache->insertBaseCipherKey(baseCipherId, baseCipher, baseCipherLen); |
| 252 | domainCacheMap.emplace(domainId, keyIdCache); |
| 253 | return cipherKey; |
| 254 | } else { |
| 255 | // Track new baseCipher keys |
| 256 | Reference<BlobCipherKeyIdCache> keyIdCache = domainItr->second; |
| 257 | return keyIdCache->insertBaseCipherKey(baseCipherId, baseCipher, baseCipherLen); |
| 258 | } |
| 259 | |
| 260 | TraceEvent("InsertCipherKey").detail("DomainId", domainId).detail("BaseCipherKeyId", baseCipherId); |
| 261 | } catch (Error& e) { |
| 262 | TraceEvent("InsertCipherKey_Failed").detail("BaseCipherKeyId", baseCipherId).detail("DomainId", domainId); |
| 263 | throw; |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | Reference<BlobCipherKey> BlobCipherKeyCache::insertCipherKey(const EncryptCipherDomainId& domainId, |
| 268 | const EncryptCipherBaseKeyId& baseCipherId, |
no test coverage detected