/// <summary>
        /// Unwraps a symmetric key using the specified wrapping key and algorithm.
        /// </summary>
        /// <param name="wrappingKey">The wrapping key</param>
        /// <param name="wrappedKey">The symmetric key to unwrap</param>
        /// <param name="algorithm">The algorithm to use</param>
        /// <returns>The unwrapped key</returns>
        public static async Task <KeyOperationResult> UnwrapKeyAsync(this KeyVaultClient client, KeyBundle wrappingKey, byte[] wrappedKey, string algorithm)
        {
            if (wrappingKey == null)
            {
                throw new ArgumentNullException("wrappingKey");
            }

            return(await client.UnwrapKeyAsync(wrappingKey.Key, wrappedKey, algorithm).ConfigureAwait(false));
        }
Ejemplo n.º 2
0
        public Task <byte[]> UnwrapKeyAsync(byte[] ciphertext, string algorithm = null, CancellationToken token = default(CancellationToken))
        {
            if (_implementation == null)
            {
                throw new ObjectDisposedException("KeyVaultKey");
            }

            if (string.IsNullOrWhiteSpace(algorithm))
            {
                algorithm = DefaultKeyWrapAlgorithm;
            }

            // Never local
            return(_client.UnwrapKeyAsync(_implementation.Kid, algorithm, ciphertext, token)
                   .ContinueWith(result => result.Result.Result, token));
        }