public virtual async Task <Response <DecryptResult> > DecryptAsync(EncryptionAlgorithm algorithm, byte[] ciphertext, byte[] iv = default, byte[] authenticationData = default, byte[] authenticationTag = default, CancellationToken cancellationToken = default) { var parameters = new KeyEncryptParameters() { Algorithm = algorithm.ToString(), Value = ciphertext, Iv = iv, AuthenticationData = authenticationData, AuthenticationTag = authenticationTag }; using DiagnosticScope scope = Pipeline.CreateScope("Azure.Security.KeyVault.Keys.Cryptography.RemoteCryptographyClient.Decrypt"); scope.AddAttribute("key", _keyId); scope.Start(); try { return(await Pipeline.SendRequestAsync(RequestMethod.Post, parameters, () => new DecryptResult { Algorithm = algorithm }, cancellationToken, "/decrypt").ConfigureAwait(false)); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual Response <EncryptResult> Encrypt(EncryptionAlgorithm algorithm, byte[] plaintext, byte[] iv = default, byte[] authenticationData = default, CancellationToken cancellationToken = default) { var parameters = new KeyEncryptParameters() { Algorithm = algorithm.ToString(), Value = plaintext, Iv = iv, AuthenticationData = authenticationData }; using DiagnosticScope scope = Pipeline.CreateScope("Azure.Security.KeyVault.Keys.Cryptography.RemoteCryptographyClient.Encrypt"); scope.AddAttribute("key", _keyId); scope.Start(); try { return(Pipeline.SendRequest(RequestMethod.Post, parameters, () => new EncryptResult { Algorithm = algorithm }, cancellationToken, "/encrypt")); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> /// /// </summary> /// <param name="algorithm"></param> /// <param name="plaintext"></param> /// <param name="iv"></param> /// <param name="authenticationData"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public virtual async Task <Response <EncryptResult> > EncryptAsync(EncryptionAlgorithm algorithm, byte[] plaintext, byte[] iv = default, byte[] authenticationData = default, CancellationToken cancellationToken = default) { var parameters = new KeyEncryptParameters() { Algorithm = algorithm.GetName(), Value = plaintext, Iv = iv, AuthenticationData = authenticationData }; return(await SendRequestAsync(EncryptOperation, parameters, () => new EncryptResult() { Algorithm = algorithm }, cancellationToken).ConfigureAwait(false)); }
/// <summary> /// /// </summary> /// <param name="algorithm"></param> /// <param name="plaintext"></param> /// <param name="iv"></param> /// <param name="authenticationData"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public virtual Response <EncryptResult> Encrypt(EncryptionAlgorithm algorithm, byte[] plaintext, byte[] iv = default, byte[] authenticationData = default, CancellationToken cancellationToken = default) { var parameters = new KeyEncryptParameters() { Algorithm = algorithm.GetName(), Value = plaintext, Iv = iv, AuthenticationData = authenticationData }; return(SendRequest(EncryptOperation, parameters, () => new EncryptResult() { Algorithm = algorithm }, cancellationToken)); }
public virtual async Task <Response <EncryptResult> > EncryptAsync(EncryptionAlgorithm algorithm, byte[] plaintext, CancellationToken cancellationToken = default) { var parameters = new KeyEncryptParameters() { Algorithm = algorithm.ToString(), Value = plaintext, }; using DiagnosticScope scope = Pipeline.CreateScope($"{nameof(RemoteCryptographyClient)}.{nameof(Encrypt)}"); scope.AddAttribute("key", _keyId); scope.Start(); try { return(await Pipeline.SendRequestAsync(RequestMethod.Post, parameters, () => new EncryptResult { Algorithm = algorithm }, cancellationToken, "/encrypt").ConfigureAwait(false)); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual Response <DecryptResult> Decrypt(EncryptionAlgorithm algorithm, byte[] ciphertext, CancellationToken cancellationToken = default) { var parameters = new KeyEncryptParameters() { Algorithm = algorithm.ToString(), Value = ciphertext, }; using DiagnosticScope scope = Pipeline.CreateScope($"{nameof(RemoteCryptographyClient)}.{nameof(Decrypt)}"); scope.AddAttribute("key", _keyId); scope.Start(); try { return(Pipeline.SendRequest(RequestMethod.Post, parameters, () => new DecryptResult { Algorithm = algorithm }, cancellationToken, "/decrypt")); } catch (Exception e) { scope.Failed(e); throw; } }