public virtual async Task <Response <UnwrapResult> > UnwrapKeyAsync(KeyWrapAlgorithm algorithm, byte[] encryptedKey, CancellationToken cancellationToken = default) { var parameters = new KeyWrapParameters() { Algorithm = algorithm.ToString(), Key = encryptedKey }; using DiagnosticScope scope = Pipeline.CreateScope("Azure.Security.KeyVault.Keys.Cryptography.RemoteCryptographyClient.UnwrapKey"); scope.AddAttribute("key", _keyId); scope.Start(); try { return(await Pipeline.SendRequestAsync(RequestMethod.Post, parameters, () => new UnwrapResult { Algorithm = algorithm }, cancellationToken, "/unwrapKey").ConfigureAwait(false)); } catch (Exception e) { scope.Failed(e); throw; } }
public UnwrapResult UnwrapKey(KeyWrapAlgorithm algorithm, byte[] encryptedKey, CancellationToken cancellationToken) { Argument.AssertNotNull(encryptedKey, nameof(encryptedKey)); RSAEncryptionPadding padding = algorithm.GetRsaEncryptionPadding(); byte[] key = Decrypt(encryptedKey, padding); UnwrapResult result = null; if (key != null) { result = new UnwrapResult { Algorithm = algorithm, Key = key, KeyId = _jwk.Id, }; } return(result); }
public virtual Response <UnwrapResult> UnwrapKey(KeyWrapAlgorithm algorithm, byte[] encryptedKey, CancellationToken cancellationToken = default) { var parameters = new KeyWrapParameters() { Algorithm = algorithm.ToString(), Key = encryptedKey }; using DiagnosticScope scope = Pipeline.CreateScope($"{nameof(RemoteCryptographyClient)}.{nameof(UnwrapKey)}"); scope.AddAttribute("key", _keyId); scope.Start(); try { return(Pipeline.SendRequest(RequestMethod.Post, parameters, () => new UnwrapResult { Algorithm = algorithm }, cancellationToken, "/unwrapKey")); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual Response <WrapResult> WrapKey(KeyWrapAlgorithm algorithm, byte[] key, CancellationToken cancellationToken = default) { var parameters = new KeyWrapParameters() { Algorithm = algorithm.ToString(), Key = key }; using DiagnosticScope scope = Pipeline.CreateScope("Azure.Security.KeyVault.Keys.Cryptography.RemoteCryptographyClient.WrapKey"); scope.AddAttribute("key", _keyId); scope.Start(); try { return(Pipeline.SendRequest(RequestMethod.Post, parameters, () => new WrapResult { Algorithm = algorithm }, cancellationToken, "/wrapKey")); } catch (Exception e) { scope.Failed(e); throw; } }
public override WrapResult WrapKey(KeyWrapAlgorithm algorithm, byte[] key, CancellationToken cancellationToken) { Argument.AssertNotNull(key, nameof(key)); ThrowIfTimeInvalid(); RSAEncryptionPadding padding = algorithm.GetRsaEncryptionPadding(); byte[] encryptedKey = Encrypt(key, padding); WrapResult result = null; if (encryptedKey != null) { result = new WrapResult { Algorithm = algorithm, EncryptedKey = encryptedKey, KeyId = KeyMaterial.Id, }; } return(result); }
public virtual Task <WrapResult> WrapKeyAsync(KeyWrapAlgorithm algorithm, byte[] key, CancellationToken cancellationToken = default) { WrapResult result = WrapKey(algorithm, key, cancellationToken); return(Task.FromResult(result)); }
public virtual WrapResult WrapKey(KeyWrapAlgorithm algorithm, byte[] key, CancellationToken cancellationToken = default) { throw CreateOperationNotSupported(nameof(WrapKey)); }
public virtual Task <UnwrapResult> UnwrapKeyAsync(KeyWrapAlgorithm algorithm, byte[] encryptedKey, CancellationToken cancellationToken = default) { UnwrapResult result = UnwrapKey(algorithm, encryptedKey, cancellationToken); return(Task.FromResult(result)); }
public virtual WrapResult WrapKey(KeyWrapAlgorithm algorithm, byte[] key, CancellationToken cancellationToken = default) { throw new NotSupportedException(); }
UnwrapResult ICryptographyProvider.UnwrapKey(KeyWrapAlgorithm algorithm, byte[] encryptedKey, CancellationToken cancellationToken) { return(UnwrapKey(algorithm, encryptedKey, cancellationToken)); }
async Task <UnwrapResult> ICryptographyProvider.UnwrapKeyAsync(KeyWrapAlgorithm algorithm, byte[] encryptedKey, CancellationToken cancellationToken) { return(await UnwrapKeyAsync(algorithm, encryptedKey, cancellationToken).ConfigureAwait(false)); }
WrapResult ICryptographyProvider.WrapKey(KeyWrapAlgorithm algorithm, byte[] key, CancellationToken cancellationToken) { return(WrapKey(algorithm, key, cancellationToken)); }
WrapResult ICryptographyProvider.WrapKey(KeyWrapAlgorithm algorithm, byte[] key, CancellationToken cancellationToken) { return(((RemoteCryptographyClient)this).WrapKey(algorithm, key, cancellationToken)); }
async Task <WrapResult> ICryptographyProvider.WrapKeyAsync(KeyWrapAlgorithm algorithm, byte[] key, CancellationToken cancellationToken) { return(await((RemoteCryptographyClient)this).WrapKeyAsync(algorithm, key, cancellationToken).ConfigureAwait(false)); }
public WrapResult WrapKey(KeyWrapAlgorithm algorithm, byte[] key, CancellationToken cancellationToken) { // TODO throw new NotImplementedException(); }