Vault | C# SDK | Keys Endpoints
Keys Endpoints
Symmetric generate
VaultClient.SymmetricGenerate(SymmetricGenerateRequest)Generate a symmetric key.
SymmetricGenerateRequest request = new SymmetricGenerateRequest
(
SymmetricAlgorithm.AES128_CFB,
KeyPurpose.Encryption,
"my-very-secret-secret")
;
var response = await client.SymmetricGenerate(request);
Asymmetric generate
VaultClient.AsymmetricGenerate(AsymmetricGenerateRequest)Generate an asymmetric key.
AsymmetricGenerateRequest request = new AsymmetricGenerateRequest
(
AsymmetricAlgorithm.ED25519,
KeyPurpose.Signing,
"my-very-secret-secret")
;
var response = await client.AsymmetricGenerate(request);
Asymmetric store
VaultClient.AsymmetricStore(AsymmetricStoreRequest)Import an asymmetric key.
AsymmetricStoreRequest request = new AsymmetricStoreRequest
(
"encoded private key",
"-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEA8s5JopbEPGBylPBcMK+L5PqHMqPJW/5KYPgBHzZGncc=\n-----END PUBLIC KEY-----",
AsymmetricAlgorithm.RSA4096_OAEP_SHA256,
KeyPurpose.Signing,
"my-very-secret-secret")
;
var response = await client.AsymmetricStore(request);
Symmetric store
VaultClient.SymmetricStore(SymmetricStoreRequest)Import a symmetric key.
SymmetricStoreRequest request = new SymmetricStoreRequest
(
"lJkk0gCLux+Q+rPNqLPEYw==",
SymmetricAlgorithm.AES128_CFB,
KeyPurpose.Encryption,
"my-very-secret-secret")
;
var response = await client.SymmetricStore(request);
Rotate
VaultClient.KeyRotate(KeyRotateRequest)Manually rotate a symmetric or asymmetric key.
KeyRotateRequest request = new KeyRotateRequest
(
"pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5",
ItemVersionState.Deactivated)
.WithEncodedSymmetricKey("lJkk0gCLux+Q+rPNqLPEYw==")
;
var response = await client.KeyRotate(request);
Encrypt
VaultClient.Encrypt(EncryptRequest)Encrypt a message using a key.
EncryptRequest request = new EncryptRequest
(
"pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5",
"lJkk0gCLux+Q+rPNqLPEYw==")
.WithVersion(2)
;
var response = await client.Encrypt(request);
Decrypt
VaultClient.Decrypt(DecryptRequest)Decrypt a message using a key.
DecryptRequest request = new DecryptRequest
(
"pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5",
"lJkk0gCLux+Q+rPNqLPEYw==")
.WithVersion(2)
;
var response = await client.Decrypt(request);
Sign
VaultClient.Sign(SignRequest)Sign a message using a key.
SignRequest request = new SignRequest
(
"pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5",
"lJkk0gCLux+Q+rPNqLPEYw==")
;
var response = await client.Sign(request);
Verify
VaultClient.Verify(VerifyRequest)Verify a signature using a key.
var request = new VerifyRequest
(
"pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5",
"data2verify",
"signature")
;
var response = await client.Verify(request);
Encrypt structured
VaultClient.EncryptStructured<T>(EncryptStructuredRequest<T>, CancellationToken)Encrypt parts of a JSON object.
var data = new SomeModel { Name = "...", Occupation = "..." };
var request = new EncryptStructuredRequest<SomeModel>(encryptionKeyId, data, "$.name");
var response = await client.EncryptStructured(request);
Decrypt structured
VaultClient.DecryptStructured<T>(EncryptStructuredRequest<T>, CancellationToken)Decrypt parts of a JSON object.
var data = new SomeModel { Name = "...", Occupation = "..." };
var request = new EncryptStructuredRequest<SomeModel>(encryptionKeyId, data, "$.name");
var response = await client.DecryptStructured(request);