diff --git a/src/VaultSharp/V1/SecretsEngines/Transit/CreateKeyRequestOptions.cs b/src/VaultSharp/V1/SecretsEngines/Transit/CreateKeyRequestOptions.cs index cfb0ef46..9d488883 100644 --- a/src/VaultSharp/V1/SecretsEngines/Transit/CreateKeyRequestOptions.cs +++ b/src/VaultSharp/V1/SecretsEngines/Transit/CreateKeyRequestOptions.cs @@ -12,33 +12,38 @@ public class CreateKeyRequestOptions /// ciphertext.This requires derived to be set to true. When enabled, each encryption(/decryption/rewrap/datakey) /// operation will derive a nonce value rather than randomly generate it. /// - [JsonProperty(PropertyName = "convergent_encryption", NullValueHandling = NullValueHandling.Ignore)] - public bool? ConvergentEncryption { get; set; } + [JsonProperty(PropertyName = "convergent_encryption")] + public bool ConvergentEncryption { get; set; } /// /// Specifies if key derivation is to be used.If enabled, all encrypt/decrypt requests to this named /// key must provide a context which is used for key derivation. /// - [JsonProperty(PropertyName = "derived", NullValueHandling = NullValueHandling.Ignore)] - public bool? Derived { get; set; } + [JsonProperty(PropertyName = "derived")] + public bool Derived { get; set; } /// /// Enables keys to be exportable. This allows for all the valid keys in the key ring to be /// exported. Once set, this cannot be disabled. /// - [JsonProperty(PropertyName = "exportable", NullValueHandling = NullValueHandling.Ignore)] - public bool? Exportable { get; set; } + [JsonProperty(PropertyName = "exportable")] + public bool Exportable { get; set; } /// /// If set, enables taking backup of named key in the plaintext format.Once set, this cannot be disabled. /// - [JsonProperty(PropertyName = "allow_plaintext_backup", NullValueHandling = NullValueHandling.Ignore)] - public bool? AllowPlaintextBackup { get; set; } + [JsonProperty(PropertyName = "allow_plaintext_backup")] + public bool AllowPlaintextBackup { get; set; } /// /// Specifies the type of key to create. /// [JsonProperty("type")] - public string Type { get; set; } = "aes256-gcm96"; + public TransitKeyType Type { get; set; } + + public CreateKeyRequestOptions() + { + this.Type = TransitKeyType.aes256_gcm96; + } } } \ No newline at end of file diff --git a/src/VaultSharp/V1/SecretsEngines/Transit/EncryptionKeyInfo.cs b/src/VaultSharp/V1/SecretsEngines/Transit/EncryptionKeyInfo.cs index f28fe9a0..143c7706 100644 --- a/src/VaultSharp/V1/SecretsEngines/Transit/EncryptionKeyInfo.cs +++ b/src/VaultSharp/V1/SecretsEngines/Transit/EncryptionKeyInfo.cs @@ -12,7 +12,7 @@ public class EncryptionKeyInfo /// The type of key (i.e. encryption algorithm) to generate. /// [JsonProperty("type")] - public string Type { get; set; } = "aes256-gcm96"; + public TransitKeyType Type { get; set; } /// /// Specifies if the key is allowed to be deleted. diff --git a/src/VaultSharp/V1/SecretsEngines/Transit/ITransitSecretsEngine.cs b/src/VaultSharp/V1/SecretsEngines/Transit/ITransitSecretsEngine.cs index 7fac7d89..5f3ce873 100644 --- a/src/VaultSharp/V1/SecretsEngines/Transit/ITransitSecretsEngine.cs +++ b/src/VaultSharp/V1/SecretsEngines/Transit/ITransitSecretsEngine.cs @@ -114,7 +114,7 @@ public interface ITransitSecretsEngine /// Provide a value only if you have customized the mount point. /// /// Nothing is returned. No error means the operation was successful. - Task CreateKeyAsync(string keyName, CreateKeyRequestOptions createKeyRequestOptions, string mountPoint = SecretsEngineDefaultPaths.Transit); + Task CreateEncryptionKeyAsync(string keyName, CreateKeyRequestOptions createKeyRequestOptions, string mountPoint = SecretsEngineDefaultPaths.Transit); /// /// This endpoint returns information about a named encryption key. @@ -143,7 +143,7 @@ public interface ITransitSecretsEngine /// Provide a value only if you have customized the mount point. /// /// Nothing is returned. No error means the operation was successful. - Task UpdateKeyAsync(string keyName, UpdateKeyRequestOptions updateKeyRequestOptions, string mountPoint = SecretsEngineDefaultPaths.Transit); + Task UpdateEncryptionKeyConfigAsync(string keyName, UpdateKeyRequestOptions updateKeyRequestOptions, string mountPoint = SecretsEngineDefaultPaths.Transit); /// /// This endpoint deletes a named encryption key. It will no longer be possible to decrypt any data encrypted with the named key. @@ -156,7 +156,7 @@ public interface ITransitSecretsEngine /// Provide a value only if you have customized the mount point. /// /// Nothing is returned. No error means the operation was successful. - Task DeleteKeyAsync(string keyName, string mountPoint = SecretsEngineDefaultPaths.Transit); + Task DeleteEncryptionKeyAsync(string keyName, string mountPoint = SecretsEngineDefaultPaths.Transit); /// /// This endpoint rotates the version of the named key. After rotation, new plaintext requests will be encrypted with the new version of the key. @@ -169,7 +169,7 @@ public interface ITransitSecretsEngine /// Provide a value only if you have customized the mount point. /// /// Nothing is returned. No error means the operation was successful. - Task RotateKeyAsync(string keyName, string mountPoint = SecretsEngineDefaultPaths.Transit); + Task RotateEncryptionKeyAsync(string keyName, string mountPoint = SecretsEngineDefaultPaths.Transit); /// /// This endpoint rewraps the provided ciphertext using the latest version of the named key. diff --git a/src/VaultSharp/V1/SecretsEngines/Transit/RewrapRequestOptions.cs b/src/VaultSharp/V1/SecretsEngines/Transit/RewrapRequestOptions.cs index aab12ed3..ab100aa9 100644 --- a/src/VaultSharp/V1/SecretsEngines/Transit/RewrapRequestOptions.cs +++ b/src/VaultSharp/V1/SecretsEngines/Transit/RewrapRequestOptions.cs @@ -11,13 +11,13 @@ public class RewrapRequestOptions : RewrapItem /// /// Specifies the version of the key to use for the operation. If not set, uses the latest version. /// - [JsonProperty(PropertyName = "key_version", NullValueHandling = NullValueHandling.Ignore)] - public int? KeyVersion { get; set; } + [JsonProperty(PropertyName = "key_version")] + public int KeyVersion { get; set; } /// /// Specifies a list of items to be decrypted in a single batch. /// - [JsonProperty(PropertyName = "batch_input", NullValueHandling = NullValueHandling.Ignore)] + [JsonProperty(PropertyName = "batch_input")] public List BatchedRewrapItems { get; set; } } } \ No newline at end of file diff --git a/src/VaultSharp/V1/SecretsEngines/Transit/TransitSecretsEngineProvider.cs b/src/VaultSharp/V1/SecretsEngines/Transit/TransitSecretsEngineProvider.cs index cc330290..04388c4c 100644 --- a/src/VaultSharp/V1/SecretsEngines/Transit/TransitSecretsEngineProvider.cs +++ b/src/VaultSharp/V1/SecretsEngines/Transit/TransitSecretsEngineProvider.cs @@ -42,7 +42,7 @@ public async Task> GenerateDataKeyAsync(string keyType, "v1/" + mountPoint.Trim('/') + "/datakey/" + keyType.Trim('/')+ "/" + keyName.Trim('/'), HttpMethod.Post, dataKeyRequestOptions, wrapTimeToLive: wrapTimeToLive).ConfigureAwait(_polymath.VaultClientSettings.ContinueAsyncTasksOnCapturedContext); } - public async Task CreateKeyAsync(string keyName, CreateKeyRequestOptions createKeyRequestOptions, string mountPoint = SecretsEngineDefaultPaths.Transit) + public async Task CreateEncryptionKeyAsync(string keyName, CreateKeyRequestOptions createKeyRequestOptions, string mountPoint = SecretsEngineDefaultPaths.Transit) { Checker.NotNull(keyName, "keyName"); Checker.NotNull(createKeyRequestOptions, "createKeyRequestOptions"); @@ -51,25 +51,22 @@ public async Task CreateKeyAsync(string keyName, CreateKeyRequestOptions createK await _polymath.MakeVaultApiRequest( "v1/" + mountPoint.Trim('/') + "/keys/" + keyName.Trim('/'), HttpMethod.Post, - createKeyRequestOptions, - wrapTimeToLive: null) + createKeyRequestOptions) .ConfigureAwait(_polymath.VaultClientSettings.ContinueAsyncTasksOnCapturedContext); } - public async Task> ReadEncryptionKeyAsync(string keyName, string mountPoint = "transit") + public async Task> ReadEncryptionKeyAsync(string keyName, string mountPoint = SecretsEngineDefaultPaths.Transit) { Checker.NotNull(keyName, "keyName"); Checker.NotNull(mountPoint, "mountPoint"); return await _polymath.MakeVaultApiRequest>( "v1/" + mountPoint.Trim('/') + "/keys/" + keyName.Trim('/'), - HttpMethod.Get, - requestData: null, - wrapTimeToLive: null) + HttpMethod.Get) .ConfigureAwait(_polymath.VaultClientSettings.ContinueAsyncTasksOnCapturedContext); } - public async Task UpdateKeyAsync(string keyName, UpdateKeyRequestOptions updateKeyRequestOptions, string mountPoint = "transit") + public async Task UpdateEncryptionKeyConfigAsync(string keyName, UpdateKeyRequestOptions updateKeyRequestOptions, string mountPoint = SecretsEngineDefaultPaths.Transit) { Checker.NotNull(keyName, "keyName"); Checker.NotNull(updateKeyRequestOptions, "updateKeyRequestOptions"); @@ -78,34 +75,29 @@ public async Task UpdateKeyAsync(string keyName, UpdateKeyRequestOptions updateK await _polymath.MakeVaultApiRequest( "v1/" + mountPoint.Trim('/') + "/keys/" + keyName.Trim('/') + "/config", HttpMethod.Post, - updateKeyRequestOptions, - wrapTimeToLive: null) + updateKeyRequestOptions) .ConfigureAwait(_polymath.VaultClientSettings.ContinueAsyncTasksOnCapturedContext); } - public async Task DeleteKeyAsync(string keyName, string mountPoint = SecretsEngineDefaultPaths.Transit) + public async Task DeleteEncryptionKeyAsync(string keyName, string mountPoint = SecretsEngineDefaultPaths.Transit) { Checker.NotNull(keyName, "keyName"); Checker.NotNull(mountPoint, "mountPoint"); await _polymath.MakeVaultApiRequest( "v1/" + mountPoint.Trim('/') + "/keys/" + keyName.Trim('/'), - HttpMethod.Delete, - requestData: null, - wrapTimeToLive: null) + HttpMethod.Delete) .ConfigureAwait(_polymath.VaultClientSettings.ContinueAsyncTasksOnCapturedContext); } - public async Task RotateKeyAsync(string keyName, string mountPoint = SecretsEngineDefaultPaths.Transit) + public async Task RotateEncryptionKeyAsync(string keyName, string mountPoint = SecretsEngineDefaultPaths.Transit) { Checker.NotNull(keyName, "keyName"); Checker.NotNull(mountPoint, "mountPoint"); await _polymath.MakeVaultApiRequest( "v1/" + mountPoint.Trim('/') + "/keys/" + keyName.Trim('/') + "/rotate", - HttpMethod.Post, - requestData: null, - wrapTimeToLive: null) + HttpMethod.Post) .ConfigureAwait(_polymath.VaultClientSettings.ContinueAsyncTasksOnCapturedContext); } @@ -118,8 +110,7 @@ public async Task> RewrapAsync(string keyName, Rewrap return await _polymath.MakeVaultApiRequest>( "v1/" + mountPoint.Trim('/') + "/rewrap/" + keyName.Trim('/'), HttpMethod.Post, - rewrapRequestOptions, - wrapTimeToLive: null) + rewrapRequestOptions) .ConfigureAwait(_polymath.VaultClientSettings.ContinueAsyncTasksOnCapturedContext); } } diff --git a/src/VaultSharp/V1/SecretsEngines/Transit/UpdateKeyRequestOptions.cs b/src/VaultSharp/V1/SecretsEngines/Transit/UpdateKeyRequestOptions.cs index 59b3bb89..5233e1fb 100644 --- a/src/VaultSharp/V1/SecretsEngines/Transit/UpdateKeyRequestOptions.cs +++ b/src/VaultSharp/V1/SecretsEngines/Transit/UpdateKeyRequestOptions.cs @@ -11,21 +11,21 @@ public class UpdateKeyRequestOptions /// /// Specifies if the key is allowed to be deleted. /// - [JsonProperty(PropertyName = "deletion_allowed", NullValueHandling = NullValueHandling.Ignore)] - public bool? DeletionAllowed { get; set; } + [JsonProperty(PropertyName = "deletion_allowed")] + public bool DeletionAllowed { get; set; } /// /// Enables keys to be exportable. This allows for all the valid keys in the key ring to be /// exported. Once set, this cannot be disabled. /// - [JsonProperty(PropertyName = "exportable", NullValueHandling = NullValueHandling.Ignore)] - public bool? Exportable { get; set; } + [JsonProperty(PropertyName = "exportable")] + public bool Exportable { get; set; } /// /// Enables taking backup of named key in the plaintext format. Once set, this cannot be disabled. /// - [JsonProperty(PropertyName = "allow_plaintext_backup", NullValueHandling = NullValueHandling.Ignore)] - public bool? AllowPlaintextBackup { get; set; } + [JsonProperty(PropertyName = "allow_plaintext_backup")] + public bool AllowPlaintextBackup { get; set; } /// /// Specifies the minimum version of ciphertext allowed to be decrypted. Adjusting this as part @@ -34,15 +34,15 @@ public class UpdateKeyRequestOptions /// signature that can be verified against. For HMACs, this controls the minimum version of a /// key allowed to be used as the key for verification. /// - [JsonProperty(PropertyName = "min_decryption_version", NullValueHandling = NullValueHandling.Ignore)] - public int? MinimumDecryptionVersion { get; set; } + [JsonProperty(PropertyName = "min_decryption_version")] + public int MinimumDecryptionVersion { get; set; } /// /// Specifies the minimum version of the key that can be used to encrypt plaintext, sign payloads, /// or generate HMACs. Must be 0 (which will use the latest version) or a value greater or equal /// to min_decryption_version. /// - [JsonProperty(PropertyName = "min_encryption_version", NullValueHandling = NullValueHandling.Ignore)] - public int? MinimumEncryptionVersion { get; set; } + [JsonProperty(PropertyName = "min_encryption_version")] + public int MinimumEncryptionVersion { get; set; } } } \ No newline at end of file