Example #1
0
        public override byte[] UnwrapKey(string encryptionKeyId, KeyEncryptionKeyAlgorithm algorithm, byte[] encryptedKey)
        {
            // since we do not expose GetOrCreateDataEncryptionKey we first look up the cache.
            // Cache miss results in call to UnWrapCore which updates the cache after UnwrapKeyAsync is called.
            return(this.GetOrCreateDataEncryptionKey(encryptedKey.ToHexString(), UnWrapKeyCore));

            // delegate that is called by GetOrCreateDataEncryptionKey, which unwraps the key and updates the cache in case of cache miss.
            byte[] UnWrapKeyCore()
            {
                return(this.keyEncryptionKeyResolver
                       .Resolve(encryptionKeyId)
                       .UnwrapKey(EncryptionKeyStoreProviderImpl.GetNameForKeyEncryptionKeyAlgorithm(algorithm), encryptedKey));
            }
        }
Example #2
0
 public override byte[] WrapKey(string encryptionKeyId, KeyEncryptionKeyAlgorithm algorithm, byte[] key)
 {
     return(this.keyEncryptionKeyResolver
            .Resolve(encryptionKeyId)
            .WrapKey(EncryptionKeyStoreProviderImpl.GetNameForKeyEncryptionKeyAlgorithm(algorithm), key));
 }