/// <summary> /// Wraps a symmetric key using the specified wrapping key and algorithm. /// </summary> /// <param name="wrappingKey">The wrapping key</param> /// <param name="key">The key to wrap</param> /// <param name="algorithm">The algorithm to use. For more information on possible algorithm types, see JsonWebKeyEncryptionAlgorithm.</param> /// <returns>The wrapped key</returns> public static async Task <KeyOperationResult> WrapKeyAsync(this KeyVaultClient client, KeyBundle wrappingKey, byte[] key, string algorithm) { if (wrappingKey == null) { throw new ArgumentNullException("keyBundle"); } return(await client.WrapKeyAsync(wrappingKey.Key, key, algorithm).ConfigureAwait(false)); }
/// <summary> /// Encrypts a single block of data. The amount of data that may be encrypted is determined /// by the target key type and the encryption algorithm. /// </summary> /// <param name="keyBundle">The key bundle to use for encryption</param> /// <param name="algorithm">The encryption algorithm. For more information on possible algorithm types, see JsonWebKeyEncryptionAlgorithm.</param> /// <param name="plaintext">The plain text to encrypt</param> /// <returns></returns> public static async Task <KeyOperationResult> EncryptDataAsync(this KeyVaultClient client, KeyBundle keyBundle, string algorithm, byte[] plaintext) { if (keyBundle == null) { throw new ArgumentNullException("keyBundle"); } return(await client.EncryptDataAsync(keyBundle.Key, algorithm, plaintext).ConfigureAwait(false)); }
/// <summary> /// Verifies a signature using the specified key. /// </summary> /// <param name="verifyKey">The verification key</param> /// <param name="algorithm">The signing algorithm. For more information on possible algorithm types, see JsonWebKeyEncryptionAlgorithm.</param> /// <param name="digest">The digest hash value</param> /// <param name="signature">The signature to verify</param> /// <returns>True if verification succeeds, false if verification fails</returns> public static async Task <bool> VerifyAsync(this KeyVaultClient client, KeyBundle verifyKey, string algorithm, byte[] digest, byte[] signature) { return(await client.VerifyAsync(verifyKey.Key, algorithm, digest, signature).ConfigureAwait(false)); }