diff --git a/AwsEncryptionSDK/runtimes/go/examples/cryptographicmaterialsmanager/requiredencryptioncontext/requiredencryptioncontext.go b/AwsEncryptionSDK/runtimes/go/examples/cryptographicmaterialsmanager/requiredencryptioncontext/requiredencryptioncontext.go index f0f42d548..0d85508ba 100644 --- a/AwsEncryptionSDK/runtimes/go/examples/cryptographicmaterialsmanager/requiredencryptioncontext/requiredencryptioncontext.go +++ b/AwsEncryptionSDK/runtimes/go/examples/cryptographicmaterialsmanager/requiredencryptioncontext/requiredencryptioncontext.go @@ -18,7 +18,6 @@ import ( mpltypes "github.com/aws/aws-cryptographic-material-providers-library/mpl/awscryptographymaterialproviderssmithygeneratedtypes" client "github.com/aws/aws-encryption-sdk/awscryptographyencryptionsdksmithygenerated" esdktypes "github.com/aws/aws-encryption-sdk/awscryptographyencryptionsdksmithygeneratedtypes" - "github.com/aws/aws-encryption-sdk/examples/utils" "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/service/kms" ) @@ -30,7 +29,7 @@ func RequiredEncryptionContextExample(exampleText, defaultKMSKeyId, defaultKmsKe panic(err) } kmsClient := kms.NewFromConfig(cfg, func(o *kms.Options) { - o.Region = utils.GetDefaultKmsKeyRegion() + o.Region = defaultKmsKeyRegion }) // Step 2: Initialize the mpl client matProv, err := mpl.NewClient(mpltypes.MaterialProvidersConfig{}) @@ -40,7 +39,7 @@ func RequiredEncryptionContextExample(exampleText, defaultKMSKeyId, defaultKmsKe // Step 3: Create the keyring awsKmsKeyringInput := mpltypes.CreateAwsKmsKeyringInput{ KmsClient: kmsClient, - KmsKeyId: utils.GetDefaultKMSKeyId(), + KmsKeyId: defaultKMSKeyId, } awsKmsKeyring, err := matProv.CreateAwsKmsKeyring(context.Background(), awsKmsKeyringInput) if err != nil { diff --git a/AwsEncryptionSDK/runtimes/go/examples/main.go b/AwsEncryptionSDK/runtimes/go/examples/main.go index 3662ac551..434034783 100644 --- a/AwsEncryptionSDK/runtimes/go/examples/main.go +++ b/AwsEncryptionSDK/runtimes/go/examples/main.go @@ -30,132 +30,132 @@ func main() { const stringToEncrypt = "Text To encrypt" clientsupplier.ClientSupplierExample( stringToEncrypt, - utils.GetDefaultRegionMrkKeyArn(), - utils.GetDefaultKMSKeyAccountID(), + utils.DefaultRegionMrkKeyArn(), + utils.DefaultKMSKeyAccountID(), []string{"eu-west-1"}) misc.CommitmentPolicyExample( stringToEncrypt, - utils.GetDefaultKMSKeyId(), - utils.GetDefaultKmsKeyRegion()) + utils.DefaultKMSKeyId(), + utils.DefaultKmsKeyRegion()) misc.SetEncryptionAlgorithmSuiteExample(stringToEncrypt) var maxEncryptedDataKeys int64 = 3 misc.LimitEncryptedDataKeyExample( stringToEncrypt, - utils.GetDefaultKMSKeyId(), - utils.GetDefaultKmsKeyRegion(), + utils.DefaultKMSKeyId(), + utils.DefaultKmsKeyRegion(), maxEncryptedDataKeys) requiredencryptioncontext.RequiredEncryptionContextExample( stringToEncrypt, - utils.GetDefaultKMSKeyId(), - utils.GetDefaultKmsKeyRegion()) + utils.DefaultKMSKeyId(), + utils.DefaultKmsKeyRegion()) restrictalgorithmsuite.SigningOnlyExample( stringToEncrypt, - utils.GetDefaultKMSKeyId(), - utils.GetDefaultKmsKeyRegion()) + utils.DefaultKMSKeyId(), + utils.DefaultKmsKeyRegion()) // keyrings ecdh.PublicKeyRawEcdhDiscoveryKeyringExample( stringToEncrypt, primitivestypes.ECDHCurveSpecEccNistP256, - utils.GetEccPublicKeyFileNameRecipient(), - utils.GetEccPrivateKeyFileNameRecipient()) + utils.EccPublicKeyFileNameRecipient(), + utils.EccPrivateKeyFileNameRecipient()) ecdh.EphemeralRawECDHKeyringExample( stringToEncrypt, primitivestypes.ECDHCurveSpecEccNistP256, - utils.GetEccPublicKeyFileNameRecipient()) + utils.EccPublicKeyFileNameRecipient()) ecdh.RawECDHKeyringExample( stringToEncrypt, primitivestypes.ECDHCurveSpecEccNistP256, - utils.GetEccPublicKeyFileNameRecipient(), - utils.GetEccPrivateKeyFileNameSender()) + utils.EccPublicKeyFileNameRecipient(), + utils.EccPrivateKeyFileNameSender()) ecdh.AwsKmsEcdhKeyringExample( stringToEncrypt, primitivestypes.ECDHCurveSpecEccNistP256, - utils.GetKmsEcdhKeyIdP256RecipientKeyId(), - utils.GetKmsEcdhKeyIdP256SenderKeyId(), - utils.GetKmsEccPublicKeyFileNameSender(), - utils.GetKmsEccPublicKeyFileNameRecipient()) + utils.KmsEcdhKeyIdP256RecipientKeyId(), + utils.KmsEcdhKeyIdP256SenderKeyId(), + utils.KmsEccPublicKeyFileNameSender(), + utils.KmsEccPublicKeyFileNameRecipient()) ecdh.AwsKmsEcdhDiscoveryKeyringExample( stringToEncrypt, primitivestypes.ECDHCurveSpecEccNistP256, - utils.GetKmsEcdhKeyIdP256RecipientKeyId(), - utils.GetKmsEcdhKeyIdP256SenderKeyId(), - utils.GetKmsEccPublicKeyFileNameSender(), - utils.GetKmsEccPublicKeyFileNameRecipient()) + utils.KmsEcdhKeyIdP256RecipientKeyId(), + utils.KmsEcdhKeyIdP256SenderKeyId(), + utils.KmsEccPublicKeyFileNameSender(), + utils.KmsEccPublicKeyFileNameRecipient()) awskmskeyring.AwsKmsKeyringExample( stringToEncrypt, - utils.GetDefaultKMSKeyId(), - utils.GetDefaultKMSKeyAccountID()) + utils.DefaultKMSKeyId(), + utils.DefaultKMSKeyAccountID()) awskmsrsakeyring.AwsKmsRsaExample( stringToEncrypt, - utils.GetTestKmsRsaKeyID(), - utils.GetKmsRSAPublicKey()) + utils.TestKmsRsaKeyID(), + utils.KmsRSAPublicKey()) awskmsmultikeyring.AwsKmsMultiKeyringExample( stringToEncrypt, - utils.GetDefaultKMSKeyId(), - utils.GetAlternateRegionKMSKeyId(), - utils.GetAlternateRegionKMSKeyRegion()) + utils.DefaultKMSKeyId(), + utils.AlternateRegionKMSKeyId(), + utils.AlternateRegionKMSKeyRegion()) awskmsdiscoverykeyring.AwsKmsDiscoveryKeyringExample( stringToEncrypt, - utils.GetDefaultKMSKeyId(), - utils.GetDefaultKMSKeyAccountID()) + utils.DefaultKMSKeyId(), + utils.DefaultKMSKeyAccountID()) awskmsdiscoverymultikeyring.AwsKmsDiscoveryMultiKeyringExample( stringToEncrypt, - utils.GetDefaultKMSKeyId(), - utils.GetDefaultKMSKeyAccountID(), - utils.GetRegions()) + utils.DefaultKMSKeyId(), + utils.DefaultKMSKeyAccountID(), + utils.Regions()) rawrsakeyring.RawRsaExample(stringToEncrypt) awskmsmrkkeyring.AwsKmsMrkKeyringExample( stringToEncrypt, - utils.GetDefaultRegionMrkKeyArn(), - utils.GetAlternateRegionMrkKeyArn(), - utils.GetDefaultMRKKeyRegion(), - utils.GetAlternateRegionMrkKeyRegion()) + utils.DefaultRegionMrkKeyArn(), + utils.AlternateRegionMrkKeyArn(), + utils.DefaultMRKKeyRegion(), + utils.AlternateRegionMrkKeyRegion()) awskmsmrkmultikeyring.AwsKmsMrkMultiKeyringExample( stringToEncrypt, - utils.GetDefaultRegionMrkKeyArn(), - utils.GetAlternateRegionMrkKeyArn(), - utils.GetDefaultKMSKeyId(), - utils.GetAlternateRegionMrkKeyRegion()) + utils.DefaultRegionMrkKeyArn(), + utils.AlternateRegionMrkKeyArn(), + utils.DefaultKMSKeyId(), + utils.AlternateRegionMrkKeyRegion()) awskmsmrkdiscoverykeyring.AwsKmsMrkDiscoveryKeyringExample( stringToEncrypt, - utils.GetDefaultRegionMrkKeyArn(), - utils.GetDefaultMRKKeyRegion(), - utils.GetAlternateRegionMrkKeyRegion(), - utils.GetDefaultKMSKeyAccountID()) + utils.DefaultRegionMrkKeyArn(), + utils.DefaultMRKKeyRegion(), + utils.AlternateRegionMrkKeyRegion(), + utils.DefaultKMSKeyAccountID()) awskmsmrkdiscoverymultikeyring.AwsKmsMrkDiscoveryMultiKeyringExample( stringToEncrypt, - utils.GetDefaultRegionMrkKeyArn(), - utils.GetDefaultMRKKeyRegion(), - utils.GetDefaultKMSKeyAccountID(), - utils.GetRegionsOfMRKKeys(), + utils.DefaultRegionMrkKeyArn(), + utils.DefaultMRKKeyRegion(), + utils.DefaultKMSKeyAccountID(), + utils.RegionsOfMRKKeys(), ) awskmshierarchicalkeyring.AwsKmsHKeyExample( stringToEncrypt, - utils.GetKeyStoreKMSKeyRegion(), - utils.GetKeyStoreRegion(), - utils.GetKeyStoreKMSKeyID(), - utils.GetKeyStoreName(), - utils.GetLogicalKeyStoreName(), + utils.KeyStoreKMSKeyRegion(), + utils.KeyStoreRegion(), + utils.KeyStoreKMSKeyID(), + utils.KeyStoreName(), + utils.LogicalKeyStoreName(), ) awskmshierarchicalkeyring.CreateAndVersionBranchKeyId( - utils.GetKeyStoreKMSKeyRegion(), - utils.GetKeyStoreRegion(), - utils.GetKeyStoreKMSKeyID(), - utils.GetKeyStoreName(), - utils.GetLogicalKeyStoreName(), + utils.KeyStoreKMSKeyRegion(), + utils.KeyStoreRegion(), + utils.KeyStoreKMSKeyID(), + utils.KeyStoreName(), + utils.LogicalKeyStoreName(), ) awskmshierarchicalkeyring.SharedCacheExample( stringToEncrypt, - utils.GetKeyStoreKMSKeyRegion(), - utils.GetKeyStoreRegion(), - utils.GetKeyStoreKMSKeyID(), - utils.GetKeyStoreName(), - utils.GetLogicalKeyStoreName(), + utils.KeyStoreKMSKeyRegion(), + utils.KeyStoreRegion(), + utils.KeyStoreKMSKeyID(), + utils.KeyStoreName(), + utils.LogicalKeyStoreName(), ) rawaeskeyring.RawAesExample(stringToEncrypt) multikeyring.MultiKeyringExample( stringToEncrypt, - utils.GetDefaultKMSKeyId(), - utils.GetDefaultKmsKeyRegion(), + utils.DefaultKMSKeyId(), + utils.DefaultKmsKeyRegion(), ) } diff --git a/AwsEncryptionSDK/runtimes/go/examples/utils/exampleUtils.go b/AwsEncryptionSDK/runtimes/go/examples/utils/exampleUtils.go index 63639b5e6..ddc75bf1b 100644 --- a/AwsEncryptionSDK/runtimes/go/examples/utils/exampleUtils.go +++ b/AwsEncryptionSDK/runtimes/go/examples/utils/exampleUtils.go @@ -51,103 +51,103 @@ twIDAQAB // Getter functions -func GetKmsEcdhKeyIdP256SenderKeyId() string { +func KmsEcdhKeyIdP256SenderKeyId() string { return testKmsEcdhKeyIdP256SenderKeyId } -func GetKmsEcdhKeyIdP256RecipientKeyId() string { +func KmsEcdhKeyIdP256RecipientKeyId() string { return testKmsEcdhKeyIdP256RecipientKeyId } -func GetKmsEccPublicKeyFileNameRecipient() string { +func KmsEccPublicKeyFileNameRecipient() string { return kmsEccPublicKeyFileNameRecipient } -func GetKmsEccPublicKeyFileNameSender() string { +func KmsEccPublicKeyFileNameSender() string { return kmsEccPublicKeyFileNameSender } -func GetEccPrivateKeyFileNameSender() string { +func EccPrivateKeyFileNameSender() string { return eccPrivateKeyFileNameSender } -func GetEccPrivateKeyFileNameRecipient() string { +func EccPrivateKeyFileNameRecipient() string { return eccPrivateKeyFileNameRecipient } -func GetEccPublicKeyFileNameRecipient() string { +func EccPublicKeyFileNameRecipient() string { return eccPublicKeyFileNameRecipient } -func GetRegionsOfMRKKeys() []string { +func RegionsOfMRKKeys() []string { return []string{defaultMRKKeyRegion, alternateRegionMrkKeyRegion} } -func GetRegions() []string { +func Regions() []string { return []string{defaultKmsKeyRegion, testAlternateRegionKMSKeyRegion} } -func GetDefaultKmsKeyRegion() string { +func DefaultKmsKeyRegion() string { return defaultKmsKeyRegion } -func GetDefaultMRKKeyRegion() string { +func DefaultMRKKeyRegion() string { return defaultMRKKeyRegion } -func GetAlternateRegionMrkKeyRegion() string { +func AlternateRegionMrkKeyRegion() string { return alternateRegionMrkKeyRegion } -func GetAlternateRegionMrkKeyArn() string { +func AlternateRegionMrkKeyArn() string { return testAlternateRegionMrkKeyId } -func GetDefaultRegionMrkKeyArn() string { +func DefaultRegionMrkKeyArn() string { return testDefaultMRKKeyId } -func GetAlternateRegionKMSKeyRegion() string { +func AlternateRegionKMSKeyRegion() string { return testAlternateRegionKMSKeyRegion } -func GetAlternateRegionKMSKeyId() string { +func AlternateRegionKMSKeyId() string { return testAlternateRegionKMSKeyId } -func GetDefaultKMSKeyAccountID() string { +func DefaultKMSKeyAccountID() string { return defaultKMSKeyAccountID } -func GetDefaultKMSKeyId() string { +func DefaultKMSKeyId() string { return testDefaultKMSKeyId } -func GetTestKmsRsaKeyID() string { +func TestKmsRsaKeyID() string { return testKmsRsaKeyID } -func GetKmsRSAPublicKey() []byte { +func KmsRSAPublicKey() []byte { return []byte(testKmsRsaPublicKey) } -func GetKeyStoreRegion() string { +func KeyStoreRegion() string { return testKeyStoreRegion } -func GetKeyStoreKMSKeyRegion() string { +func KeyStoreKMSKeyRegion() string { return testKeyStoreKMSKeyRegion } -func GetKeyStoreKMSKeyID() string { +func KeyStoreKMSKeyID() string { return testKeyStoreKMSKeyID } -func GetLogicalKeyStoreName() string { +func LogicalKeyStoreName() string { return testLogicalKeyStoreName } -func GetKeyStoreName() string { +func KeyStoreName() string { return testKeyStoreName }