From e1a11c37e338081f1565b48d7d235f153418ecfe Mon Sep 17 00:00:00 2001 From: Daniel Hougaard Date: Fri, 4 Apr 2025 06:02:47 +0400 Subject: [PATCH 1/4] docs(sdk): go sdk kms docs --- docs/sdks/languages/go.mdx | 358 ++++++++++++++++++++++++++++++++++++- 1 file changed, 356 insertions(+), 2 deletions(-) diff --git a/docs/sdks/languages/go.mdx b/docs/sdks/languages/go.mdx index 47bc9a9ea..e2af279cc 100644 --- a/docs/sdks/languages/go.mdx +++ b/docs/sdks/languages/go.mdx @@ -284,7 +284,7 @@ if err != nil { } ``` -## Working With Secrets +## Secrets ### List Secrets @@ -588,7 +588,7 @@ Create multiple secrets in Infisical. -## Working With Folders +## Folders ### @@ -745,3 +745,357 @@ deletedFolder, err := client.Folders().Delete(infisical.DeleteFolderOptions{ + +## KMS + +### Create Key + +`client.Kms().Keys().Create(options)` + +Create a new key in Infisical. + +```go + newKey, err := client.Kms().Keys().Create(infisical.KmsCreateKeyOptions{ + KeyUsage: "|", + Description: "", + Name: "", + EncryptionAlgorithm: "|||", + ProjectId: "", + }) +``` + +#### Parameters + + + + + The usage of the key. Valid options are `sign-verify` or `encrypt-decrypt`. + The usage dictates what the key can be used for. + + + The description of the key. + + + The name of the key. + + + The encryption algorithm of the key. + + Valid options for Signing/Verifying keys are: + - `rsa-4096` + - `ecc-nist-p256` + + Valid options for Encryption/Decryption keys are: + - `aes-256-gcm` + - `aes-128-gcm` + + + The ID of the project where the key will be created. + + + + +#### Return (object) + + + + The ID of the key that was created. + + + The name of the key that was created. + + + The description of the key that was created. + + + Whether or not the key is disabled. + + + The ID of the organization that the key belongs to. + + + The ID of the project that the key belongs to. + + + The intended usage of the key that was created. + + + The encryption algorithm of the key that was created. + + + The version of the key that was created. + + + + +### Delete Key + +`client.Kms().Keys().Delete(options)` + +Delete a key in Infisical. + +```go +deletedKey, err = client.Kms().Keys().Delete(infisical.KmsDeleteKeyOptions{ + KeyId: "", + }) +``` + +#### Parameters + + + + + The ID of the key to delete. + + + + +#### Return (object) + + + + The ID of the key that was deleted + + + The name of the key that was deleted. + + + The description of the key that was deleted. + + + Whether or not the key is disabled. + + + The ID of the organization that the key belonged to. + + + The ID of the project that the key belonged to. + + + The intended usage of the key that was deleted. + + + The encryption algorithm of the key that was deleted. + + + The version of the key that was deleted. + + + + +### Signing Data + +`client.Kms().Signing().Sign(options)` +Sign data in Infisical. + +```go +res, err := client.Kms().Signing().SignData(infisical.KmsSignDataOptions{ + KeyId: "", + Data: "", // Must be a base64 encoded string. + SigningAlgorithm: "", // The signing algorithm that will be used to sign the data. +}) +``` + +#### Parameters + + + + + The ID of the key to sign the data with. + + + The data to sign. Must be a base64 encoded string. + + + The signing algorithm to use. You must use a signing algorithm that matches the key usage. + + + If you are unsure about which signing algorithms are available for your key, you can use the `client.Kms().Signing().ListSigningAlgorithms()` method. It will return an array of signing algorithms that are available for your key. + + + Valid options for `RSA 4096` keys are: + - `RSASSA_PSS_SHA_512` + - `RSASSA_PSS_SHA_384` + - `RSASSA_PSS_SHA_256` + - `RSASSA_PKCS1_V1_5_SHA_512` + - `RSASSA_PKCS1_V1_5_SHA_384` + - `RSASSA_PKCS1_V1_5_SHA_256` + + Valid options for `ECC NIST P256` keys are: + - `ECDSA_SHA_512` + - `ECDSA_SHA_384` + - `ECDSA_SHA_256` + + + + +#### Return (object) + + + + The signature of the data that was signed. + + + The ID of the key that was used to sign the data. + + + The signing algorithm that was used to sign the data. + + + + +### Verifying Data + +`client.Kms().Signing().Verify(options)` +Verify data in Infisical. + +```go +res, err := client.Kms().Signing().Verify(infisical.KmsVerifyDataOptions{ + KeyId: "", + Data: "", // Must be a base64 encoded string. + SigningAlgorithm: "", // The signing algorithm that was used to sign the data. +}) +``` + +#### Parameters + + + + + The ID of the key to verify the data with. + + + The data to verify. Must be a base64 encoded string. + + + The signing algorithm that was used to sign the data. + + + + +#### Return (object) + + + + Whether or not the data is valid. + + + The ID of the key that was used to verify the data. + + + The signing algorithm that was used to verify the data. + + + + +### List Signing Algorithms + +`client.Kms().Signing().ListSigningAlgorithms(options)` +List signing algorithms in Infisical. + +```go +res, err := client.Kms().Signing().ListSigningAlgorithms(infisical.KmsListSigningAlgorithmsOptions{ + KeyId: "", +}) +``` + +#### Parameters + + + + + The ID of the key to list signing algorithms for. + + + + +#### Return ([]string) + + The signing algorithms that are available for the key. + + +### Get Public Key + + This method is only available for keys with key usage `sign-verify`. If you attempt to use this method on a key that is intended for encryption/decryption, it will return an error. + + +`client.Kms().Signing().GetPublicKey(options)` +Get the public key in Infisical. + +```go +publicKey, err := client.Kms().Signing().GetPublicKey(infisical.KmsGetPublicKeyOptions{ + KeyId: "", +}) +``` + +#### Parameters + + + + + The ID of the key to get the public key for. + + + + +#### Return (string) + + The public key for the key. + + +### Encrypt Data + +`client.Kms().Encryption().Encrypt(options)` +Encrypt data with a key in Infisical KMS. + +```go +res, err := client.Kms().EncryptData(infisical.KmsEncryptDataOptions{ + KeyId: "", + Plaintext: "", +}) +``` + +#### Parameters + + + + + The ID of the key to encrypt the data with. + + + + +#### Return (string) + + The encrypted data. + + +### Decrypt Data + +`client.Kms().DecryptData(options)` +Decrypt data with a key in Infisical KMS. + +```go +res, err := client.Kms().DecryptData(infisical.KmsDecryptDataOptions{ + KeyId: "", + Ciphertext: "", +}) +``` + +#### Parameters + + + + + The ID of the key to decrypt the data with. + + + The encrypted data to decrypt. + + + + +#### Return (string) + + The decrypted data. + From 041d585f19e010f1dcad922ba9766895b858c186 Mon Sep 17 00:00:00 2001 From: Daniel Hougaard Date: Wed, 9 Apr 2025 02:11:43 +0400 Subject: [PATCH 2/4] Update go.mdx --- docs/sdks/languages/go.mdx | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/docs/sdks/languages/go.mdx b/docs/sdks/languages/go.mdx index e2af279cc..b8dbb92ab 100644 --- a/docs/sdks/languages/go.mdx +++ b/docs/sdks/languages/go.mdx @@ -906,6 +906,9 @@ res, err := client.Kms().Signing().SignData(infisical.KmsSignDataOptions{ The data to sign. Must be a base64 encoded string. + + Whether the data is already digested or not. + The signing algorithm to use. You must use a signing algorithm that matches the key usage. @@ -929,19 +932,9 @@ res, err := client.Kms().Signing().SignData(infisical.KmsSignDataOptions{ -#### Return (object) - - - - The signature of the data that was signed. - - - The ID of the key that was used to sign the data. - - - The signing algorithm that was used to sign the data. - - +#### Return ([]byte) + + The signature of the data that was signed. ### Verifying Data @@ -967,6 +960,9 @@ res, err := client.Kms().Signing().Verify(infisical.KmsVerifyDataOptions{ The data to verify. Must be a base64 encoded string. + + Whether the data is already digested or not. + The signing algorithm that was used to sign the data. From 8d4fa0bdb972e6055541410a82482dff62dbb71b Mon Sep 17 00:00:00 2001 From: Daniel Hougaard Date: Tue, 15 Apr 2025 03:51:30 +0400 Subject: [PATCH 3/4] fix: rename `IsDigest` to `IsPreDigested` --- docs/sdks/languages/go.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sdks/languages/go.mdx b/docs/sdks/languages/go.mdx index b8dbb92ab..4078a109c 100644 --- a/docs/sdks/languages/go.mdx +++ b/docs/sdks/languages/go.mdx @@ -906,7 +906,7 @@ res, err := client.Kms().Signing().SignData(infisical.KmsSignDataOptions{ The data to sign. Must be a base64 encoded string. - + Whether the data is already digested or not. @@ -960,7 +960,7 @@ res, err := client.Kms().Signing().Verify(infisical.KmsVerifyDataOptions{ The data to verify. Must be a base64 encoded string. - + Whether the data is already digested or not. From 24bf9f7a2a6402aa96b3f804337a7adf30edbc2c Mon Sep 17 00:00:00 2001 From: Daniel Hougaard Date: Tue, 15 Apr 2025 05:24:39 +0400 Subject: [PATCH 4/4] Revert "fix: rename `IsDigest` to `IsPreDigested`" This reverts commit 8d4fa0bdb972e6055541410a82482dff62dbb71b. --- docs/sdks/languages/go.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sdks/languages/go.mdx b/docs/sdks/languages/go.mdx index 4078a109c..b8dbb92ab 100644 --- a/docs/sdks/languages/go.mdx +++ b/docs/sdks/languages/go.mdx @@ -906,7 +906,7 @@ res, err := client.Kms().Signing().SignData(infisical.KmsSignDataOptions{ The data to sign. Must be a base64 encoded string. - + Whether the data is already digested or not. @@ -960,7 +960,7 @@ res, err := client.Kms().Signing().Verify(infisical.KmsVerifyDataOptions{ The data to verify. Must be a base64 encoded string. - + Whether the data is already digested or not.