diff --git a/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/ECDH/externs.go b/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/ECDH/externs.go index 70e1140cb..c29cb22e2 100644 --- a/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/ECDH/externs.go +++ b/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/ECDH/externs.go @@ -44,7 +44,7 @@ func (CompanionStruct_Default___) GenerateKeyPair(curveSpec AwsCryptographyPrimi } func (CompanionStruct_Default___) CalculateSharedSecret(curveSpec AwsCryptographyPrimitivesTypes.ECDHCurveSpec, - privateKeyInput AwsCryptographyPrimitivesTypes.ECCPrivateKey, publicKeyInput AwsCryptographyPrimitivesTypes.ECCPublicKey) Wrappers.Result { + privateKeyInput AwsCryptographyPrimitivesTypes.ECCPrivateKey, publicKeyInput AwsCryptographyPrimitivesTypes.ECCPublicKey) Wrappers.Result { curve, err := getNativeEcdhCurve(curveSpec) if err != nil { @@ -112,7 +112,7 @@ func (CompanionStruct_Default___) CalculateSharedSecret(curveSpec AwsCryptograph } func (static CompanionStruct_Default___) CompressPublicKey(publicKeyInput dafny.Sequence, - curveSpec AwsCryptographyPrimitivesTypes.ECDHCurveSpec) Wrappers.Result { + curveSpec AwsCryptographyPrimitivesTypes.ECDHCurveSpec) Wrappers.Result { // We only need this because elliptic.MarshalCompressed() doesn't return err handle and panics, so to avoid panic we pre-validate the key. validate := static.ValidatePublicKey(curveSpec, publicKeyInput) @@ -138,7 +138,7 @@ func (static CompanionStruct_Default___) CompressPublicKey(publicKeyInput dafny. } func (CompanionStruct_Default___) DecompressPublicKey(publicKeyInput dafny.Sequence, - curveSpec AwsCryptographyPrimitivesTypes.ECDHCurveSpec) Wrappers.Result { + curveSpec AwsCryptographyPrimitivesTypes.ECDHCurveSpec) Wrappers.Result { publicKeyBytes := dafny.ToByteArray(publicKeyInput) curve, err := getNativeEcdhCurve(curveSpec) diff --git a/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/RSAEncryption/externs.go b/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/RSAEncryption/externs.go index 2344b54bf..ab50f415a 100644 --- a/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/RSAEncryption/externs.go +++ b/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/RSAEncryption/externs.go @@ -34,7 +34,7 @@ func (CompanionStruct_Default___) GenerateKeyPairExtern(bits int32) (dafny.Seque panic(err) } return dafny.SeqOfBytes(pem.EncodeToMemory(&pem.Block{Type: "RSA PUBLIC KEY", Bytes: encodePublicKey})), - dafny.SeqOfBytes(pem.EncodeToMemory(&pem.Block{Type: "RSA PRIVATE KEY", Bytes: encodePrivateKey})) + dafny.SeqOfBytes(pem.EncodeToMemory(&pem.Block{Type: "RSA PRIVATE KEY", Bytes: encodePrivateKey})) } func (m_RSAEncryption_Ghost) RSA_GetRSAKeyModulusLengthExtern(publicKeyInput dafny.Sequence) Wrappers.Result { @@ -52,7 +52,7 @@ func (m_RSAEncryption_Ghost) RSA_GetRSAKeyModulusLengthExtern(publicKeyInput daf } func (CompanionStruct_Default___) DecryptExtern(paddingMode AwsCryptographyPrimitivesTypes.RSAPaddingMode, - key dafny.Sequence, cipher_text dafny.Sequence) Wrappers.Result { + key dafny.Sequence, cipher_text dafny.Sequence) Wrappers.Result { derPrivateKey, rest := pem.Decode(dafny.ToByteArray(key)) if len(rest) > 0 { return Wrappers.Companion_Result_.Create_Failure_(AwsCryptographyPrimitivesTypes.Companion_Error_.Create_AwsCryptographicPrimitivesError_( @@ -89,7 +89,7 @@ func (CompanionStruct_Default___) DecryptExtern(paddingMode AwsCryptographyPrimi } func (CompanionStruct_Default___) EncryptExtern(paddingMode AwsCryptographyPrimitivesTypes.RSAPaddingMode, - key dafny.Sequence, plainText dafny.Sequence) Wrappers.Result { + key dafny.Sequence, plainText dafny.Sequence) Wrappers.Result { derPublicKey, rest := pem.Decode(dafny.ToByteArray(key)) if len(rest) > 0 { return Wrappers.Companion_Result_.Create_Failure_(AwsCryptographyPrimitivesTypes.Companion_Error_.Create_AwsCryptographicPrimitivesError_( diff --git a/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/Signature/externs.go b/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/Signature/externs.go index 5a1c69545..18fde54f9 100644 --- a/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/Signature/externs.go +++ b/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/Signature/externs.go @@ -42,7 +42,7 @@ func (CompanionStruct_Default___) ExternKeyGen(algorithm AwsCryptographyPrimitiv } func (CompanionStruct_Default___) Sign(algorithm AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm, - key dafny.Sequence, msg dafny.Sequence) Wrappers.Result { + key dafny.Sequence, msg dafny.Sequence) Wrappers.Result { privateKey, err := x509.ParsePKCS8PrivateKey(dafny.ToByteArray(key)) if err != nil { return Wrappers.Companion_Result_.Create_Failure_(AwsCryptographyPrimitivesTypes.Companion_Error_.Create_AwsCryptographicPrimitivesError_( @@ -75,7 +75,7 @@ func (CompanionStruct_Default___) Sign(algorithm AwsCryptographyPrimitivesTypes. } func ECDSA_Verify(algorithm AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm, key dafny.Sequence, - msg dafny.Sequence, sig dafny.Sequence) Wrappers.Result { + msg dafny.Sequence, sig dafny.Sequence) Wrappers.Result { curve, digestAlgo, _, err := getNativeEC(algorithm) if err != nil { return Wrappers.Companion_Result_.Create_Failure_(AwsCryptographyPrimitivesTypes.Companion_Error_.Create_AwsCryptographicPrimitivesError_( @@ -92,8 +92,8 @@ func ECDSA_Verify(algorithm AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorit return Wrappers.Companion_Result_.Create_Failure_(AwsCryptographyPrimitivesTypes.Companion_Error_.Create_AwsCryptographicPrimitivesError_( dafny.SeqOfChars([]dafny.Char("Failed to decompress verification key")...))) } - res := ecdsa.VerifyASN1(&ecdsa.PublicKey{Curve: curve, X: x, Y: y},dafny.ToByteArray(msgDigest.Dtor_value().(dafny.Sequence)), - dafny.ToByteArray(sig)) + res := ecdsa.VerifyASN1(&ecdsa.PublicKey{Curve: curve, X: x, Y: y}, dafny.ToByteArray(msgDigest.Dtor_value().(dafny.Sequence)), + dafny.ToByteArray(sig)) return Wrappers.Companion_Result_.Create_Success_(res) } @@ -114,7 +114,7 @@ func generateKeyPair(curve elliptic.Curve) ([]byte, []byte, error) { } func getNativeEC(curveSpec AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm) (elliptic.Curve, - AwsCryptographyPrimitivesTypes.DigestAlgorithm, int, error) { + AwsCryptographyPrimitivesTypes.DigestAlgorithm, int, error) { switch curveSpec { case AwsCryptographyPrimitivesTypes.Companion_ECDSASignatureAlgorithm_.Create_ECDSA__P256_(): return elliptic.P256(), AwsCryptographyPrimitivesTypes.Companion_DigestAlgorithm_.Create_SHA__256_(), 71, nil diff --git a/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/WrappedAwsCryptographyPrimitivesService/shim.go b/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/WrappedAwsCryptographyPrimitivesService/shim.go new file mode 100644 index 000000000..625816d56 --- /dev/null +++ b/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/WrappedAwsCryptographyPrimitivesService/shim.go @@ -0,0 +1,241 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package WrappedAwsCryptographyPrimitivesService + +import ( + "context" + + "github.com/aws/aws-cryptographic-material-providers-library/primitives/AwsCryptographyPrimitivesTypes" + "github.com/aws/aws-cryptographic-material-providers-library/primitives/awscryptographyprimitivessmithygenerated" + "github.com/dafny-lang/DafnyStandardLibGo/Wrappers" +) + +type Shim struct { + AwsCryptographyPrimitivesTypes.IAwsCryptographicPrimitivesClient + client *awscryptographyprimitivessmithygenerated.Client +} + +func (_static *CompanionStruct_Default___) WrappedAtomicPrimitives(inputConfig AwsCryptographyPrimitivesTypes.CryptoConfig) Wrappers.Result { + var nativeConfig = awscryptographyprimitivessmithygenerated.CryptoConfig_FromDafny(inputConfig) + var nativeClient, nativeError = awscryptographyprimitivessmithygenerated.NewClient(nativeConfig) + if nativeError != nil { + return Wrappers.Companion_Result_.Create_Failure_(AwsCryptographyPrimitivesTypes.Companion_Error_.Create_Opaque_(nativeError)) + } + return Wrappers.Companion_Result_.Create_Success_(&Shim{client: nativeClient}) +} + +func (shim *Shim) GenerateRandomBytes(input AwsCryptographyPrimitivesTypes.GenerateRandomBytesInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.GenerateRandomBytesInput_FromDafny(input) + var native_response, native_error = shim.client.GenerateRandomBytes(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_GenerateRandomBytesOutput_data_ToDafny(native_response)) +} + +func (shim *Shim) Digest(input AwsCryptographyPrimitivesTypes.DigestInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.DigestInput_FromDafny(input) + var native_response, native_error = shim.client.Digest(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_DigestOutput_digest_ToDafny(native_response)) +} + +func (shim *Shim) HMac(input AwsCryptographyPrimitivesTypes.HMacInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.HMacInput_FromDafny(input) + var native_response, native_error = shim.client.HMac(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_HMacOutput_digest_ToDafny(native_response)) +} + +func (shim *Shim) HkdfExtract(input AwsCryptographyPrimitivesTypes.HkdfExtractInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.HkdfExtractInput_FromDafny(input) + var native_response, native_error = shim.client.HkdfExtract(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_HkdfExtractOutput_prk_ToDafny(native_response)) +} + +func (shim *Shim) HkdfExpand(input AwsCryptographyPrimitivesTypes.HkdfExpandInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.HkdfExpandInput_FromDafny(input) + var native_response, native_error = shim.client.HkdfExpand(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_HkdfExpandOutput_okm_ToDafny(native_response)) +} + +func (shim *Shim) Hkdf(input AwsCryptographyPrimitivesTypes.HkdfInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.HkdfInput_FromDafny(input) + var native_response, native_error = shim.client.Hkdf(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_HkdfOutput_okm_ToDafny(native_response)) +} + +func (shim *Shim) KdfCounterMode(input AwsCryptographyPrimitivesTypes.KdfCtrInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.KdfCtrInput_FromDafny(input) + var native_response, native_error = shim.client.KdfCounterMode(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_KdfCtrOutput_okm_ToDafny(native_response)) +} + +func (shim *Shim) AesKdfCounterMode(input AwsCryptographyPrimitivesTypes.AesKdfCtrInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.AesKdfCtrInput_FromDafny(input) + var native_response, native_error = shim.client.AesKdfCounterMode(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_AesKdfCtrOutput_okm_ToDafny(native_response)) +} + +func (shim *Shim) AESEncrypt(input AwsCryptographyPrimitivesTypes.AESEncryptInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.AESEncryptInput_FromDafny(input) + var native_response, native_error = shim.client.AESEncrypt(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.AESEncryptOutput_ToDafny(*native_response)) +} + +func (shim *Shim) AESDecrypt(input AwsCryptographyPrimitivesTypes.AESDecryptInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.AESDecryptInput_FromDafny(input) + var native_response, native_error = shim.client.AESDecrypt(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_AESDecryptOutput_plaintext_ToDafny(native_response)) +} + +func (shim *Shim) GenerateRSAKeyPair(input AwsCryptographyPrimitivesTypes.GenerateRSAKeyPairInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.GenerateRSAKeyPairInput_FromDafny(input) + var native_response, native_error = shim.client.GenerateRSAKeyPair(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.GenerateRSAKeyPairOutput_ToDafny(*native_response)) +} + +func (shim *Shim) GetRSAKeyModulusLength(input AwsCryptographyPrimitivesTypes.GetRSAKeyModulusLengthInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.GetRSAKeyModulusLengthInput_FromDafny(input) + var native_response, native_error = shim.client.GetRSAKeyModulusLength(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.GetRSAKeyModulusLengthOutput_ToDafny(*native_response)) +} + +func (shim *Shim) RSADecrypt(input AwsCryptographyPrimitivesTypes.RSADecryptInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.RSADecryptInput_FromDafny(input) + var native_response, native_error = shim.client.RSADecrypt(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_RSADecryptOutput_plaintext_ToDafny(native_response)) +} + +func (shim *Shim) RSAEncrypt(input AwsCryptographyPrimitivesTypes.RSAEncryptInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.RSAEncryptInput_FromDafny(input) + var native_response, native_error = shim.client.RSAEncrypt(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_RSAEncryptOutput_cipherText_ToDafny(native_response)) +} + +func (shim *Shim) GenerateECDSASignatureKey(input AwsCryptographyPrimitivesTypes.GenerateECDSASignatureKeyInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.GenerateECDSASignatureKeyInput_FromDafny(input) + var native_response, native_error = shim.client.GenerateECDSASignatureKey(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.GenerateECDSASignatureKeyOutput_ToDafny(*native_response)) +} + +func (shim *Shim) ECDSASign(input AwsCryptographyPrimitivesTypes.ECDSASignInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.ECDSASignInput_FromDafny(input) + var native_response, native_error = shim.client.ECDSASign(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_ECDSASignOutput_signature_ToDafny(native_response)) +} + +func (shim *Shim) ECDSAVerify(input AwsCryptographyPrimitivesTypes.ECDSAVerifyInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.ECDSAVerifyInput_FromDafny(input) + var native_response, native_error = shim.client.ECDSAVerify(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_ECDSAVerifyOutput_success_ToDafny(native_response)) +} + +func (shim *Shim) GenerateECCKeyPair(input AwsCryptographyPrimitivesTypes.GenerateECCKeyPairInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.GenerateECCKeyPairInput_FromDafny(input) + var native_response, native_error = shim.client.GenerateECCKeyPair(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.GenerateECCKeyPairOutput_ToDafny(*native_response)) +} + +func (shim *Shim) GetPublicKeyFromPrivateKey(input AwsCryptographyPrimitivesTypes.GetPublicKeyFromPrivateKeyInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.GetPublicKeyFromPrivateKeyInput_FromDafny(input) + var native_response, native_error = shim.client.GetPublicKeyFromPrivateKey(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.GetPublicKeyFromPrivateKeyOutput_ToDafny(*native_response)) +} + +func (shim *Shim) ValidatePublicKey(input AwsCryptographyPrimitivesTypes.ValidatePublicKeyInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.ValidatePublicKeyInput_FromDafny(input) + var native_response, native_error = shim.client.ValidatePublicKey(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.ValidatePublicKeyOutput_ToDafny(*native_response)) +} + +func (shim *Shim) DeriveSharedSecret(input AwsCryptographyPrimitivesTypes.DeriveSharedSecretInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.DeriveSharedSecretInput_FromDafny(input) + var native_response, native_error = shim.client.DeriveSharedSecret(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.DeriveSharedSecretOutput_ToDafny(*native_response)) +} + +func (shim *Shim) CompressPublicKey(input AwsCryptographyPrimitivesTypes.CompressPublicKeyInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.CompressPublicKeyInput_FromDafny(input) + var native_response, native_error = shim.client.CompressPublicKey(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.CompressPublicKeyOutput_ToDafny(*native_response)) +} + +func (shim *Shim) DecompressPublicKey(input AwsCryptographyPrimitivesTypes.DecompressPublicKeyInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.DecompressPublicKeyInput_FromDafny(input) + var native_response, native_error = shim.client.DecompressPublicKey(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.DecompressPublicKeyOutput_ToDafny(*native_response)) +} + +func (shim *Shim) ParsePublicKey(input AwsCryptographyPrimitivesTypes.ParsePublicKeyInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.ParsePublicKeyInput_FromDafny(input) + var native_response, native_error = shim.client.ParsePublicKey(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.ParsePublicKeyOutput_ToDafny(*native_response)) +} diff --git a/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/awscryptographyprimitivessmithygenerated/api_client.go b/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/awscryptographyprimitivessmithygenerated/api_client.go new file mode 100644 index 000000000..7c6437db0 --- /dev/null +++ b/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/awscryptographyprimitivessmithygenerated/api_client.go @@ -0,0 +1,557 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package awscryptographyprimitivessmithygenerated + +import ( + "context" + + "github.com/aws/aws-cryptographic-material-providers-library/primitives/AtomicPrimitives" + "github.com/aws/aws-cryptographic-material-providers-library/primitives/AwsCryptographyPrimitivesTypes" + "github.com/aws/aws-cryptographic-material-providers-library/primitives/awscryptographyprimitivessmithygeneratedtypes" + "github.com/dafny-lang/DafnyRuntimeGo/v4/dafny" +) + +type Client struct { + DafnyClient AwsCryptographyPrimitivesTypes.IAwsCryptographicPrimitivesClient +} + +func NewClient(clientConfig awscryptographyprimitivessmithygeneratedtypes.CryptoConfig) (*Client, error) { + var dafnyConfig = CryptoConfig_ToDafny(clientConfig) + var dafny_response = AtomicPrimitives.Companion_Default___.AtomicPrimitives(dafnyConfig) + if dafny_response.Is_Failure() { + panic("Client construction failed. This should never happen") + } + var dafnyClient = dafny_response.Extract().(AwsCryptographyPrimitivesTypes.IAwsCryptographicPrimitivesClient) + client := &Client{dafnyClient} + return client, nil +} + +func (client *Client) GenerateRandomBytes(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.GenerateRandomBytesInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.GenerateRandomBytesInput = GenerateRandomBytesInput_ToDafny(params) + var dafny_response = client.DafnyClient.GenerateRandomBytes(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_GenerateRandomBytesOutput_data_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) Digest(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.DigestInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.DigestInput = DigestInput_ToDafny(params) + var dafny_response = client.DafnyClient.Digest(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_DigestOutput_digest_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) HMac(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.HMacInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.HMacInput = HMacInput_ToDafny(params) + var dafny_response = client.DafnyClient.HMac(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_HMacOutput_digest_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) HkdfExtract(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.HkdfExtractInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.HkdfExtractInput = HkdfExtractInput_ToDafny(params) + var dafny_response = client.DafnyClient.HkdfExtract(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_HkdfExtractOutput_prk_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) HkdfExpand(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.HkdfExpandInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.HkdfExpandInput = HkdfExpandInput_ToDafny(params) + var dafny_response = client.DafnyClient.HkdfExpand(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_HkdfExpandOutput_okm_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) Hkdf(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.HkdfInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.HkdfInput = HkdfInput_ToDafny(params) + var dafny_response = client.DafnyClient.Hkdf(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_HkdfOutput_okm_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) KdfCounterMode(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.KdfCtrInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.KdfCtrInput = KdfCtrInput_ToDafny(params) + var dafny_response = client.DafnyClient.KdfCounterMode(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_KdfCtrOutput_okm_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) AesKdfCounterMode(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.AesKdfCtrInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.AesKdfCtrInput = AesKdfCtrInput_ToDafny(params) + var dafny_response = client.DafnyClient.AesKdfCounterMode(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_AesKdfCtrOutput_okm_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) AESEncrypt(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.AESEncryptInput) (*awscryptographyprimitivessmithygeneratedtypes.AESEncryptOutput, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + return nil, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.AESEncryptInput = AESEncryptInput_ToDafny(params) + var dafny_response = client.DafnyClient.AESEncrypt(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + return nil, Error_FromDafny(err) + } + var native_response = AESEncryptOutput_FromDafny(dafny_response.Dtor_value().(AwsCryptographyPrimitivesTypes.AESEncryptOutput)) + return &native_response, nil + +} + +func (client *Client) AESDecrypt(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.AESDecryptInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.AESDecryptInput = AESDecryptInput_ToDafny(params) + var dafny_response = client.DafnyClient.AESDecrypt(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_AESDecryptOutput_plaintext_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) GenerateRSAKeyPair(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.GenerateRSAKeyPairInput) (*awscryptographyprimitivessmithygeneratedtypes.GenerateRSAKeyPairOutput, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + return nil, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.GenerateRSAKeyPairInput = GenerateRSAKeyPairInput_ToDafny(params) + var dafny_response = client.DafnyClient.GenerateRSAKeyPair(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + return nil, Error_FromDafny(err) + } + var native_response = GenerateRSAKeyPairOutput_FromDafny(dafny_response.Dtor_value().(AwsCryptographyPrimitivesTypes.GenerateRSAKeyPairOutput)) + return &native_response, nil + +} + +func (client *Client) GetRSAKeyModulusLength(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.GetRSAKeyModulusLengthInput) (*awscryptographyprimitivessmithygeneratedtypes.GetRSAKeyModulusLengthOutput, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + return nil, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.GetRSAKeyModulusLengthInput = GetRSAKeyModulusLengthInput_ToDafny(params) + var dafny_response = client.DafnyClient.GetRSAKeyModulusLength(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + return nil, Error_FromDafny(err) + } + var native_response = GetRSAKeyModulusLengthOutput_FromDafny(dafny_response.Dtor_value().(AwsCryptographyPrimitivesTypes.GetRSAKeyModulusLengthOutput)) + return &native_response, nil + +} + +func (client *Client) RSADecrypt(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.RSADecryptInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.RSADecryptInput = RSADecryptInput_ToDafny(params) + var dafny_response = client.DafnyClient.RSADecrypt(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_RSADecryptOutput_plaintext_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) RSAEncrypt(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.RSAEncryptInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.RSAEncryptInput = RSAEncryptInput_ToDafny(params) + var dafny_response = client.DafnyClient.RSAEncrypt(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_RSAEncryptOutput_cipherText_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) GenerateECDSASignatureKey(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.GenerateECDSASignatureKeyInput) (*awscryptographyprimitivessmithygeneratedtypes.GenerateECDSASignatureKeyOutput, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + return nil, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.GenerateECDSASignatureKeyInput = GenerateECDSASignatureKeyInput_ToDafny(params) + var dafny_response = client.DafnyClient.GenerateECDSASignatureKey(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + return nil, Error_FromDafny(err) + } + var native_response = GenerateECDSASignatureKeyOutput_FromDafny(dafny_response.Dtor_value().(AwsCryptographyPrimitivesTypes.GenerateECDSASignatureKeyOutput)) + return &native_response, nil + +} + +func (client *Client) ECDSASign(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.ECDSASignInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.ECDSASignInput = ECDSASignInput_ToDafny(params) + var dafny_response = client.DafnyClient.ECDSASign(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_ECDSASignOutput_signature_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) ECDSAVerify(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.ECDSAVerifyInput) (bool, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal bool + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.ECDSAVerifyInput = ECDSAVerifyInput_ToDafny(params) + var dafny_response = client.DafnyClient.ECDSAVerify(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal bool + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_ECDSAVerifyOutput_success_FromDafny(dafny_response.Dtor_value().(bool)) + return native_response, nil + +} + +func (client *Client) GenerateECCKeyPair(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.GenerateECCKeyPairInput) (*awscryptographyprimitivessmithygeneratedtypes.GenerateECCKeyPairOutput, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + return nil, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.GenerateECCKeyPairInput = GenerateECCKeyPairInput_ToDafny(params) + var dafny_response = client.DafnyClient.GenerateECCKeyPair(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + return nil, Error_FromDafny(err) + } + var native_response = GenerateECCKeyPairOutput_FromDafny(dafny_response.Dtor_value().(AwsCryptographyPrimitivesTypes.GenerateECCKeyPairOutput)) + return &native_response, nil + +} + +func (client *Client) GetPublicKeyFromPrivateKey(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.GetPublicKeyFromPrivateKeyInput) (*awscryptographyprimitivessmithygeneratedtypes.GetPublicKeyFromPrivateKeyOutput, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + return nil, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.GetPublicKeyFromPrivateKeyInput = GetPublicKeyFromPrivateKeyInput_ToDafny(params) + var dafny_response = client.DafnyClient.GetPublicKeyFromPrivateKey(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + return nil, Error_FromDafny(err) + } + var native_response = GetPublicKeyFromPrivateKeyOutput_FromDafny(dafny_response.Dtor_value().(AwsCryptographyPrimitivesTypes.GetPublicKeyFromPrivateKeyOutput)) + return &native_response, nil + +} + +func (client *Client) ValidatePublicKey(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.ValidatePublicKeyInput) (*awscryptographyprimitivessmithygeneratedtypes.ValidatePublicKeyOutput, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + return nil, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.ValidatePublicKeyInput = ValidatePublicKeyInput_ToDafny(params) + var dafny_response = client.DafnyClient.ValidatePublicKey(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + return nil, Error_FromDafny(err) + } + var native_response = ValidatePublicKeyOutput_FromDafny(dafny_response.Dtor_value().(AwsCryptographyPrimitivesTypes.ValidatePublicKeyOutput)) + return &native_response, nil + +} + +func (client *Client) DeriveSharedSecret(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.DeriveSharedSecretInput) (*awscryptographyprimitivessmithygeneratedtypes.DeriveSharedSecretOutput, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + return nil, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.DeriveSharedSecretInput = DeriveSharedSecretInput_ToDafny(params) + var dafny_response = client.DafnyClient.DeriveSharedSecret(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + return nil, Error_FromDafny(err) + } + var native_response = DeriveSharedSecretOutput_FromDafny(dafny_response.Dtor_value().(AwsCryptographyPrimitivesTypes.DeriveSharedSecretOutput)) + return &native_response, nil + +} + +func (client *Client) CompressPublicKey(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.CompressPublicKeyInput) (*awscryptographyprimitivessmithygeneratedtypes.CompressPublicKeyOutput, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + return nil, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.CompressPublicKeyInput = CompressPublicKeyInput_ToDafny(params) + var dafny_response = client.DafnyClient.CompressPublicKey(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + return nil, Error_FromDafny(err) + } + var native_response = CompressPublicKeyOutput_FromDafny(dafny_response.Dtor_value().(AwsCryptographyPrimitivesTypes.CompressPublicKeyOutput)) + return &native_response, nil + +} + +func (client *Client) DecompressPublicKey(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.DecompressPublicKeyInput) (*awscryptographyprimitivessmithygeneratedtypes.DecompressPublicKeyOutput, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + return nil, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.DecompressPublicKeyInput = DecompressPublicKeyInput_ToDafny(params) + var dafny_response = client.DafnyClient.DecompressPublicKey(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + return nil, Error_FromDafny(err) + } + var native_response = DecompressPublicKeyOutput_FromDafny(dafny_response.Dtor_value().(AwsCryptographyPrimitivesTypes.DecompressPublicKeyOutput)) + return &native_response, nil + +} + +func (client *Client) ParsePublicKey(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.ParsePublicKeyInput) (*awscryptographyprimitivessmithygeneratedtypes.ParsePublicKeyOutput, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + return nil, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.ParsePublicKeyInput = ParsePublicKeyInput_ToDafny(params) + var dafny_response = client.DafnyClient.ParsePublicKey(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + return nil, Error_FromDafny(err) + } + var native_response = ParsePublicKeyOutput_FromDafny(dafny_response.Dtor_value().(AwsCryptographyPrimitivesTypes.ParsePublicKeyOutput)) + return &native_response, nil + +} diff --git a/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/awscryptographyprimitivessmithygenerated/to_dafny.go b/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/awscryptographyprimitivessmithygenerated/to_dafny.go new file mode 100644 index 000000000..6727ffcb6 --- /dev/null +++ b/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/awscryptographyprimitivessmithygenerated/to_dafny.go @@ -0,0 +1,1789 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package awscryptographyprimitivessmithygenerated + +import ( + "github.com/aws/aws-cryptographic-material-providers-library/primitives/AwsCryptographyPrimitivesTypes" + "github.com/aws/aws-cryptographic-material-providers-library/primitives/awscryptographyprimitivessmithygeneratedtypes" + "github.com/dafny-lang/DafnyRuntimeGo/v4/dafny" + "github.com/dafny-lang/DafnyStandardLibGo/Wrappers" +) + +func GenerateRandomBytesInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.GenerateRandomBytesInput) AwsCryptographyPrimitivesTypes.GenerateRandomBytesInput { + + return func() AwsCryptographyPrimitivesTypes.GenerateRandomBytesInput { + + return AwsCryptographyPrimitivesTypes.Companion_GenerateRandomBytesInput_.Create_GenerateRandomBytesInput_(aws_cryptography_primitives_GenerateRandomBytesInput_length_ToDafny(nativeInput.Length)) + }() + +} + +func DigestInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.DigestInput) AwsCryptographyPrimitivesTypes.DigestInput { + + return func() AwsCryptographyPrimitivesTypes.DigestInput { + + return AwsCryptographyPrimitivesTypes.Companion_DigestInput_.Create_DigestInput_(aws_cryptography_primitives_DigestInput_digestAlgorithm_ToDafny(nativeInput.DigestAlgorithm), aws_cryptography_primitives_DigestInput_message_ToDafny(nativeInput.Message)) + }() + +} + +func HMacInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.HMacInput) AwsCryptographyPrimitivesTypes.HMacInput { + + return func() AwsCryptographyPrimitivesTypes.HMacInput { + + return AwsCryptographyPrimitivesTypes.Companion_HMacInput_.Create_HMacInput_(aws_cryptography_primitives_HMacInput_digestAlgorithm_ToDafny(nativeInput.DigestAlgorithm), aws_cryptography_primitives_HMacInput_key_ToDafny(nativeInput.Key), aws_cryptography_primitives_HMacInput_message_ToDafny(nativeInput.Message)) + }() + +} + +func HkdfExtractInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.HkdfExtractInput) AwsCryptographyPrimitivesTypes.HkdfExtractInput { + + return func() AwsCryptographyPrimitivesTypes.HkdfExtractInput { + + return AwsCryptographyPrimitivesTypes.Companion_HkdfExtractInput_.Create_HkdfExtractInput_(aws_cryptography_primitives_HkdfExtractInput_digestAlgorithm_ToDafny(nativeInput.DigestAlgorithm), aws_cryptography_primitives_HkdfExtractInput_salt_ToDafny(nativeInput.Salt), aws_cryptography_primitives_HkdfExtractInput_ikm_ToDafny(nativeInput.Ikm)) + }() + +} + +func HkdfExpandInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.HkdfExpandInput) AwsCryptographyPrimitivesTypes.HkdfExpandInput { + + return func() AwsCryptographyPrimitivesTypes.HkdfExpandInput { + + return AwsCryptographyPrimitivesTypes.Companion_HkdfExpandInput_.Create_HkdfExpandInput_(aws_cryptography_primitives_HkdfExpandInput_digestAlgorithm_ToDafny(nativeInput.DigestAlgorithm), aws_cryptography_primitives_HkdfExpandInput_prk_ToDafny(nativeInput.Prk), aws_cryptography_primitives_HkdfExpandInput_info_ToDafny(nativeInput.Info), aws_cryptography_primitives_HkdfExpandInput_expectedLength_ToDafny(nativeInput.ExpectedLength)) + }() + +} + +func HkdfInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.HkdfInput) AwsCryptographyPrimitivesTypes.HkdfInput { + + return func() AwsCryptographyPrimitivesTypes.HkdfInput { + + return AwsCryptographyPrimitivesTypes.Companion_HkdfInput_.Create_HkdfInput_(aws_cryptography_primitives_HkdfInput_digestAlgorithm_ToDafny(nativeInput.DigestAlgorithm), aws_cryptography_primitives_HkdfInput_salt_ToDafny(nativeInput.Salt), aws_cryptography_primitives_HkdfInput_ikm_ToDafny(nativeInput.Ikm), aws_cryptography_primitives_HkdfInput_info_ToDafny(nativeInput.Info), aws_cryptography_primitives_HkdfInput_expectedLength_ToDafny(nativeInput.ExpectedLength)) + }() + +} + +func KdfCtrInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.KdfCtrInput) AwsCryptographyPrimitivesTypes.KdfCtrInput { + + return func() AwsCryptographyPrimitivesTypes.KdfCtrInput { + + return AwsCryptographyPrimitivesTypes.Companion_KdfCtrInput_.Create_KdfCtrInput_(aws_cryptography_primitives_KdfCtrInput_digestAlgorithm_ToDafny(nativeInput.DigestAlgorithm), aws_cryptography_primitives_KdfCtrInput_ikm_ToDafny(nativeInput.Ikm), aws_cryptography_primitives_KdfCtrInput_expectedLength_ToDafny(nativeInput.ExpectedLength), aws_cryptography_primitives_KdfCtrInput_purpose_ToDafny(nativeInput.Purpose), aws_cryptography_primitives_KdfCtrInput_nonce_ToDafny(nativeInput.Nonce)) + }() + +} + +func AesKdfCtrInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.AesKdfCtrInput) AwsCryptographyPrimitivesTypes.AesKdfCtrInput { + + return func() AwsCryptographyPrimitivesTypes.AesKdfCtrInput { + + return AwsCryptographyPrimitivesTypes.Companion_AesKdfCtrInput_.Create_AesKdfCtrInput_(aws_cryptography_primitives_AesKdfCtrInput_ikm_ToDafny(nativeInput.Ikm), aws_cryptography_primitives_AesKdfCtrInput_expectedLength_ToDafny(nativeInput.ExpectedLength), aws_cryptography_primitives_AesKdfCtrInput_nonce_ToDafny(nativeInput.Nonce)) + }() + +} + +func AESEncryptInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.AESEncryptInput) AwsCryptographyPrimitivesTypes.AESEncryptInput { + + return func() AwsCryptographyPrimitivesTypes.AESEncryptInput { + + return AwsCryptographyPrimitivesTypes.Companion_AESEncryptInput_.Create_AESEncryptInput_(aws_cryptography_primitives_AESEncryptInput_encAlg_ToDafny(nativeInput.EncAlg), aws_cryptography_primitives_AESEncryptInput_iv_ToDafny(nativeInput.Iv), aws_cryptography_primitives_AESEncryptInput_key_ToDafny(nativeInput.Key), aws_cryptography_primitives_AESEncryptInput_msg_ToDafny(nativeInput.Msg), aws_cryptography_primitives_AESEncryptInput_aad_ToDafny(nativeInput.Aad)) + }() + +} + +func AESEncryptOutput_ToDafny(nativeOutput awscryptographyprimitivessmithygeneratedtypes.AESEncryptOutput) AwsCryptographyPrimitivesTypes.AESEncryptOutput { + + return func() AwsCryptographyPrimitivesTypes.AESEncryptOutput { + + return AwsCryptographyPrimitivesTypes.Companion_AESEncryptOutput_.Create_AESEncryptOutput_(aws_cryptography_primitives_AESEncryptOutput_cipherText_ToDafny(nativeOutput.CipherText), aws_cryptography_primitives_AESEncryptOutput_authTag_ToDafny(nativeOutput.AuthTag)) + }() + +} + +func AESDecryptInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.AESDecryptInput) AwsCryptographyPrimitivesTypes.AESDecryptInput { + + return func() AwsCryptographyPrimitivesTypes.AESDecryptInput { + + return AwsCryptographyPrimitivesTypes.Companion_AESDecryptInput_.Create_AESDecryptInput_(aws_cryptography_primitives_AESDecryptInput_encAlg_ToDafny(nativeInput.EncAlg), aws_cryptography_primitives_AESDecryptInput_key_ToDafny(nativeInput.Key), aws_cryptography_primitives_AESDecryptInput_cipherTxt_ToDafny(nativeInput.CipherTxt), aws_cryptography_primitives_AESDecryptInput_authTag_ToDafny(nativeInput.AuthTag), aws_cryptography_primitives_AESDecryptInput_iv_ToDafny(nativeInput.Iv), aws_cryptography_primitives_AESDecryptInput_aad_ToDafny(nativeInput.Aad)) + }() + +} + +func GenerateRSAKeyPairInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.GenerateRSAKeyPairInput) AwsCryptographyPrimitivesTypes.GenerateRSAKeyPairInput { + + return func() AwsCryptographyPrimitivesTypes.GenerateRSAKeyPairInput { + + return AwsCryptographyPrimitivesTypes.Companion_GenerateRSAKeyPairInput_.Create_GenerateRSAKeyPairInput_(aws_cryptography_primitives_GenerateRSAKeyPairInput_lengthBits_ToDafny(nativeInput.LengthBits)) + }() + +} + +func GenerateRSAKeyPairOutput_ToDafny(nativeOutput awscryptographyprimitivessmithygeneratedtypes.GenerateRSAKeyPairOutput) AwsCryptographyPrimitivesTypes.GenerateRSAKeyPairOutput { + + return func() AwsCryptographyPrimitivesTypes.GenerateRSAKeyPairOutput { + + return AwsCryptographyPrimitivesTypes.Companion_GenerateRSAKeyPairOutput_.Create_GenerateRSAKeyPairOutput_(aws_cryptography_primitives_GenerateRSAKeyPairOutput_publicKey_ToDafny(nativeOutput.PublicKey), aws_cryptography_primitives_GenerateRSAKeyPairOutput_privateKey_ToDafny(nativeOutput.PrivateKey)) + }() + +} + +func GetRSAKeyModulusLengthInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.GetRSAKeyModulusLengthInput) AwsCryptographyPrimitivesTypes.GetRSAKeyModulusLengthInput { + + return func() AwsCryptographyPrimitivesTypes.GetRSAKeyModulusLengthInput { + + return AwsCryptographyPrimitivesTypes.Companion_GetRSAKeyModulusLengthInput_.Create_GetRSAKeyModulusLengthInput_(aws_cryptography_primitives_GetRSAKeyModulusLengthInput_publicKey_ToDafny(nativeInput.PublicKey)) + }() + +} + +func GetRSAKeyModulusLengthOutput_ToDafny(nativeOutput awscryptographyprimitivessmithygeneratedtypes.GetRSAKeyModulusLengthOutput) AwsCryptographyPrimitivesTypes.GetRSAKeyModulusLengthOutput { + + return func() AwsCryptographyPrimitivesTypes.GetRSAKeyModulusLengthOutput { + + return AwsCryptographyPrimitivesTypes.Companion_GetRSAKeyModulusLengthOutput_.Create_GetRSAKeyModulusLengthOutput_(aws_cryptography_primitives_GetRSAKeyModulusLengthOutput_length_ToDafny(nativeOutput.Length)) + }() + +} + +func RSADecryptInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.RSADecryptInput) AwsCryptographyPrimitivesTypes.RSADecryptInput { + + return func() AwsCryptographyPrimitivesTypes.RSADecryptInput { + + return AwsCryptographyPrimitivesTypes.Companion_RSADecryptInput_.Create_RSADecryptInput_(aws_cryptography_primitives_RSADecryptInput_padding_ToDafny(nativeInput.Padding), aws_cryptography_primitives_RSADecryptInput_privateKey_ToDafny(nativeInput.PrivateKey), aws_cryptography_primitives_RSADecryptInput_cipherText_ToDafny(nativeInput.CipherText)) + }() + +} + +func RSAEncryptInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.RSAEncryptInput) AwsCryptographyPrimitivesTypes.RSAEncryptInput { + + return func() AwsCryptographyPrimitivesTypes.RSAEncryptInput { + + return AwsCryptographyPrimitivesTypes.Companion_RSAEncryptInput_.Create_RSAEncryptInput_(aws_cryptography_primitives_RSAEncryptInput_padding_ToDafny(nativeInput.Padding), aws_cryptography_primitives_RSAEncryptInput_publicKey_ToDafny(nativeInput.PublicKey), aws_cryptography_primitives_RSAEncryptInput_plaintext_ToDafny(nativeInput.Plaintext)) + }() + +} + +func GenerateECDSASignatureKeyInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.GenerateECDSASignatureKeyInput) AwsCryptographyPrimitivesTypes.GenerateECDSASignatureKeyInput { + + return func() AwsCryptographyPrimitivesTypes.GenerateECDSASignatureKeyInput { + + return AwsCryptographyPrimitivesTypes.Companion_GenerateECDSASignatureKeyInput_.Create_GenerateECDSASignatureKeyInput_(aws_cryptography_primitives_GenerateECDSASignatureKeyInput_signatureAlgorithm_ToDafny(nativeInput.SignatureAlgorithm)) + }() + +} + +func GenerateECDSASignatureKeyOutput_ToDafny(nativeOutput awscryptographyprimitivessmithygeneratedtypes.GenerateECDSASignatureKeyOutput) AwsCryptographyPrimitivesTypes.GenerateECDSASignatureKeyOutput { + + return func() AwsCryptographyPrimitivesTypes.GenerateECDSASignatureKeyOutput { + + return AwsCryptographyPrimitivesTypes.Companion_GenerateECDSASignatureKeyOutput_.Create_GenerateECDSASignatureKeyOutput_(aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_signatureAlgorithm_ToDafny(nativeOutput.SignatureAlgorithm), aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_verificationKey_ToDafny(nativeOutput.VerificationKey), aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_signingKey_ToDafny(nativeOutput.SigningKey)) + }() + +} + +func ECDSASignInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.ECDSASignInput) AwsCryptographyPrimitivesTypes.ECDSASignInput { + + return func() AwsCryptographyPrimitivesTypes.ECDSASignInput { + + return AwsCryptographyPrimitivesTypes.Companion_ECDSASignInput_.Create_ECDSASignInput_(aws_cryptography_primitives_ECDSASignInput_signatureAlgorithm_ToDafny(nativeInput.SignatureAlgorithm), aws_cryptography_primitives_ECDSASignInput_signingKey_ToDafny(nativeInput.SigningKey), aws_cryptography_primitives_ECDSASignInput_message_ToDafny(nativeInput.Message)) + }() + +} + +func ECDSAVerifyInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.ECDSAVerifyInput) AwsCryptographyPrimitivesTypes.ECDSAVerifyInput { + + return func() AwsCryptographyPrimitivesTypes.ECDSAVerifyInput { + + return AwsCryptographyPrimitivesTypes.Companion_ECDSAVerifyInput_.Create_ECDSAVerifyInput_(aws_cryptography_primitives_ECDSAVerifyInput_signatureAlgorithm_ToDafny(nativeInput.SignatureAlgorithm), aws_cryptography_primitives_ECDSAVerifyInput_verificationKey_ToDafny(nativeInput.VerificationKey), aws_cryptography_primitives_ECDSAVerifyInput_message_ToDafny(nativeInput.Message), aws_cryptography_primitives_ECDSAVerifyInput_signature_ToDafny(nativeInput.Signature)) + }() + +} + +func GenerateECCKeyPairInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.GenerateECCKeyPairInput) AwsCryptographyPrimitivesTypes.GenerateECCKeyPairInput { + + return func() AwsCryptographyPrimitivesTypes.GenerateECCKeyPairInput { + + return AwsCryptographyPrimitivesTypes.Companion_GenerateECCKeyPairInput_.Create_GenerateECCKeyPairInput_(aws_cryptography_primitives_GenerateECCKeyPairInput_eccCurve_ToDafny(nativeInput.EccCurve)) + }() + +} + +func GenerateECCKeyPairOutput_ToDafny(nativeOutput awscryptographyprimitivessmithygeneratedtypes.GenerateECCKeyPairOutput) AwsCryptographyPrimitivesTypes.GenerateECCKeyPairOutput { + + return func() AwsCryptographyPrimitivesTypes.GenerateECCKeyPairOutput { + + return AwsCryptographyPrimitivesTypes.Companion_GenerateECCKeyPairOutput_.Create_GenerateECCKeyPairOutput_(aws_cryptography_primitives_GenerateECCKeyPairOutput_eccCurve_ToDafny(nativeOutput.EccCurve), aws_cryptography_primitives_GenerateECCKeyPairOutput_privateKey_ToDafny(nativeOutput.PrivateKey), aws_cryptography_primitives_GenerateECCKeyPairOutput_publicKey_ToDafny(nativeOutput.PublicKey)) + }() + +} + +func GetPublicKeyFromPrivateKeyInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.GetPublicKeyFromPrivateKeyInput) AwsCryptographyPrimitivesTypes.GetPublicKeyFromPrivateKeyInput { + + return func() AwsCryptographyPrimitivesTypes.GetPublicKeyFromPrivateKeyInput { + + return AwsCryptographyPrimitivesTypes.Companion_GetPublicKeyFromPrivateKeyInput_.Create_GetPublicKeyFromPrivateKeyInput_(aws_cryptography_primitives_GetPublicKeyFromPrivateKeyInput_eccCurve_ToDafny(nativeInput.EccCurve), aws_cryptography_primitives_GetPublicKeyFromPrivateKeyInput_privateKey_ToDafny(nativeInput.PrivateKey)) + }() + +} + +func GetPublicKeyFromPrivateKeyOutput_ToDafny(nativeOutput awscryptographyprimitivessmithygeneratedtypes.GetPublicKeyFromPrivateKeyOutput) AwsCryptographyPrimitivesTypes.GetPublicKeyFromPrivateKeyOutput { + + return func() AwsCryptographyPrimitivesTypes.GetPublicKeyFromPrivateKeyOutput { + + return AwsCryptographyPrimitivesTypes.Companion_GetPublicKeyFromPrivateKeyOutput_.Create_GetPublicKeyFromPrivateKeyOutput_(aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_eccCurve_ToDafny(nativeOutput.EccCurve), aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_privateKey_ToDafny(nativeOutput.PrivateKey), aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_publicKey_ToDafny(nativeOutput.PublicKey)) + }() + +} + +func ValidatePublicKeyInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.ValidatePublicKeyInput) AwsCryptographyPrimitivesTypes.ValidatePublicKeyInput { + + return func() AwsCryptographyPrimitivesTypes.ValidatePublicKeyInput { + + return AwsCryptographyPrimitivesTypes.Companion_ValidatePublicKeyInput_.Create_ValidatePublicKeyInput_(aws_cryptography_primitives_ValidatePublicKeyInput_eccCurve_ToDafny(nativeInput.EccCurve), aws_cryptography_primitives_ValidatePublicKeyInput_publicKey_ToDafny(nativeInput.PublicKey)) + }() + +} + +func ValidatePublicKeyOutput_ToDafny(nativeOutput awscryptographyprimitivessmithygeneratedtypes.ValidatePublicKeyOutput) AwsCryptographyPrimitivesTypes.ValidatePublicKeyOutput { + + return func() AwsCryptographyPrimitivesTypes.ValidatePublicKeyOutput { + + return AwsCryptographyPrimitivesTypes.Companion_ValidatePublicKeyOutput_.Create_ValidatePublicKeyOutput_(aws_cryptography_primitives_ValidatePublicKeyOutput_success_ToDafny(nativeOutput.Success)) + }() + +} + +func DeriveSharedSecretInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.DeriveSharedSecretInput) AwsCryptographyPrimitivesTypes.DeriveSharedSecretInput { + + return func() AwsCryptographyPrimitivesTypes.DeriveSharedSecretInput { + + return AwsCryptographyPrimitivesTypes.Companion_DeriveSharedSecretInput_.Create_DeriveSharedSecretInput_(aws_cryptography_primitives_DeriveSharedSecretInput_eccCurve_ToDafny(nativeInput.EccCurve), aws_cryptography_primitives_DeriveSharedSecretInput_privateKey_ToDafny(nativeInput.PrivateKey), aws_cryptography_primitives_DeriveSharedSecretInput_publicKey_ToDafny(nativeInput.PublicKey)) + }() + +} + +func DeriveSharedSecretOutput_ToDafny(nativeOutput awscryptographyprimitivessmithygeneratedtypes.DeriveSharedSecretOutput) AwsCryptographyPrimitivesTypes.DeriveSharedSecretOutput { + + return func() AwsCryptographyPrimitivesTypes.DeriveSharedSecretOutput { + + return AwsCryptographyPrimitivesTypes.Companion_DeriveSharedSecretOutput_.Create_DeriveSharedSecretOutput_(aws_cryptography_primitives_DeriveSharedSecretOutput_sharedSecret_ToDafny(nativeOutput.SharedSecret)) + }() + +} + +func CompressPublicKeyInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.CompressPublicKeyInput) AwsCryptographyPrimitivesTypes.CompressPublicKeyInput { + + return func() AwsCryptographyPrimitivesTypes.CompressPublicKeyInput { + + return AwsCryptographyPrimitivesTypes.Companion_CompressPublicKeyInput_.Create_CompressPublicKeyInput_(aws_cryptography_primitives_CompressPublicKeyInput_publicKey_ToDafny(nativeInput.PublicKey), aws_cryptography_primitives_CompressPublicKeyInput_eccCurve_ToDafny(nativeInput.EccCurve)) + }() + +} + +func CompressPublicKeyOutput_ToDafny(nativeOutput awscryptographyprimitivessmithygeneratedtypes.CompressPublicKeyOutput) AwsCryptographyPrimitivesTypes.CompressPublicKeyOutput { + + return func() AwsCryptographyPrimitivesTypes.CompressPublicKeyOutput { + + return AwsCryptographyPrimitivesTypes.Companion_CompressPublicKeyOutput_.Create_CompressPublicKeyOutput_(aws_cryptography_primitives_CompressPublicKeyOutput_compressedPublicKey_ToDafny(nativeOutput.CompressedPublicKey)) + }() + +} + +func DecompressPublicKeyInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.DecompressPublicKeyInput) AwsCryptographyPrimitivesTypes.DecompressPublicKeyInput { + + return func() AwsCryptographyPrimitivesTypes.DecompressPublicKeyInput { + + return AwsCryptographyPrimitivesTypes.Companion_DecompressPublicKeyInput_.Create_DecompressPublicKeyInput_(aws_cryptography_primitives_DecompressPublicKeyInput_compressedPublicKey_ToDafny(nativeInput.CompressedPublicKey), aws_cryptography_primitives_DecompressPublicKeyInput_eccCurve_ToDafny(nativeInput.EccCurve)) + }() + +} + +func DecompressPublicKeyOutput_ToDafny(nativeOutput awscryptographyprimitivessmithygeneratedtypes.DecompressPublicKeyOutput) AwsCryptographyPrimitivesTypes.DecompressPublicKeyOutput { + + return func() AwsCryptographyPrimitivesTypes.DecompressPublicKeyOutput { + + return AwsCryptographyPrimitivesTypes.Companion_DecompressPublicKeyOutput_.Create_DecompressPublicKeyOutput_(aws_cryptography_primitives_DecompressPublicKeyOutput_publicKey_ToDafny(nativeOutput.PublicKey)) + }() + +} + +func ParsePublicKeyInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.ParsePublicKeyInput) AwsCryptographyPrimitivesTypes.ParsePublicKeyInput { + + return func() AwsCryptographyPrimitivesTypes.ParsePublicKeyInput { + + return AwsCryptographyPrimitivesTypes.Companion_ParsePublicKeyInput_.Create_ParsePublicKeyInput_(aws_cryptography_primitives_ParsePublicKeyInput_publicKey_ToDafny(nativeInput.PublicKey)) + }() + +} + +func ParsePublicKeyOutput_ToDafny(nativeOutput awscryptographyprimitivessmithygeneratedtypes.ParsePublicKeyOutput) AwsCryptographyPrimitivesTypes.ParsePublicKeyOutput { + + return func() AwsCryptographyPrimitivesTypes.ParsePublicKeyOutput { + + return AwsCryptographyPrimitivesTypes.Companion_ParsePublicKeyOutput_.Create_ParsePublicKeyOutput_(aws_cryptography_primitives_ParsePublicKeyOutput_publicKey_ToDafny(nativeOutput.PublicKey)) + }() + +} + +func AwsCryptographicPrimitivesError_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.AwsCryptographicPrimitivesError) AwsCryptographyPrimitivesTypes.Error { + return func() AwsCryptographyPrimitivesTypes.Error { + + return AwsCryptographyPrimitivesTypes.Companion_Error_.Create_AwsCryptographicPrimitivesError_(aws_cryptography_primitives_AwsCryptographicPrimitivesError_message_ToDafny(nativeInput.Message)) + }() + +} + +func CollectionOfErrors_Input_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.CollectionOfErrors) AwsCryptographyPrimitivesTypes.Error { + var e []interface{} + for _, i2 := range nativeInput.ListOfErrors { + e = append(e, Error_ToDafny(i2)) + } + return AwsCryptographyPrimitivesTypes.Companion_Error_.Create_CollectionOfErrors_(dafny.SeqOf(e...), dafny.SeqOfChars([]dafny.Char(nativeInput.Message)...)) +} +func OpaqueError_Input_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.OpaqueError) AwsCryptographyPrimitivesTypes.Error { + return AwsCryptographyPrimitivesTypes.Companion_Error_.Create_Opaque_(nativeInput.ErrObject) +} + +func Error_ToDafny(err error) AwsCryptographyPrimitivesTypes.Error { + switch err.(type) { + // Service Errors + case awscryptographyprimitivessmithygeneratedtypes.AwsCryptographicPrimitivesError: + return AwsCryptographicPrimitivesError_ToDafny(err.(awscryptographyprimitivessmithygeneratedtypes.AwsCryptographicPrimitivesError)) + + //DependentErrors + + //Unmodelled Errors + case awscryptographyprimitivessmithygeneratedtypes.CollectionOfErrors: + return CollectionOfErrors_Input_ToDafny(err.(awscryptographyprimitivessmithygeneratedtypes.CollectionOfErrors)) + + default: + error, ok := err.(awscryptographyprimitivessmithygeneratedtypes.OpaqueError) + if !ok { + panic("Error is not an OpaqueError") + } + return OpaqueError_Input_ToDafny(error) + } +} + +func CryptoConfig_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.CryptoConfig) AwsCryptographyPrimitivesTypes.CryptoConfig { + return func() AwsCryptographyPrimitivesTypes.CryptoConfig { + + return AwsCryptographyPrimitivesTypes.Companion_CryptoConfig_.Create_CryptoConfig_() + }() + +} + +func Aws_cryptography_primitives_GenerateRandomBytesOutput_data_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_AESDecryptInput_key_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_ECDSAVerifyInput_message_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_DeriveSharedSecretInput_publicKey_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey) AwsCryptographyPrimitivesTypes.ECCPublicKey { + return func() AwsCryptographyPrimitivesTypes.ECCPublicKey { + + return AwsCryptographyPrimitivesTypes.Companion_ECCPublicKey_.Create_ECCPublicKey_(aws_cryptography_primitives_ECCPublicKey_der_ToDafny(input.Der)) + }() +} + +func aws_cryptography_primitives_ECDSAVerifyInput_signatureAlgorithm_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm) AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm { + return func() AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDSASignatureAlgorithm_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm) + }() +} + +func aws_cryptography_primitives_AESEncryptInput_iv_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_RSADecryptInput_privateKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_HkdfInput_expectedLength_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func Aws_cryptography_primitives_ECDSAVerifyOutput_success_ToDafny(input bool) bool { + return func() bool { + + return input + }() +} + +func Aws_cryptography_primitives_HkdfOutput_okm_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_HkdfExpandInput_expectedLength_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func aws_cryptography_primitives_GenerateECCKeyPairOutput_publicKey_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey) AwsCryptographyPrimitivesTypes.ECCPublicKey { + return func() AwsCryptographyPrimitivesTypes.ECCPublicKey { + + return AwsCryptographyPrimitivesTypes.Companion_ECCPublicKey_.Create_ECCPublicKey_(aws_cryptography_primitives_ECCPublicKey_der_ToDafny(input.Der)) + }() +} + +func aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_publicKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_HMacInput_digestAlgorithm_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm) AwsCryptographyPrimitivesTypes.DigestAlgorithm { + return func() AwsCryptographyPrimitivesTypes.DigestAlgorithm { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + }() +} + +func Aws_cryptography_primitives_AESDecryptOutput_plaintext_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_ValidatePublicKeyInput_publicKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_GenerateRandomBytesInput_length_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func aws_cryptography_primitives_AESDecryptInput_authTag_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_RSAEncryptInput_plaintext_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func Aws_cryptography_primitives_KdfCtrOutput_okm_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_KdfCtrInput_ikm_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_ParsePublicKeyOutput_publicKey_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey) AwsCryptographyPrimitivesTypes.ECCPublicKey { + return func() AwsCryptographyPrimitivesTypes.ECCPublicKey { + + return AwsCryptographyPrimitivesTypes.Companion_ECCPublicKey_.Create_ECCPublicKey_(aws_cryptography_primitives_ECCPublicKey_der_ToDafny(input.Der)) + }() +} + +func aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_eccCurve_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec) AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + return func() AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + }() +} + +func aws_cryptography_primitives_HkdfExtractInput_ikm_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_GetRSAKeyModulusLengthOutput_length_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func aws_cryptography_primitives_KdfCtrInput_purpose_ToDafny(input []byte) Wrappers.Option { + return func() Wrappers.Option { + var v []interface{} + if input == nil { + return Wrappers.Companion_Option_.Create_None_() + } + for _, e := range input { + v = append(v, e) + } + return Wrappers.Companion_Option_.Create_Some_(dafny.SeqOf(v...)) + }() +} + +func aws_cryptography_primitives_AesKdfCtrInput_expectedLength_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func aws_cryptography_primitives_RSAPublicKey_lengthBits_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_privateKey_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey) AwsCryptographyPrimitivesTypes.ECCPrivateKey { + return func() AwsCryptographyPrimitivesTypes.ECCPrivateKey { + + return AwsCryptographyPrimitivesTypes.Companion_ECCPrivateKey_.Create_ECCPrivateKey_(aws_cryptography_primitives_ECCPrivateKey_pem_ToDafny(input.Pem)) + }() +} + +func aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_signingKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_RSADecryptInput_cipherText_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_AESEncryptInput_aad_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_DecompressPublicKeyInput_eccCurve_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec) AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + return func() AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + }() +} + +func Aws_cryptography_primitives_ECDSASignOutput_signature_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_ValidatePublicKeyInput_eccCurve_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec) AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + return func() AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + }() +} + +func aws_cryptography_primitives_DeriveSharedSecretInput_eccCurve_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec) AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + return func() AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + }() +} + +func aws_cryptography_primitives_AES_GCM_ivLength_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func aws_cryptography_primitives_HkdfInput_info_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_HkdfExpandInput_info_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_HMacInput_key_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func Aws_cryptography_primitives_DigestOutput_digest_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_AESEncryptOutput_cipherText_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_AESEncryptInput_key_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_RSAPrivateKey_lengthBits_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func aws_cryptography_primitives_GenerateRSAKeyPairInput_lengthBits_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func aws_cryptography_primitives_DigestInput_message_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_RSAPublicKey_pem_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_ParsePublicKeyInput_publicKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_HkdfExpandInput_prk_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_GetRSAKeyModulusLengthInput_publicKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_GenerateRSAKeyPairOutput_publicKey_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.RSAPublicKey) AwsCryptographyPrimitivesTypes.RSAPublicKey { + return func() AwsCryptographyPrimitivesTypes.RSAPublicKey { + + return AwsCryptographyPrimitivesTypes.Companion_RSAPublicKey_.Create_RSAPublicKey_(aws_cryptography_primitives_RSAPublicKey_lengthBits_ToDafny(input.LengthBits), aws_cryptography_primitives_RSAPublicKey_pem_ToDafny(input.Pem)) + }() +} + +func aws_cryptography_primitives_AESEncryptInput_msg_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_DecompressPublicKeyInput_compressedPublicKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_RSAEncryptInput_publicKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_RSAPrivateKey_pem_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_GenerateRSAKeyPairOutput_privateKey_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.RSAPrivateKey) AwsCryptographyPrimitivesTypes.RSAPrivateKey { + return func() AwsCryptographyPrimitivesTypes.RSAPrivateKey { + + return AwsCryptographyPrimitivesTypes.Companion_RSAPrivateKey_.Create_RSAPrivateKey_(aws_cryptography_primitives_RSAPrivateKey_lengthBits_ToDafny(input.LengthBits), aws_cryptography_primitives_RSAPrivateKey_pem_ToDafny(input.Pem)) + }() +} + +func aws_cryptography_primitives_AESEncryptOutput_authTag_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_ECDSASignInput_signingKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_ECDSAVerifyInput_verificationKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_AesKdfCtrInput_nonce_ToDafny(input []byte) Wrappers.Option { + return func() Wrappers.Option { + var v []interface{} + if input == nil { + return Wrappers.Companion_Option_.Create_None_() + } + for _, e := range input { + v = append(v, e) + } + return Wrappers.Companion_Option_.Create_Some_(dafny.SeqOf(v...)) + }() +} + +func aws_cryptography_primitives_HMacInput_message_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_CompressPublicKeyInput_publicKey_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey) AwsCryptographyPrimitivesTypes.ECCPublicKey { + return func() AwsCryptographyPrimitivesTypes.ECCPublicKey { + + return AwsCryptographyPrimitivesTypes.Companion_ECCPublicKey_.Create_ECCPublicKey_(aws_cryptography_primitives_ECCPublicKey_der_ToDafny(input.Der)) + }() +} + +func aws_cryptography_primitives_DigestInput_digestAlgorithm_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm) AwsCryptographyPrimitivesTypes.DigestAlgorithm { + return func() AwsCryptographyPrimitivesTypes.DigestAlgorithm { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + }() +} + +func aws_cryptography_primitives_AES_GCM_tagLength_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func aws_cryptography_primitives_ValidatePublicKeyOutput_success_ToDafny(input bool) bool { + return func() bool { + + return input + }() +} + +func aws_cryptography_primitives_ECDSASignInput_signatureAlgorithm_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm) AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm { + return func() AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDSASignatureAlgorithm_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm) + }() +} + +func aws_cryptography_primitives_RSADecryptInput_padding_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.RSAPaddingMode) AwsCryptographyPrimitivesTypes.RSAPaddingMode { + return func() AwsCryptographyPrimitivesTypes.RSAPaddingMode { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_RSAPaddingMode_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.RSAPaddingMode) + }() +} + +func Aws_cryptography_primitives_HkdfExtractOutput_prk_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func Aws_cryptography_primitives_RSADecryptOutput_plaintext_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_GetPublicKeyFromPrivateKeyInput_privateKey_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey) AwsCryptographyPrimitivesTypes.ECCPrivateKey { + return func() AwsCryptographyPrimitivesTypes.ECCPrivateKey { + + return AwsCryptographyPrimitivesTypes.Companion_ECCPrivateKey_.Create_ECCPrivateKey_(aws_cryptography_primitives_ECCPrivateKey_pem_ToDafny(input.Pem)) + }() +} + +func aws_cryptography_primitives_ECDSAVerifyInput_signature_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_AESDecryptInput_encAlg_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.AES_GCM) AwsCryptographyPrimitivesTypes.AES__GCM { + return func() AwsCryptographyPrimitivesTypes.AES__GCM { + + return AwsCryptographyPrimitivesTypes.Companion_AES__GCM_.Create_AES__GCM_(aws_cryptography_primitives_AES_GCM_keyLength_ToDafny(input.KeyLength), aws_cryptography_primitives_AES_GCM_tagLength_ToDafny(input.TagLength), aws_cryptography_primitives_AES_GCM_ivLength_ToDafny(input.IvLength)) + }() +} + +func aws_cryptography_primitives_HkdfExpandInput_digestAlgorithm_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm) AwsCryptographyPrimitivesTypes.DigestAlgorithm { + return func() AwsCryptographyPrimitivesTypes.DigestAlgorithm { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + }() +} + +func Aws_cryptography_primitives_HkdfExpandOutput_okm_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_GetPublicKeyFromPrivateKeyInput_eccCurve_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec) AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + return func() AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + }() +} + +func aws_cryptography_primitives_RSAEncryptInput_padding_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.RSAPaddingMode) AwsCryptographyPrimitivesTypes.RSAPaddingMode { + return func() AwsCryptographyPrimitivesTypes.RSAPaddingMode { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_RSAPaddingMode_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.RSAPaddingMode) + }() +} + +func aws_cryptography_primitives_DeriveSharedSecretInput_privateKey_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey) AwsCryptographyPrimitivesTypes.ECCPrivateKey { + return func() AwsCryptographyPrimitivesTypes.ECCPrivateKey { + + return AwsCryptographyPrimitivesTypes.Companion_ECCPrivateKey_.Create_ECCPrivateKey_(aws_cryptography_primitives_ECCPrivateKey_pem_ToDafny(input.Pem)) + }() +} + +func aws_cryptography_primitives_ECCPublicKey_der_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_HkdfInput_ikm_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_GenerateECDSASignatureKeyInput_signatureAlgorithm_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm) AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm { + return func() AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDSASignatureAlgorithm_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm) + }() +} + +func aws_cryptography_primitives_AESDecryptInput_cipherTxt_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_KdfCtrInput_digestAlgorithm_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm) AwsCryptographyPrimitivesTypes.DigestAlgorithm { + return func() AwsCryptographyPrimitivesTypes.DigestAlgorithm { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + }() +} + +func aws_cryptography_primitives_HkdfExtractInput_salt_ToDafny(input []byte) Wrappers.Option { + return func() Wrappers.Option { + var v []interface{} + if input == nil { + return Wrappers.Companion_Option_.Create_None_() + } + for _, e := range input { + v = append(v, e) + } + return Wrappers.Companion_Option_.Create_Some_(dafny.SeqOf(v...)) + }() +} + +func Aws_cryptography_primitives_HMacOutput_digest_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_KdfCtrInput_nonce_ToDafny(input []byte) Wrappers.Option { + return func() Wrappers.Option { + var v []interface{} + if input == nil { + return Wrappers.Companion_Option_.Create_None_() + } + for _, e := range input { + v = append(v, e) + } + return Wrappers.Companion_Option_.Create_Some_(dafny.SeqOf(v...)) + }() +} + +func aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_signatureAlgorithm_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm) AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm { + return func() AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDSASignatureAlgorithm_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm) + }() +} + +func aws_cryptography_primitives_CompressPublicKeyInput_eccCurve_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec) AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + return func() AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + }() +} + +func aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_verificationKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_DecompressPublicKeyOutput_publicKey_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey) AwsCryptographyPrimitivesTypes.ECCPublicKey { + return func() AwsCryptographyPrimitivesTypes.ECCPublicKey { + + return AwsCryptographyPrimitivesTypes.Companion_ECCPublicKey_.Create_ECCPublicKey_(aws_cryptography_primitives_ECCPublicKey_der_ToDafny(input.Der)) + }() +} + +func aws_cryptography_primitives_HkdfExtractInput_digestAlgorithm_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm) AwsCryptographyPrimitivesTypes.DigestAlgorithm { + return func() AwsCryptographyPrimitivesTypes.DigestAlgorithm { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + }() +} + +func Aws_cryptography_primitives_RSAEncryptOutput_cipherText_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_GenerateECCKeyPairOutput_eccCurve_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec) AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + return func() AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + }() +} + +func aws_cryptography_primitives_HkdfInput_salt_ToDafny(input []byte) Wrappers.Option { + return func() Wrappers.Option { + var v []interface{} + if input == nil { + return Wrappers.Companion_Option_.Create_None_() + } + for _, e := range input { + v = append(v, e) + } + return Wrappers.Companion_Option_.Create_Some_(dafny.SeqOf(v...)) + }() +} + +func aws_cryptography_primitives_ECCPrivateKey_pem_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_AESDecryptInput_aad_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_AwsCryptographicPrimitivesError_message_ToDafny(input string) dafny.Sequence { + return func() dafny.Sequence { + + return dafny.SeqOfChars([]dafny.Char(input)...) + }() +} + +func aws_cryptography_primitives_AES_GCM_keyLength_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func aws_cryptography_primitives_HkdfInput_digestAlgorithm_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm) AwsCryptographyPrimitivesTypes.DigestAlgorithm { + return func() AwsCryptographyPrimitivesTypes.DigestAlgorithm { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + }() +} + +func aws_cryptography_primitives_AesKdfCtrInput_ikm_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_GenerateECCKeyPairInput_eccCurve_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec) AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + return func() AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + }() +} + +func aws_cryptography_primitives_AESEncryptInput_encAlg_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.AES_GCM) AwsCryptographyPrimitivesTypes.AES__GCM { + return func() AwsCryptographyPrimitivesTypes.AES__GCM { + + return AwsCryptographyPrimitivesTypes.Companion_AES__GCM_.Create_AES__GCM_(aws_cryptography_primitives_AES_GCM_keyLength_ToDafny(input.KeyLength), aws_cryptography_primitives_AES_GCM_tagLength_ToDafny(input.TagLength), aws_cryptography_primitives_AES_GCM_ivLength_ToDafny(input.IvLength)) + }() +} + +func aws_cryptography_primitives_CompressPublicKeyOutput_compressedPublicKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_AESDecryptInput_iv_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_KdfCtrInput_expectedLength_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func aws_cryptography_primitives_ECDSASignInput_message_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_DeriveSharedSecretOutput_sharedSecret_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func Aws_cryptography_primitives_AesKdfCtrOutput_okm_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_GenerateECCKeyPairOutput_privateKey_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey) AwsCryptographyPrimitivesTypes.ECCPrivateKey { + return func() AwsCryptographyPrimitivesTypes.ECCPrivateKey { + + return AwsCryptographyPrimitivesTypes.Companion_ECCPrivateKey_.Create_ECCPrivateKey_(aws_cryptography_primitives_ECCPrivateKey_pem_ToDafny(input.Pem)) + }() +} diff --git a/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/awscryptographyprimitivessmithygenerated/to_native.go b/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/awscryptographyprimitivessmithygenerated/to_native.go new file mode 100644 index 000000000..b33c76b63 --- /dev/null +++ b/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/awscryptographyprimitivessmithygenerated/to_native.go @@ -0,0 +1,1811 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package awscryptographyprimitivessmithygenerated + +import ( + "github.com/aws/aws-cryptographic-material-providers-library/primitives/AwsCryptographyPrimitivesTypes" + "github.com/aws/aws-cryptographic-material-providers-library/primitives/awscryptographyprimitivessmithygeneratedtypes" + "github.com/dafny-lang/DafnyRuntimeGo/v4/dafny" +) + +func GenerateRandomBytesInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.GenerateRandomBytesInput) awscryptographyprimitivessmithygeneratedtypes.GenerateRandomBytesInput { + + return awscryptographyprimitivessmithygeneratedtypes.GenerateRandomBytesInput{Length: aws_cryptography_primitives_GenerateRandomBytesInput_length_FromDafny(dafnyInput.Dtor_length())} + +} + +func DigestInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.DigestInput) awscryptographyprimitivessmithygeneratedtypes.DigestInput { + + return awscryptographyprimitivessmithygeneratedtypes.DigestInput{DigestAlgorithm: aws_cryptography_primitives_DigestInput_digestAlgorithm_FromDafny(dafnyInput.Dtor_digestAlgorithm()), + Message: aws_cryptography_primitives_DigestInput_message_FromDafny(dafnyInput.Dtor_message()), + } + +} + +func HMacInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.HMacInput) awscryptographyprimitivessmithygeneratedtypes.HMacInput { + + return awscryptographyprimitivessmithygeneratedtypes.HMacInput{DigestAlgorithm: aws_cryptography_primitives_HMacInput_digestAlgorithm_FromDafny(dafnyInput.Dtor_digestAlgorithm()), + Key: aws_cryptography_primitives_HMacInput_key_FromDafny(dafnyInput.Dtor_key()), + Message: aws_cryptography_primitives_HMacInput_message_FromDafny(dafnyInput.Dtor_message()), + } + +} + +func HkdfExtractInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.HkdfExtractInput) awscryptographyprimitivessmithygeneratedtypes.HkdfExtractInput { + + return awscryptographyprimitivessmithygeneratedtypes.HkdfExtractInput{DigestAlgorithm: aws_cryptography_primitives_HkdfExtractInput_digestAlgorithm_FromDafny(dafnyInput.Dtor_digestAlgorithm()), + Salt: aws_cryptography_primitives_HkdfExtractInput_salt_FromDafny(dafnyInput.Dtor_salt().UnwrapOr(nil)), + Ikm: aws_cryptography_primitives_HkdfExtractInput_ikm_FromDafny(dafnyInput.Dtor_ikm()), + } + +} + +func HkdfExpandInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.HkdfExpandInput) awscryptographyprimitivessmithygeneratedtypes.HkdfExpandInput { + + return awscryptographyprimitivessmithygeneratedtypes.HkdfExpandInput{DigestAlgorithm: aws_cryptography_primitives_HkdfExpandInput_digestAlgorithm_FromDafny(dafnyInput.Dtor_digestAlgorithm()), + Prk: aws_cryptography_primitives_HkdfExpandInput_prk_FromDafny(dafnyInput.Dtor_prk()), + Info: aws_cryptography_primitives_HkdfExpandInput_info_FromDafny(dafnyInput.Dtor_info()), + ExpectedLength: aws_cryptography_primitives_HkdfExpandInput_expectedLength_FromDafny(dafnyInput.Dtor_expectedLength()), + } + +} + +func HkdfInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.HkdfInput) awscryptographyprimitivessmithygeneratedtypes.HkdfInput { + + return awscryptographyprimitivessmithygeneratedtypes.HkdfInput{DigestAlgorithm: aws_cryptography_primitives_HkdfInput_digestAlgorithm_FromDafny(dafnyInput.Dtor_digestAlgorithm()), + Salt: aws_cryptography_primitives_HkdfInput_salt_FromDafny(dafnyInput.Dtor_salt().UnwrapOr(nil)), + Ikm: aws_cryptography_primitives_HkdfInput_ikm_FromDafny(dafnyInput.Dtor_ikm()), + Info: aws_cryptography_primitives_HkdfInput_info_FromDafny(dafnyInput.Dtor_info()), + ExpectedLength: aws_cryptography_primitives_HkdfInput_expectedLength_FromDafny(dafnyInput.Dtor_expectedLength()), + } + +} + +func KdfCtrInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.KdfCtrInput) awscryptographyprimitivessmithygeneratedtypes.KdfCtrInput { + + return awscryptographyprimitivessmithygeneratedtypes.KdfCtrInput{DigestAlgorithm: aws_cryptography_primitives_KdfCtrInput_digestAlgorithm_FromDafny(dafnyInput.Dtor_digestAlgorithm()), + Ikm: aws_cryptography_primitives_KdfCtrInput_ikm_FromDafny(dafnyInput.Dtor_ikm()), + ExpectedLength: aws_cryptography_primitives_KdfCtrInput_expectedLength_FromDafny(dafnyInput.Dtor_expectedLength()), + Purpose: aws_cryptography_primitives_KdfCtrInput_purpose_FromDafny(dafnyInput.Dtor_purpose().UnwrapOr(nil)), + Nonce: aws_cryptography_primitives_KdfCtrInput_nonce_FromDafny(dafnyInput.Dtor_nonce().UnwrapOr(nil)), + } + +} + +func AesKdfCtrInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.AesKdfCtrInput) awscryptographyprimitivessmithygeneratedtypes.AesKdfCtrInput { + + return awscryptographyprimitivessmithygeneratedtypes.AesKdfCtrInput{Ikm: aws_cryptography_primitives_AesKdfCtrInput_ikm_FromDafny(dafnyInput.Dtor_ikm()), + ExpectedLength: aws_cryptography_primitives_AesKdfCtrInput_expectedLength_FromDafny(dafnyInput.Dtor_expectedLength()), + Nonce: aws_cryptography_primitives_AesKdfCtrInput_nonce_FromDafny(dafnyInput.Dtor_nonce().UnwrapOr(nil)), + } + +} + +func AESEncryptInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.AESEncryptInput) awscryptographyprimitivessmithygeneratedtypes.AESEncryptInput { + + return awscryptographyprimitivessmithygeneratedtypes.AESEncryptInput{EncAlg: aws_cryptography_primitives_AESEncryptInput_encAlg_FromDafny(dafnyInput.Dtor_encAlg()), + Iv: aws_cryptography_primitives_AESEncryptInput_iv_FromDafny(dafnyInput.Dtor_iv()), + Key: aws_cryptography_primitives_AESEncryptInput_key_FromDafny(dafnyInput.Dtor_key()), + Msg: aws_cryptography_primitives_AESEncryptInput_msg_FromDafny(dafnyInput.Dtor_msg()), + Aad: aws_cryptography_primitives_AESEncryptInput_aad_FromDafny(dafnyInput.Dtor_aad()), + } + +} + +func AESEncryptOutput_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.AESEncryptOutput) awscryptographyprimitivessmithygeneratedtypes.AESEncryptOutput { + + return awscryptographyprimitivessmithygeneratedtypes.AESEncryptOutput{CipherText: aws_cryptography_primitives_AESEncryptOutput_cipherText_FromDafny(dafnyOutput.Dtor_cipherText()), + AuthTag: aws_cryptography_primitives_AESEncryptOutput_authTag_FromDafny(dafnyOutput.Dtor_authTag()), + } + +} + +func AESDecryptInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.AESDecryptInput) awscryptographyprimitivessmithygeneratedtypes.AESDecryptInput { + + return awscryptographyprimitivessmithygeneratedtypes.AESDecryptInput{EncAlg: aws_cryptography_primitives_AESDecryptInput_encAlg_FromDafny(dafnyInput.Dtor_encAlg()), + Key: aws_cryptography_primitives_AESDecryptInput_key_FromDafny(dafnyInput.Dtor_key()), + CipherTxt: aws_cryptography_primitives_AESDecryptInput_cipherTxt_FromDafny(dafnyInput.Dtor_cipherTxt()), + AuthTag: aws_cryptography_primitives_AESDecryptInput_authTag_FromDafny(dafnyInput.Dtor_authTag()), + Iv: aws_cryptography_primitives_AESDecryptInput_iv_FromDafny(dafnyInput.Dtor_iv()), + Aad: aws_cryptography_primitives_AESDecryptInput_aad_FromDafny(dafnyInput.Dtor_aad()), + } + +} + +func GenerateRSAKeyPairInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.GenerateRSAKeyPairInput) awscryptographyprimitivessmithygeneratedtypes.GenerateRSAKeyPairInput { + + return awscryptographyprimitivessmithygeneratedtypes.GenerateRSAKeyPairInput{LengthBits: aws_cryptography_primitives_GenerateRSAKeyPairInput_lengthBits_FromDafny(dafnyInput.Dtor_lengthBits())} + +} + +func GenerateRSAKeyPairOutput_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.GenerateRSAKeyPairOutput) awscryptographyprimitivessmithygeneratedtypes.GenerateRSAKeyPairOutput { + + return awscryptographyprimitivessmithygeneratedtypes.GenerateRSAKeyPairOutput{PublicKey: aws_cryptography_primitives_GenerateRSAKeyPairOutput_publicKey_FromDafny(dafnyOutput.Dtor_publicKey()), + PrivateKey: aws_cryptography_primitives_GenerateRSAKeyPairOutput_privateKey_FromDafny(dafnyOutput.Dtor_privateKey()), + } + +} + +func GetRSAKeyModulusLengthInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.GetRSAKeyModulusLengthInput) awscryptographyprimitivessmithygeneratedtypes.GetRSAKeyModulusLengthInput { + + return awscryptographyprimitivessmithygeneratedtypes.GetRSAKeyModulusLengthInput{PublicKey: aws_cryptography_primitives_GetRSAKeyModulusLengthInput_publicKey_FromDafny(dafnyInput.Dtor_publicKey())} + +} + +func GetRSAKeyModulusLengthOutput_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.GetRSAKeyModulusLengthOutput) awscryptographyprimitivessmithygeneratedtypes.GetRSAKeyModulusLengthOutput { + + return awscryptographyprimitivessmithygeneratedtypes.GetRSAKeyModulusLengthOutput{Length: aws_cryptography_primitives_GetRSAKeyModulusLengthOutput_length_FromDafny(dafnyOutput.Dtor_length())} + +} + +func RSADecryptInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.RSADecryptInput) awscryptographyprimitivessmithygeneratedtypes.RSADecryptInput { + + return awscryptographyprimitivessmithygeneratedtypes.RSADecryptInput{Padding: aws_cryptography_primitives_RSADecryptInput_padding_FromDafny(dafnyInput.Dtor_padding()), + PrivateKey: aws_cryptography_primitives_RSADecryptInput_privateKey_FromDafny(dafnyInput.Dtor_privateKey()), + CipherText: aws_cryptography_primitives_RSADecryptInput_cipherText_FromDafny(dafnyInput.Dtor_cipherText()), + } + +} + +func RSAEncryptInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.RSAEncryptInput) awscryptographyprimitivessmithygeneratedtypes.RSAEncryptInput { + + return awscryptographyprimitivessmithygeneratedtypes.RSAEncryptInput{Padding: aws_cryptography_primitives_RSAEncryptInput_padding_FromDafny(dafnyInput.Dtor_padding()), + PublicKey: aws_cryptography_primitives_RSAEncryptInput_publicKey_FromDafny(dafnyInput.Dtor_publicKey()), + Plaintext: aws_cryptography_primitives_RSAEncryptInput_plaintext_FromDafny(dafnyInput.Dtor_plaintext()), + } + +} + +func GenerateECDSASignatureKeyInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.GenerateECDSASignatureKeyInput) awscryptographyprimitivessmithygeneratedtypes.GenerateECDSASignatureKeyInput { + + return awscryptographyprimitivessmithygeneratedtypes.GenerateECDSASignatureKeyInput{SignatureAlgorithm: aws_cryptography_primitives_GenerateECDSASignatureKeyInput_signatureAlgorithm_FromDafny(dafnyInput.Dtor_signatureAlgorithm())} + +} + +func GenerateECDSASignatureKeyOutput_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.GenerateECDSASignatureKeyOutput) awscryptographyprimitivessmithygeneratedtypes.GenerateECDSASignatureKeyOutput { + + return awscryptographyprimitivessmithygeneratedtypes.GenerateECDSASignatureKeyOutput{SignatureAlgorithm: aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_signatureAlgorithm_FromDafny(dafnyOutput.Dtor_signatureAlgorithm()), + VerificationKey: aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_verificationKey_FromDafny(dafnyOutput.Dtor_verificationKey()), + SigningKey: aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_signingKey_FromDafny(dafnyOutput.Dtor_signingKey()), + } + +} + +func ECDSASignInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.ECDSASignInput) awscryptographyprimitivessmithygeneratedtypes.ECDSASignInput { + + return awscryptographyprimitivessmithygeneratedtypes.ECDSASignInput{SignatureAlgorithm: aws_cryptography_primitives_ECDSASignInput_signatureAlgorithm_FromDafny(dafnyInput.Dtor_signatureAlgorithm()), + SigningKey: aws_cryptography_primitives_ECDSASignInput_signingKey_FromDafny(dafnyInput.Dtor_signingKey()), + Message: aws_cryptography_primitives_ECDSASignInput_message_FromDafny(dafnyInput.Dtor_message()), + } + +} + +func ECDSAVerifyInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.ECDSAVerifyInput) awscryptographyprimitivessmithygeneratedtypes.ECDSAVerifyInput { + + return awscryptographyprimitivessmithygeneratedtypes.ECDSAVerifyInput{SignatureAlgorithm: aws_cryptography_primitives_ECDSAVerifyInput_signatureAlgorithm_FromDafny(dafnyInput.Dtor_signatureAlgorithm()), + VerificationKey: aws_cryptography_primitives_ECDSAVerifyInput_verificationKey_FromDafny(dafnyInput.Dtor_verificationKey()), + Message: aws_cryptography_primitives_ECDSAVerifyInput_message_FromDafny(dafnyInput.Dtor_message()), + Signature: aws_cryptography_primitives_ECDSAVerifyInput_signature_FromDafny(dafnyInput.Dtor_signature()), + } + +} + +func GenerateECCKeyPairInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.GenerateECCKeyPairInput) awscryptographyprimitivessmithygeneratedtypes.GenerateECCKeyPairInput { + + return awscryptographyprimitivessmithygeneratedtypes.GenerateECCKeyPairInput{EccCurve: aws_cryptography_primitives_GenerateECCKeyPairInput_eccCurve_FromDafny(dafnyInput.Dtor_eccCurve())} + +} + +func GenerateECCKeyPairOutput_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.GenerateECCKeyPairOutput) awscryptographyprimitivessmithygeneratedtypes.GenerateECCKeyPairOutput { + + return awscryptographyprimitivessmithygeneratedtypes.GenerateECCKeyPairOutput{EccCurve: aws_cryptography_primitives_GenerateECCKeyPairOutput_eccCurve_FromDafny(dafnyOutput.Dtor_eccCurve()), + PrivateKey: aws_cryptography_primitives_GenerateECCKeyPairOutput_privateKey_FromDafny(dafnyOutput.Dtor_privateKey()), + PublicKey: aws_cryptography_primitives_GenerateECCKeyPairOutput_publicKey_FromDafny(dafnyOutput.Dtor_publicKey()), + } + +} + +func GetPublicKeyFromPrivateKeyInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.GetPublicKeyFromPrivateKeyInput) awscryptographyprimitivessmithygeneratedtypes.GetPublicKeyFromPrivateKeyInput { + + return awscryptographyprimitivessmithygeneratedtypes.GetPublicKeyFromPrivateKeyInput{EccCurve: aws_cryptography_primitives_GetPublicKeyFromPrivateKeyInput_eccCurve_FromDafny(dafnyInput.Dtor_eccCurve()), + PrivateKey: aws_cryptography_primitives_GetPublicKeyFromPrivateKeyInput_privateKey_FromDafny(dafnyInput.Dtor_privateKey()), + } + +} + +func GetPublicKeyFromPrivateKeyOutput_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.GetPublicKeyFromPrivateKeyOutput) awscryptographyprimitivessmithygeneratedtypes.GetPublicKeyFromPrivateKeyOutput { + + return awscryptographyprimitivessmithygeneratedtypes.GetPublicKeyFromPrivateKeyOutput{EccCurve: aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_eccCurve_FromDafny(dafnyOutput.Dtor_eccCurve()), + PrivateKey: aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_privateKey_FromDafny(dafnyOutput.Dtor_privateKey()), + PublicKey: aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_publicKey_FromDafny(dafnyOutput.Dtor_publicKey()), + } + +} + +func ValidatePublicKeyInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.ValidatePublicKeyInput) awscryptographyprimitivessmithygeneratedtypes.ValidatePublicKeyInput { + + return awscryptographyprimitivessmithygeneratedtypes.ValidatePublicKeyInput{EccCurve: aws_cryptography_primitives_ValidatePublicKeyInput_eccCurve_FromDafny(dafnyInput.Dtor_eccCurve()), + PublicKey: aws_cryptography_primitives_ValidatePublicKeyInput_publicKey_FromDafny(dafnyInput.Dtor_publicKey()), + } + +} + +func ValidatePublicKeyOutput_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.ValidatePublicKeyOutput) awscryptographyprimitivessmithygeneratedtypes.ValidatePublicKeyOutput { + + return awscryptographyprimitivessmithygeneratedtypes.ValidatePublicKeyOutput{Success: aws_cryptography_primitives_ValidatePublicKeyOutput_success_FromDafny(dafnyOutput.Dtor_success())} + +} + +func DeriveSharedSecretInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.DeriveSharedSecretInput) awscryptographyprimitivessmithygeneratedtypes.DeriveSharedSecretInput { + + return awscryptographyprimitivessmithygeneratedtypes.DeriveSharedSecretInput{EccCurve: aws_cryptography_primitives_DeriveSharedSecretInput_eccCurve_FromDafny(dafnyInput.Dtor_eccCurve()), + PrivateKey: aws_cryptography_primitives_DeriveSharedSecretInput_privateKey_FromDafny(dafnyInput.Dtor_privateKey()), + PublicKey: aws_cryptography_primitives_DeriveSharedSecretInput_publicKey_FromDafny(dafnyInput.Dtor_publicKey()), + } + +} + +func DeriveSharedSecretOutput_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.DeriveSharedSecretOutput) awscryptographyprimitivessmithygeneratedtypes.DeriveSharedSecretOutput { + + return awscryptographyprimitivessmithygeneratedtypes.DeriveSharedSecretOutput{SharedSecret: aws_cryptography_primitives_DeriveSharedSecretOutput_sharedSecret_FromDafny(dafnyOutput.Dtor_sharedSecret())} + +} + +func CompressPublicKeyInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.CompressPublicKeyInput) awscryptographyprimitivessmithygeneratedtypes.CompressPublicKeyInput { + + return awscryptographyprimitivessmithygeneratedtypes.CompressPublicKeyInput{PublicKey: aws_cryptography_primitives_CompressPublicKeyInput_publicKey_FromDafny(dafnyInput.Dtor_publicKey()), + EccCurve: aws_cryptography_primitives_CompressPublicKeyInput_eccCurve_FromDafny(dafnyInput.Dtor_eccCurve()), + } + +} + +func CompressPublicKeyOutput_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.CompressPublicKeyOutput) awscryptographyprimitivessmithygeneratedtypes.CompressPublicKeyOutput { + + return awscryptographyprimitivessmithygeneratedtypes.CompressPublicKeyOutput{CompressedPublicKey: aws_cryptography_primitives_CompressPublicKeyOutput_compressedPublicKey_FromDafny(dafnyOutput.Dtor_compressedPublicKey())} + +} + +func DecompressPublicKeyInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.DecompressPublicKeyInput) awscryptographyprimitivessmithygeneratedtypes.DecompressPublicKeyInput { + + return awscryptographyprimitivessmithygeneratedtypes.DecompressPublicKeyInput{CompressedPublicKey: aws_cryptography_primitives_DecompressPublicKeyInput_compressedPublicKey_FromDafny(dafnyInput.Dtor_compressedPublicKey()), + EccCurve: aws_cryptography_primitives_DecompressPublicKeyInput_eccCurve_FromDafny(dafnyInput.Dtor_eccCurve()), + } + +} + +func DecompressPublicKeyOutput_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.DecompressPublicKeyOutput) awscryptographyprimitivessmithygeneratedtypes.DecompressPublicKeyOutput { + + return awscryptographyprimitivessmithygeneratedtypes.DecompressPublicKeyOutput{PublicKey: aws_cryptography_primitives_DecompressPublicKeyOutput_publicKey_FromDafny(dafnyOutput.Dtor_publicKey())} + +} + +func ParsePublicKeyInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.ParsePublicKeyInput) awscryptographyprimitivessmithygeneratedtypes.ParsePublicKeyInput { + + return awscryptographyprimitivessmithygeneratedtypes.ParsePublicKeyInput{PublicKey: aws_cryptography_primitives_ParsePublicKeyInput_publicKey_FromDafny(dafnyInput.Dtor_publicKey())} + +} + +func ParsePublicKeyOutput_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.ParsePublicKeyOutput) awscryptographyprimitivessmithygeneratedtypes.ParsePublicKeyOutput { + + return awscryptographyprimitivessmithygeneratedtypes.ParsePublicKeyOutput{PublicKey: aws_cryptography_primitives_ParsePublicKeyOutput_publicKey_FromDafny(dafnyOutput.Dtor_publicKey())} + +} + +func AwsCryptographicPrimitivesError_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.Error) awscryptographyprimitivessmithygeneratedtypes.AwsCryptographicPrimitivesError { + return awscryptographyprimitivessmithygeneratedtypes.AwsCryptographicPrimitivesError{Message: aws_cryptography_primitives_AwsCryptographicPrimitivesError_message_FromDafny(dafnyOutput.Dtor_message())} + +} + +func CollectionOfErrors_Output_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.Error) awscryptographyprimitivessmithygeneratedtypes.CollectionOfErrors { + listOfErrors := dafnyOutput.Dtor_list() + message := dafnyOutput.Dtor_message() + t := awscryptographyprimitivessmithygeneratedtypes.CollectionOfErrors{} + for i := dafny.Iterate(listOfErrors); ; { + val, ok := i() + if !ok { + break + } + err := val.(AwsCryptographyPrimitivesTypes.Error) + t.ListOfErrors = append(t.ListOfErrors, Error_FromDafny(err)) + + } + t.Message = func() string { + var s string + for i := dafny.Iterate(message); ; { + val, ok := i() + if !ok { + return s + } else { + s = s + string(val.(dafny.Char)) + } + } + }() + return t +} +func OpaqueError_Output_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.Error) awscryptographyprimitivessmithygeneratedtypes.OpaqueError { + return awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: dafnyOutput.Dtor_obj(), + } +} + +func Error_FromDafny(err AwsCryptographyPrimitivesTypes.Error) error { + // Service Errors + if err.Is_AwsCryptographicPrimitivesError() { + return AwsCryptographicPrimitivesError_FromDafny(err) + } + + //DependentErrors + + //Unmodelled Errors + if err.Is_CollectionOfErrors() { + return CollectionOfErrors_Output_FromDafny(err) + } + + return OpaqueError_Output_FromDafny(err) +} + +func CryptoConfig_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.CryptoConfig) awscryptographyprimitivessmithygeneratedtypes.CryptoConfig { + return awscryptographyprimitivessmithygeneratedtypes.CryptoConfig{} + +} + +func Aws_cryptography_primitives_GenerateRandomBytesOutput_data_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_AESDecryptInput_key_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_ECDSAVerifyInput_message_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_DeriveSharedSecretInput_publicKey_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey { + return awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey{Der: aws_cryptography_primitives_ECCPublicKey_der_FromDafny(input.(AwsCryptographyPrimitivesTypes.ECCPublicKey).Dtor_der())} +} +func aws_cryptography_primitives_ECDSAVerifyInput_signatureAlgorithm_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm { + var u awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDSASignatureAlgorithm_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_AESEncryptInput_iv_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_RSADecryptInput_privateKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_HkdfInput_expectedLength_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func Aws_cryptography_primitives_ECDSAVerifyOutput_success_FromDafny(input interface{}) bool { + return input.(bool) +} +func Aws_cryptography_primitives_HkdfOutput_okm_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_HkdfExpandInput_expectedLength_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func aws_cryptography_primitives_GenerateECCKeyPairOutput_publicKey_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey { + return awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey{Der: aws_cryptography_primitives_ECCPublicKey_der_FromDafny(input.(AwsCryptographyPrimitivesTypes.ECCPublicKey).Dtor_der())} +} +func aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_publicKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_HMacInput_digestAlgorithm_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + return func() awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + var u awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm + inputEnum := input.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func Aws_cryptography_primitives_AESDecryptOutput_plaintext_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_ValidatePublicKeyInput_publicKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GenerateRandomBytesInput_length_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func aws_cryptography_primitives_AESDecryptInput_authTag_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_RSAEncryptInput_plaintext_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func Aws_cryptography_primitives_KdfCtrOutput_okm_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_KdfCtrInput_ikm_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_ParsePublicKeyOutput_publicKey_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey { + return awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey{Der: aws_cryptography_primitives_ECCPublicKey_der_FromDafny(input.(AwsCryptographyPrimitivesTypes.ECCPublicKey).Dtor_der())} +} +func aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_eccCurve_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + var u awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_HkdfExtractInput_ikm_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GetRSAKeyModulusLengthOutput_length_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func aws_cryptography_primitives_KdfCtrInput_purpose_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_AesKdfCtrInput_expectedLength_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func aws_cryptography_primitives_RSAPublicKey_lengthBits_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_privateKey_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey { + return awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey{Pem: aws_cryptography_primitives_ECCPrivateKey_pem_FromDafny(input.(AwsCryptographyPrimitivesTypes.ECCPrivateKey).Dtor_pem())} +} +func aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_signingKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_RSADecryptInput_cipherText_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_AESEncryptInput_aad_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_DecompressPublicKeyInput_eccCurve_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + var u awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func Aws_cryptography_primitives_ECDSASignOutput_signature_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_ValidatePublicKeyInput_eccCurve_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + var u awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_DeriveSharedSecretInput_eccCurve_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + var u awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_AES_GCM_ivLength_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func aws_cryptography_primitives_HkdfInput_info_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_HkdfExpandInput_info_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_HMacInput_key_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func Aws_cryptography_primitives_DigestOutput_digest_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_AESEncryptOutput_cipherText_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_AESEncryptInput_key_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_RSAPrivateKey_lengthBits_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func aws_cryptography_primitives_GenerateRSAKeyPairInput_lengthBits_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func aws_cryptography_primitives_DigestInput_message_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_RSAPublicKey_pem_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_ParsePublicKeyInput_publicKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_HkdfExpandInput_prk_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GetRSAKeyModulusLengthInput_publicKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GenerateRSAKeyPairOutput_publicKey_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.RSAPublicKey { + return awscryptographyprimitivessmithygeneratedtypes.RSAPublicKey{LengthBits: aws_cryptography_primitives_RSAPublicKey_lengthBits_FromDafny(input.(AwsCryptographyPrimitivesTypes.RSAPublicKey).Dtor_lengthBits()), + Pem: aws_cryptography_primitives_RSAPublicKey_pem_FromDafny(input.(AwsCryptographyPrimitivesTypes.RSAPublicKey).Dtor_pem()), + } +} +func aws_cryptography_primitives_AESEncryptInput_msg_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_DecompressPublicKeyInput_compressedPublicKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_RSAEncryptInput_publicKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_RSAPrivateKey_pem_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GenerateRSAKeyPairOutput_privateKey_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.RSAPrivateKey { + return awscryptographyprimitivessmithygeneratedtypes.RSAPrivateKey{LengthBits: aws_cryptography_primitives_RSAPrivateKey_lengthBits_FromDafny(input.(AwsCryptographyPrimitivesTypes.RSAPrivateKey).Dtor_lengthBits()), + Pem: aws_cryptography_primitives_RSAPrivateKey_pem_FromDafny(input.(AwsCryptographyPrimitivesTypes.RSAPrivateKey).Dtor_pem()), + } +} +func aws_cryptography_primitives_AESEncryptOutput_authTag_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_ECDSASignInput_signingKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_ECDSAVerifyInput_verificationKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_AesKdfCtrInput_nonce_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_HMacInput_message_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_CompressPublicKeyInput_publicKey_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey { + return awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey{Der: aws_cryptography_primitives_ECCPublicKey_der_FromDafny(input.(AwsCryptographyPrimitivesTypes.ECCPublicKey).Dtor_der())} +} +func aws_cryptography_primitives_DigestInput_digestAlgorithm_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + return func() awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + var u awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm + inputEnum := input.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_AES_GCM_tagLength_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func aws_cryptography_primitives_ValidatePublicKeyOutput_success_FromDafny(input interface{}) bool { + return input.(bool) +} +func aws_cryptography_primitives_ECDSASignInput_signatureAlgorithm_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm { + var u awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDSASignatureAlgorithm_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_RSADecryptInput_padding_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.RSAPaddingMode { + return func() awscryptographyprimitivessmithygeneratedtypes.RSAPaddingMode { + var u awscryptographyprimitivessmithygeneratedtypes.RSAPaddingMode + inputEnum := input.(AwsCryptographyPrimitivesTypes.RSAPaddingMode) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_RSAPaddingMode_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.RSAPaddingMode).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func Aws_cryptography_primitives_HkdfExtractOutput_prk_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func Aws_cryptography_primitives_RSADecryptOutput_plaintext_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GetPublicKeyFromPrivateKeyInput_privateKey_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey { + return awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey{Pem: aws_cryptography_primitives_ECCPrivateKey_pem_FromDafny(input.(AwsCryptographyPrimitivesTypes.ECCPrivateKey).Dtor_pem())} +} +func aws_cryptography_primitives_ECDSAVerifyInput_signature_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_AESDecryptInput_encAlg_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.AES_GCM { + return awscryptographyprimitivessmithygeneratedtypes.AES_GCM{KeyLength: aws_cryptography_primitives_AES_GCM_keyLength_FromDafny(input.(AwsCryptographyPrimitivesTypes.AES__GCM).Dtor_keyLength()), + TagLength: aws_cryptography_primitives_AES_GCM_tagLength_FromDafny(input.(AwsCryptographyPrimitivesTypes.AES__GCM).Dtor_tagLength()), + IvLength: aws_cryptography_primitives_AES_GCM_ivLength_FromDafny(input.(AwsCryptographyPrimitivesTypes.AES__GCM).Dtor_ivLength()), + } +} +func aws_cryptography_primitives_HkdfExpandInput_digestAlgorithm_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + return func() awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + var u awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm + inputEnum := input.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func Aws_cryptography_primitives_HkdfExpandOutput_okm_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GetPublicKeyFromPrivateKeyInput_eccCurve_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + var u awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_RSAEncryptInput_padding_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.RSAPaddingMode { + return func() awscryptographyprimitivessmithygeneratedtypes.RSAPaddingMode { + var u awscryptographyprimitivessmithygeneratedtypes.RSAPaddingMode + inputEnum := input.(AwsCryptographyPrimitivesTypes.RSAPaddingMode) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_RSAPaddingMode_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.RSAPaddingMode).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_DeriveSharedSecretInput_privateKey_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey { + return awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey{Pem: aws_cryptography_primitives_ECCPrivateKey_pem_FromDafny(input.(AwsCryptographyPrimitivesTypes.ECCPrivateKey).Dtor_pem())} +} +func aws_cryptography_primitives_ECCPublicKey_der_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_HkdfInput_ikm_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GenerateECDSASignatureKeyInput_signatureAlgorithm_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm { + var u awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDSASignatureAlgorithm_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_AESDecryptInput_cipherTxt_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_KdfCtrInput_digestAlgorithm_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + return func() awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + var u awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm + inputEnum := input.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_HkdfExtractInput_salt_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func Aws_cryptography_primitives_HMacOutput_digest_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_KdfCtrInput_nonce_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_signatureAlgorithm_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm { + var u awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDSASignatureAlgorithm_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_CompressPublicKeyInput_eccCurve_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + var u awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_verificationKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_DecompressPublicKeyOutput_publicKey_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey { + return awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey{Der: aws_cryptography_primitives_ECCPublicKey_der_FromDafny(input.(AwsCryptographyPrimitivesTypes.ECCPublicKey).Dtor_der())} +} +func aws_cryptography_primitives_HkdfExtractInput_digestAlgorithm_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + return func() awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + var u awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm + inputEnum := input.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func Aws_cryptography_primitives_RSAEncryptOutput_cipherText_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GenerateECCKeyPairOutput_eccCurve_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + var u awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_HkdfInput_salt_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_ECCPrivateKey_pem_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_AESDecryptInput_aad_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_AwsCryptographicPrimitivesError_message_FromDafny(input interface{}) string { + return func() string { + var s string + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return s + } else { + s = s + string(val.(dafny.Char)) + } + } + }() +} +func aws_cryptography_primitives_AES_GCM_keyLength_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func aws_cryptography_primitives_HkdfInput_digestAlgorithm_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + return func() awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + var u awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm + inputEnum := input.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_AesKdfCtrInput_ikm_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GenerateECCKeyPairInput_eccCurve_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + var u awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_AESEncryptInput_encAlg_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.AES_GCM { + return awscryptographyprimitivessmithygeneratedtypes.AES_GCM{KeyLength: aws_cryptography_primitives_AES_GCM_keyLength_FromDafny(input.(AwsCryptographyPrimitivesTypes.AES__GCM).Dtor_keyLength()), + TagLength: aws_cryptography_primitives_AES_GCM_tagLength_FromDafny(input.(AwsCryptographyPrimitivesTypes.AES__GCM).Dtor_tagLength()), + IvLength: aws_cryptography_primitives_AES_GCM_ivLength_FromDafny(input.(AwsCryptographyPrimitivesTypes.AES__GCM).Dtor_ivLength()), + } +} +func aws_cryptography_primitives_CompressPublicKeyOutput_compressedPublicKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_AESDecryptInput_iv_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_KdfCtrInput_expectedLength_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func aws_cryptography_primitives_ECDSASignInput_message_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_DeriveSharedSecretOutput_sharedSecret_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func Aws_cryptography_primitives_AesKdfCtrOutput_okm_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GenerateECCKeyPairOutput_privateKey_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey { + return awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey{Pem: aws_cryptography_primitives_ECCPrivateKey_pem_FromDafny(input.(AwsCryptographyPrimitivesTypes.ECCPrivateKey).Dtor_pem())} +} diff --git a/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/enums.go b/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/enums.go new file mode 100644 index 000000000..11a7802a1 --- /dev/null +++ b/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/enums.go @@ -0,0 +1,71 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package awscryptographyprimitivessmithygeneratedtypes + +type ECDHCurveSpec string + +const ( + ECDHCurveSpecEccNistP256 ECDHCurveSpec = "ECC_NIST_P256" + ECDHCurveSpecEccNistP384 ECDHCurveSpec = "ECC_NIST_P384" + ECDHCurveSpecEccNistP521 ECDHCurveSpec = "ECC_NIST_P521" + ECDHCurveSpecSm2 ECDHCurveSpec = "SM2" +) + +func (ECDHCurveSpec) Values() []ECDHCurveSpec { + return []ECDHCurveSpec{ + "ECC_NIST_P256", + "ECC_NIST_P384", + "ECC_NIST_P521", + "SM2", + } +} + +type DigestAlgorithm string + +const ( + DigestAlgorithmSha512 DigestAlgorithm = "SHA_512" + DigestAlgorithmSha384 DigestAlgorithm = "SHA_384" + DigestAlgorithmSha256 DigestAlgorithm = "SHA_256" +) + +func (DigestAlgorithm) Values() []DigestAlgorithm { + return []DigestAlgorithm{ + "SHA_512", + "SHA_384", + "SHA_256", + } +} + +type ECDSASignatureAlgorithm string + +const ( + ECDSASignatureAlgorithmEcdsaP384 ECDSASignatureAlgorithm = "ECDSA_P384" + ECDSASignatureAlgorithmEcdsaP256 ECDSASignatureAlgorithm = "ECDSA_P256" +) + +func (ECDSASignatureAlgorithm) Values() []ECDSASignatureAlgorithm { + return []ECDSASignatureAlgorithm{ + "ECDSA_P384", + "ECDSA_P256", + } +} + +type RSAPaddingMode string + +const ( + RSAPaddingModePkcs1 RSAPaddingMode = "PKCS1" + RSAPaddingModeOaepSha1 RSAPaddingMode = "OAEP_SHA1" + RSAPaddingModeOaepSha256 RSAPaddingMode = "OAEP_SHA256" + RSAPaddingModeOaepSha384 RSAPaddingMode = "OAEP_SHA384" + RSAPaddingModeOaepSha512 RSAPaddingMode = "OAEP_SHA512" +) + +func (RSAPaddingMode) Values() []RSAPaddingMode { + return []RSAPaddingMode{ + "PKCS1", + "OAEP_SHA1", + "OAEP_SHA256", + "OAEP_SHA384", + "OAEP_SHA512", + } +} diff --git a/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/errors.go b/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/errors.go new file mode 100644 index 000000000..0acaacb8b --- /dev/null +++ b/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/errors.go @@ -0,0 +1,17 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package awscryptographyprimitivessmithygeneratedtypes + +import ( + "fmt" +) + +type AwsCryptographicPrimitivesError struct { + AwsCryptographicPrimitivesBaseException + Message string + ErrorCodeOverride *string +} + +func (e AwsCryptographicPrimitivesError) Error() string { + return fmt.Sprintf("%s: %s", e.ErrorCodeOverride, e.Message) +} diff --git a/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/types.go b/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/types.go new file mode 100644 index 000000000..9d2605d70 --- /dev/null +++ b/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/types.go @@ -0,0 +1,717 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package awscryptographyprimitivessmithygeneratedtypes + +import ( + "fmt" +) + +type AES_GCM struct { + IvLength int32 + + KeyLength int32 + + TagLength int32 +} + +func (input AES_GCM) Validate() error { + if input.IvLength < 0 { + return fmt.Errorf("Uint8Bits has a minimum of 0 but has the value of %d.", input.IvLength) + } + if input.IvLength > 255 { + return fmt.Errorf("Uint8Bits has a maximum of 255 but has the value of %d.", input.IvLength) + } + if input.KeyLength < 1 { + return fmt.Errorf("SymmetricKeyLength has a minimum of 1 but has the value of %d.", input.KeyLength) + } + if input.KeyLength > 32 { + return fmt.Errorf("SymmetricKeyLength has a maximum of 32 but has the value of %d.", input.KeyLength) + } + if input.TagLength < 0 { + return fmt.Errorf("Uint8Bytes has a minimum of 0 but has the value of %d.", input.TagLength) + } + if input.TagLength > 32 { + return fmt.Errorf("Uint8Bytes has a maximum of 32 but has the value of %d.", input.TagLength) + } + + return nil +} + +type AESDecryptInput struct { + Aad []byte + + AuthTag []byte + + CipherTxt []byte + + EncAlg AES_GCM + + Iv []byte + + Key []byte +} + +func (input AESDecryptInput) Validate() error { + if input.EncAlg.Validate() != nil { + return input.EncAlg.Validate() + } + + return nil +} + +type AESDecryptOutput struct { + Plaintext []byte +} + +func (input AESDecryptOutput) Validate() error { + + return nil +} + +type AESEncryptInput struct { + Aad []byte + + EncAlg AES_GCM + + Iv []byte + + Key []byte + + Msg []byte +} + +func (input AESEncryptInput) Validate() error { + if input.EncAlg.Validate() != nil { + return input.EncAlg.Validate() + } + + return nil +} + +type AESEncryptOutput struct { + AuthTag []byte + + CipherText []byte +} + +func (input AESEncryptOutput) Validate() error { + + return nil +} + +type AesKdfCtrInput struct { + ExpectedLength int32 + + Ikm []byte + + Nonce []byte +} + +func (input AesKdfCtrInput) Validate() error { + if input.ExpectedLength < 0 { + return fmt.Errorf("PositiveInteger has a minimum of 0 but has the value of %d.", input.ExpectedLength) + } + + return nil +} + +type AesKdfCtrOutput struct { + Okm []byte +} + +func (input AesKdfCtrOutput) Validate() error { + + return nil +} + +type ECCPublicKey struct { + Der []byte +} + +func (input ECCPublicKey) Validate() error { + + return nil +} + +type CompressPublicKeyInput struct { + EccCurve ECDHCurveSpec + + PublicKey ECCPublicKey +} + +func (input CompressPublicKeyInput) Validate() error { + if input.PublicKey.Validate() != nil { + return input.PublicKey.Validate() + } + + return nil +} + +type CompressPublicKeyOutput struct { + CompressedPublicKey []byte +} + +func (input CompressPublicKeyOutput) Validate() error { + + return nil +} + +type DecompressPublicKeyInput struct { + CompressedPublicKey []byte + + EccCurve ECDHCurveSpec +} + +func (input DecompressPublicKeyInput) Validate() error { + + return nil +} + +type DecompressPublicKeyOutput struct { + PublicKey ECCPublicKey +} + +func (input DecompressPublicKeyOutput) Validate() error { + if input.PublicKey.Validate() != nil { + return input.PublicKey.Validate() + } + + return nil +} + +type ECCPrivateKey struct { + Pem []byte +} + +func (input ECCPrivateKey) Validate() error { + + return nil +} + +type DeriveSharedSecretInput struct { + EccCurve ECDHCurveSpec + + PrivateKey ECCPrivateKey + + PublicKey ECCPublicKey +} + +func (input DeriveSharedSecretInput) Validate() error { + if input.PrivateKey.Validate() != nil { + return input.PrivateKey.Validate() + } + if input.PublicKey.Validate() != nil { + return input.PublicKey.Validate() + } + + return nil +} + +type DeriveSharedSecretOutput struct { + SharedSecret []byte +} + +func (input DeriveSharedSecretOutput) Validate() error { + + return nil +} + +type DigestInput struct { + DigestAlgorithm DigestAlgorithm + + Message []byte +} + +func (input DigestInput) Validate() error { + + return nil +} + +type DigestOutput struct { + Digest []byte +} + +func (input DigestOutput) Validate() error { + + return nil +} + +type ECDSASignInput struct { + Message []byte + + SignatureAlgorithm ECDSASignatureAlgorithm + + SigningKey []byte +} + +func (input ECDSASignInput) Validate() error { + + return nil +} + +type ECDSASignOutput struct { + Signature []byte +} + +func (input ECDSASignOutput) Validate() error { + + return nil +} + +type ECDSAVerifyInput struct { + Message []byte + + Signature []byte + + SignatureAlgorithm ECDSASignatureAlgorithm + + VerificationKey []byte +} + +func (input ECDSAVerifyInput) Validate() error { + + return nil +} + +type ECDSAVerifyOutput struct { + Success bool +} + +func (input ECDSAVerifyOutput) Validate() error { + + return nil +} + +type GenerateECCKeyPairInput struct { + EccCurve ECDHCurveSpec +} + +func (input GenerateECCKeyPairInput) Validate() error { + + return nil +} + +type GenerateECCKeyPairOutput struct { + EccCurve ECDHCurveSpec + + PrivateKey ECCPrivateKey + + PublicKey ECCPublicKey +} + +func (input GenerateECCKeyPairOutput) Validate() error { + if input.PrivateKey.Validate() != nil { + return input.PrivateKey.Validate() + } + if input.PublicKey.Validate() != nil { + return input.PublicKey.Validate() + } + + return nil +} + +type GenerateECDSASignatureKeyInput struct { + SignatureAlgorithm ECDSASignatureAlgorithm +} + +func (input GenerateECDSASignatureKeyInput) Validate() error { + + return nil +} + +type GenerateECDSASignatureKeyOutput struct { + SignatureAlgorithm ECDSASignatureAlgorithm + + SigningKey []byte + + VerificationKey []byte +} + +func (input GenerateECDSASignatureKeyOutput) Validate() error { + + return nil +} + +type GenerateRandomBytesInput struct { + Length int32 +} + +func (input GenerateRandomBytesInput) Validate() error { + if input.Length < 0 { + return fmt.Errorf("PositiveInteger has a minimum of 0 but has the value of %d.", input.Length) + } + + return nil +} + +type GenerateRandomBytesOutput struct { + Data []byte +} + +func (input GenerateRandomBytesOutput) Validate() error { + + return nil +} + +type GenerateRSAKeyPairInput struct { + LengthBits int32 +} + +func (input GenerateRSAKeyPairInput) Validate() error { + if input.LengthBits < 81 { + return fmt.Errorf("RSAModulusLengthBitsToGenerate has a minimum of 81 but has the value of %d.", input.LengthBits) + } + if input.LengthBits > 4096 { + return fmt.Errorf("RSAModulusLengthBitsToGenerate has a maximum of 4096 but has the value of %d.", input.LengthBits) + } + + return nil +} + +type RSAPrivateKey struct { + LengthBits int32 + + Pem []byte +} + +func (input RSAPrivateKey) Validate() error { + if input.LengthBits < 81 { + return fmt.Errorf("RSAModulusLengthBits has a minimum of 81 but has the value of %d.", input.LengthBits) + } + + return nil +} + +type RSAPublicKey struct { + LengthBits int32 + + Pem []byte +} + +func (input RSAPublicKey) Validate() error { + if input.LengthBits < 81 { + return fmt.Errorf("RSAModulusLengthBits has a minimum of 81 but has the value of %d.", input.LengthBits) + } + + return nil +} + +type GenerateRSAKeyPairOutput struct { + PrivateKey RSAPrivateKey + + PublicKey RSAPublicKey +} + +func (input GenerateRSAKeyPairOutput) Validate() error { + if input.PrivateKey.Validate() != nil { + return input.PrivateKey.Validate() + } + if input.PublicKey.Validate() != nil { + return input.PublicKey.Validate() + } + + return nil +} + +type GetPublicKeyFromPrivateKeyInput struct { + EccCurve ECDHCurveSpec + + PrivateKey ECCPrivateKey +} + +func (input GetPublicKeyFromPrivateKeyInput) Validate() error { + if input.PrivateKey.Validate() != nil { + return input.PrivateKey.Validate() + } + + return nil +} + +type GetPublicKeyFromPrivateKeyOutput struct { + EccCurve ECDHCurveSpec + + PrivateKey ECCPrivateKey + + PublicKey []byte +} + +func (input GetPublicKeyFromPrivateKeyOutput) Validate() error { + if input.PrivateKey.Validate() != nil { + return input.PrivateKey.Validate() + } + + return nil +} + +type GetRSAKeyModulusLengthInput struct { + PublicKey []byte +} + +func (input GetRSAKeyModulusLengthInput) Validate() error { + + return nil +} + +type GetRSAKeyModulusLengthOutput struct { + Length int32 +} + +func (input GetRSAKeyModulusLengthOutput) Validate() error { + if input.Length < 81 { + return fmt.Errorf("RSAModulusLengthBits has a minimum of 81 but has the value of %d.", input.Length) + } + + return nil +} + +type HkdfInput struct { + DigestAlgorithm DigestAlgorithm + + ExpectedLength int32 + + Ikm []byte + + Info []byte + + Salt []byte +} + +func (input HkdfInput) Validate() error { + if input.ExpectedLength < 0 { + return fmt.Errorf("PositiveInteger has a minimum of 0 but has the value of %d.", input.ExpectedLength) + } + + return nil +} + +type HkdfOutput struct { + Okm []byte +} + +func (input HkdfOutput) Validate() error { + + return nil +} + +type HkdfExpandInput struct { + DigestAlgorithm DigestAlgorithm + + ExpectedLength int32 + + Info []byte + + Prk []byte +} + +func (input HkdfExpandInput) Validate() error { + if input.ExpectedLength < 0 { + return fmt.Errorf("PositiveInteger has a minimum of 0 but has the value of %d.", input.ExpectedLength) + } + + return nil +} + +type HkdfExpandOutput struct { + Okm []byte +} + +func (input HkdfExpandOutput) Validate() error { + + return nil +} + +type HkdfExtractInput struct { + DigestAlgorithm DigestAlgorithm + + Ikm []byte + + Salt []byte +} + +func (input HkdfExtractInput) Validate() error { + + return nil +} + +type HkdfExtractOutput struct { + Prk []byte +} + +func (input HkdfExtractOutput) Validate() error { + + return nil +} + +type HMacInput struct { + DigestAlgorithm DigestAlgorithm + + Key []byte + + Message []byte +} + +func (input HMacInput) Validate() error { + + return nil +} + +type HMacOutput struct { + Digest []byte +} + +func (input HMacOutput) Validate() error { + + return nil +} + +type KdfCtrInput struct { + DigestAlgorithm DigestAlgorithm + + ExpectedLength int32 + + Ikm []byte + + Nonce []byte + + Purpose []byte +} + +func (input KdfCtrInput) Validate() error { + if input.ExpectedLength < 0 { + return fmt.Errorf("PositiveInteger has a minimum of 0 but has the value of %d.", input.ExpectedLength) + } + + return nil +} + +type KdfCtrOutput struct { + Okm []byte +} + +func (input KdfCtrOutput) Validate() error { + + return nil +} + +type ParsePublicKeyInput struct { + PublicKey []byte +} + +func (input ParsePublicKeyInput) Validate() error { + + return nil +} + +type ParsePublicKeyOutput struct { + PublicKey ECCPublicKey +} + +func (input ParsePublicKeyOutput) Validate() error { + if input.PublicKey.Validate() != nil { + return input.PublicKey.Validate() + } + + return nil +} + +type RSADecryptInput struct { + CipherText []byte + + Padding RSAPaddingMode + + PrivateKey []byte +} + +func (input RSADecryptInput) Validate() error { + + return nil +} + +type RSADecryptOutput struct { + Plaintext []byte +} + +func (input RSADecryptOutput) Validate() error { + + return nil +} + +type RSAEncryptInput struct { + Padding RSAPaddingMode + + Plaintext []byte + + PublicKey []byte +} + +func (input RSAEncryptInput) Validate() error { + + return nil +} + +type RSAEncryptOutput struct { + CipherText []byte +} + +func (input RSAEncryptOutput) Validate() error { + + return nil +} + +type ValidatePublicKeyInput struct { + EccCurve ECDHCurveSpec + + PublicKey []byte +} + +func (input ValidatePublicKeyInput) Validate() error { + + return nil +} + +type ValidatePublicKeyOutput struct { + Success bool +} + +func (input ValidatePublicKeyOutput) Validate() error { + + return nil +} + +type AES_CTR struct { + KeyLength int32 + + NonceLength int32 +} + +func (input AES_CTR) Validate() error { + if input.KeyLength < 1 { + return fmt.Errorf("SymmetricKeyLength has a minimum of 1 but has the value of %d.", input.KeyLength) + } + if input.KeyLength > 32 { + return fmt.Errorf("SymmetricKeyLength has a maximum of 32 but has the value of %d.", input.KeyLength) + } + if input.NonceLength < 0 { + return fmt.Errorf("Uint8Bits has a minimum of 0 but has the value of %d.", input.NonceLength) + } + if input.NonceLength > 255 { + return fmt.Errorf("Uint8Bits has a maximum of 255 but has the value of %d.", input.NonceLength) + } + + return nil +} + +type CryptoConfig struct { +} + +func (input CryptoConfig) Validate() error { + + return nil +} + +type AwsCryptographicPrimitivesBaseException interface { + // This is a dummy method to allow type assertion since Go empty interfaces + // aren't useful for type assertion checks. No concrete class is expected to implement + // this method. This is also not exported. + interfaceBindingMethod() +} diff --git a/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/unmodelled_errors.go b/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/unmodelled_errors.go new file mode 100644 index 000000000..bc6484a09 --- /dev/null +++ b/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/unmodelled_errors.go @@ -0,0 +1,26 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package awscryptographyprimitivessmithygeneratedtypes + +import ( + "fmt" +) + +type CollectionOfErrors struct { + AwsCryptographicPrimitivesBaseException + ListOfErrors []error + Message string +} + +func (e CollectionOfErrors) Error() string { + return fmt.Sprintf("message: %s\n err %v", e.Message, e.ListOfErrors) +} + +type OpaqueError struct { + AwsCryptographicPrimitivesBaseException + ErrObject interface{} +} + +func (e OpaqueError) Error() string { + return fmt.Sprintf("message: %v", e.ErrObject) +} diff --git a/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/WrappedAwsCryptographyPrimitivesService/shim.go b/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/WrappedAwsCryptographyPrimitivesService/shim.go new file mode 100644 index 000000000..625816d56 --- /dev/null +++ b/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/WrappedAwsCryptographyPrimitivesService/shim.go @@ -0,0 +1,241 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package WrappedAwsCryptographyPrimitivesService + +import ( + "context" + + "github.com/aws/aws-cryptographic-material-providers-library/primitives/AwsCryptographyPrimitivesTypes" + "github.com/aws/aws-cryptographic-material-providers-library/primitives/awscryptographyprimitivessmithygenerated" + "github.com/dafny-lang/DafnyStandardLibGo/Wrappers" +) + +type Shim struct { + AwsCryptographyPrimitivesTypes.IAwsCryptographicPrimitivesClient + client *awscryptographyprimitivessmithygenerated.Client +} + +func (_static *CompanionStruct_Default___) WrappedAtomicPrimitives(inputConfig AwsCryptographyPrimitivesTypes.CryptoConfig) Wrappers.Result { + var nativeConfig = awscryptographyprimitivessmithygenerated.CryptoConfig_FromDafny(inputConfig) + var nativeClient, nativeError = awscryptographyprimitivessmithygenerated.NewClient(nativeConfig) + if nativeError != nil { + return Wrappers.Companion_Result_.Create_Failure_(AwsCryptographyPrimitivesTypes.Companion_Error_.Create_Opaque_(nativeError)) + } + return Wrappers.Companion_Result_.Create_Success_(&Shim{client: nativeClient}) +} + +func (shim *Shim) GenerateRandomBytes(input AwsCryptographyPrimitivesTypes.GenerateRandomBytesInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.GenerateRandomBytesInput_FromDafny(input) + var native_response, native_error = shim.client.GenerateRandomBytes(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_GenerateRandomBytesOutput_data_ToDafny(native_response)) +} + +func (shim *Shim) Digest(input AwsCryptographyPrimitivesTypes.DigestInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.DigestInput_FromDafny(input) + var native_response, native_error = shim.client.Digest(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_DigestOutput_digest_ToDafny(native_response)) +} + +func (shim *Shim) HMac(input AwsCryptographyPrimitivesTypes.HMacInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.HMacInput_FromDafny(input) + var native_response, native_error = shim.client.HMac(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_HMacOutput_digest_ToDafny(native_response)) +} + +func (shim *Shim) HkdfExtract(input AwsCryptographyPrimitivesTypes.HkdfExtractInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.HkdfExtractInput_FromDafny(input) + var native_response, native_error = shim.client.HkdfExtract(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_HkdfExtractOutput_prk_ToDafny(native_response)) +} + +func (shim *Shim) HkdfExpand(input AwsCryptographyPrimitivesTypes.HkdfExpandInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.HkdfExpandInput_FromDafny(input) + var native_response, native_error = shim.client.HkdfExpand(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_HkdfExpandOutput_okm_ToDafny(native_response)) +} + +func (shim *Shim) Hkdf(input AwsCryptographyPrimitivesTypes.HkdfInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.HkdfInput_FromDafny(input) + var native_response, native_error = shim.client.Hkdf(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_HkdfOutput_okm_ToDafny(native_response)) +} + +func (shim *Shim) KdfCounterMode(input AwsCryptographyPrimitivesTypes.KdfCtrInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.KdfCtrInput_FromDafny(input) + var native_response, native_error = shim.client.KdfCounterMode(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_KdfCtrOutput_okm_ToDafny(native_response)) +} + +func (shim *Shim) AesKdfCounterMode(input AwsCryptographyPrimitivesTypes.AesKdfCtrInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.AesKdfCtrInput_FromDafny(input) + var native_response, native_error = shim.client.AesKdfCounterMode(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_AesKdfCtrOutput_okm_ToDafny(native_response)) +} + +func (shim *Shim) AESEncrypt(input AwsCryptographyPrimitivesTypes.AESEncryptInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.AESEncryptInput_FromDafny(input) + var native_response, native_error = shim.client.AESEncrypt(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.AESEncryptOutput_ToDafny(*native_response)) +} + +func (shim *Shim) AESDecrypt(input AwsCryptographyPrimitivesTypes.AESDecryptInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.AESDecryptInput_FromDafny(input) + var native_response, native_error = shim.client.AESDecrypt(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_AESDecryptOutput_plaintext_ToDafny(native_response)) +} + +func (shim *Shim) GenerateRSAKeyPair(input AwsCryptographyPrimitivesTypes.GenerateRSAKeyPairInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.GenerateRSAKeyPairInput_FromDafny(input) + var native_response, native_error = shim.client.GenerateRSAKeyPair(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.GenerateRSAKeyPairOutput_ToDafny(*native_response)) +} + +func (shim *Shim) GetRSAKeyModulusLength(input AwsCryptographyPrimitivesTypes.GetRSAKeyModulusLengthInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.GetRSAKeyModulusLengthInput_FromDafny(input) + var native_response, native_error = shim.client.GetRSAKeyModulusLength(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.GetRSAKeyModulusLengthOutput_ToDafny(*native_response)) +} + +func (shim *Shim) RSADecrypt(input AwsCryptographyPrimitivesTypes.RSADecryptInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.RSADecryptInput_FromDafny(input) + var native_response, native_error = shim.client.RSADecrypt(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_RSADecryptOutput_plaintext_ToDafny(native_response)) +} + +func (shim *Shim) RSAEncrypt(input AwsCryptographyPrimitivesTypes.RSAEncryptInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.RSAEncryptInput_FromDafny(input) + var native_response, native_error = shim.client.RSAEncrypt(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_RSAEncryptOutput_cipherText_ToDafny(native_response)) +} + +func (shim *Shim) GenerateECDSASignatureKey(input AwsCryptographyPrimitivesTypes.GenerateECDSASignatureKeyInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.GenerateECDSASignatureKeyInput_FromDafny(input) + var native_response, native_error = shim.client.GenerateECDSASignatureKey(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.GenerateECDSASignatureKeyOutput_ToDafny(*native_response)) +} + +func (shim *Shim) ECDSASign(input AwsCryptographyPrimitivesTypes.ECDSASignInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.ECDSASignInput_FromDafny(input) + var native_response, native_error = shim.client.ECDSASign(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_ECDSASignOutput_signature_ToDafny(native_response)) +} + +func (shim *Shim) ECDSAVerify(input AwsCryptographyPrimitivesTypes.ECDSAVerifyInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.ECDSAVerifyInput_FromDafny(input) + var native_response, native_error = shim.client.ECDSAVerify(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.Aws_cryptography_primitives_ECDSAVerifyOutput_success_ToDafny(native_response)) +} + +func (shim *Shim) GenerateECCKeyPair(input AwsCryptographyPrimitivesTypes.GenerateECCKeyPairInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.GenerateECCKeyPairInput_FromDafny(input) + var native_response, native_error = shim.client.GenerateECCKeyPair(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.GenerateECCKeyPairOutput_ToDafny(*native_response)) +} + +func (shim *Shim) GetPublicKeyFromPrivateKey(input AwsCryptographyPrimitivesTypes.GetPublicKeyFromPrivateKeyInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.GetPublicKeyFromPrivateKeyInput_FromDafny(input) + var native_response, native_error = shim.client.GetPublicKeyFromPrivateKey(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.GetPublicKeyFromPrivateKeyOutput_ToDafny(*native_response)) +} + +func (shim *Shim) ValidatePublicKey(input AwsCryptographyPrimitivesTypes.ValidatePublicKeyInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.ValidatePublicKeyInput_FromDafny(input) + var native_response, native_error = shim.client.ValidatePublicKey(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.ValidatePublicKeyOutput_ToDafny(*native_response)) +} + +func (shim *Shim) DeriveSharedSecret(input AwsCryptographyPrimitivesTypes.DeriveSharedSecretInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.DeriveSharedSecretInput_FromDafny(input) + var native_response, native_error = shim.client.DeriveSharedSecret(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.DeriveSharedSecretOutput_ToDafny(*native_response)) +} + +func (shim *Shim) CompressPublicKey(input AwsCryptographyPrimitivesTypes.CompressPublicKeyInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.CompressPublicKeyInput_FromDafny(input) + var native_response, native_error = shim.client.CompressPublicKey(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.CompressPublicKeyOutput_ToDafny(*native_response)) +} + +func (shim *Shim) DecompressPublicKey(input AwsCryptographyPrimitivesTypes.DecompressPublicKeyInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.DecompressPublicKeyInput_FromDafny(input) + var native_response, native_error = shim.client.DecompressPublicKey(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.DecompressPublicKeyOutput_ToDafny(*native_response)) +} + +func (shim *Shim) ParsePublicKey(input AwsCryptographyPrimitivesTypes.ParsePublicKeyInput) Wrappers.Result { + var native_request = awscryptographyprimitivessmithygenerated.ParsePublicKeyInput_FromDafny(input) + var native_response, native_error = shim.client.ParsePublicKey(context.Background(), native_request) + if native_error != nil { + return Wrappers.Companion_Result_.Create_Failure_(awscryptographyprimitivessmithygenerated.Error_ToDafny(native_error)) + } + return Wrappers.Companion_Result_.Create_Success_(awscryptographyprimitivessmithygenerated.ParsePublicKeyOutput_ToDafny(*native_response)) +} diff --git a/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/awscryptographyprimitivessmithygenerated/api_client.go b/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/awscryptographyprimitivessmithygenerated/api_client.go new file mode 100644 index 000000000..7c6437db0 --- /dev/null +++ b/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/awscryptographyprimitivessmithygenerated/api_client.go @@ -0,0 +1,557 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package awscryptographyprimitivessmithygenerated + +import ( + "context" + + "github.com/aws/aws-cryptographic-material-providers-library/primitives/AtomicPrimitives" + "github.com/aws/aws-cryptographic-material-providers-library/primitives/AwsCryptographyPrimitivesTypes" + "github.com/aws/aws-cryptographic-material-providers-library/primitives/awscryptographyprimitivessmithygeneratedtypes" + "github.com/dafny-lang/DafnyRuntimeGo/v4/dafny" +) + +type Client struct { + DafnyClient AwsCryptographyPrimitivesTypes.IAwsCryptographicPrimitivesClient +} + +func NewClient(clientConfig awscryptographyprimitivessmithygeneratedtypes.CryptoConfig) (*Client, error) { + var dafnyConfig = CryptoConfig_ToDafny(clientConfig) + var dafny_response = AtomicPrimitives.Companion_Default___.AtomicPrimitives(dafnyConfig) + if dafny_response.Is_Failure() { + panic("Client construction failed. This should never happen") + } + var dafnyClient = dafny_response.Extract().(AwsCryptographyPrimitivesTypes.IAwsCryptographicPrimitivesClient) + client := &Client{dafnyClient} + return client, nil +} + +func (client *Client) GenerateRandomBytes(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.GenerateRandomBytesInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.GenerateRandomBytesInput = GenerateRandomBytesInput_ToDafny(params) + var dafny_response = client.DafnyClient.GenerateRandomBytes(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_GenerateRandomBytesOutput_data_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) Digest(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.DigestInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.DigestInput = DigestInput_ToDafny(params) + var dafny_response = client.DafnyClient.Digest(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_DigestOutput_digest_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) HMac(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.HMacInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.HMacInput = HMacInput_ToDafny(params) + var dafny_response = client.DafnyClient.HMac(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_HMacOutput_digest_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) HkdfExtract(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.HkdfExtractInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.HkdfExtractInput = HkdfExtractInput_ToDafny(params) + var dafny_response = client.DafnyClient.HkdfExtract(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_HkdfExtractOutput_prk_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) HkdfExpand(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.HkdfExpandInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.HkdfExpandInput = HkdfExpandInput_ToDafny(params) + var dafny_response = client.DafnyClient.HkdfExpand(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_HkdfExpandOutput_okm_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) Hkdf(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.HkdfInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.HkdfInput = HkdfInput_ToDafny(params) + var dafny_response = client.DafnyClient.Hkdf(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_HkdfOutput_okm_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) KdfCounterMode(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.KdfCtrInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.KdfCtrInput = KdfCtrInput_ToDafny(params) + var dafny_response = client.DafnyClient.KdfCounterMode(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_KdfCtrOutput_okm_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) AesKdfCounterMode(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.AesKdfCtrInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.AesKdfCtrInput = AesKdfCtrInput_ToDafny(params) + var dafny_response = client.DafnyClient.AesKdfCounterMode(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_AesKdfCtrOutput_okm_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) AESEncrypt(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.AESEncryptInput) (*awscryptographyprimitivessmithygeneratedtypes.AESEncryptOutput, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + return nil, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.AESEncryptInput = AESEncryptInput_ToDafny(params) + var dafny_response = client.DafnyClient.AESEncrypt(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + return nil, Error_FromDafny(err) + } + var native_response = AESEncryptOutput_FromDafny(dafny_response.Dtor_value().(AwsCryptographyPrimitivesTypes.AESEncryptOutput)) + return &native_response, nil + +} + +func (client *Client) AESDecrypt(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.AESDecryptInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.AESDecryptInput = AESDecryptInput_ToDafny(params) + var dafny_response = client.DafnyClient.AESDecrypt(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_AESDecryptOutput_plaintext_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) GenerateRSAKeyPair(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.GenerateRSAKeyPairInput) (*awscryptographyprimitivessmithygeneratedtypes.GenerateRSAKeyPairOutput, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + return nil, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.GenerateRSAKeyPairInput = GenerateRSAKeyPairInput_ToDafny(params) + var dafny_response = client.DafnyClient.GenerateRSAKeyPair(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + return nil, Error_FromDafny(err) + } + var native_response = GenerateRSAKeyPairOutput_FromDafny(dafny_response.Dtor_value().(AwsCryptographyPrimitivesTypes.GenerateRSAKeyPairOutput)) + return &native_response, nil + +} + +func (client *Client) GetRSAKeyModulusLength(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.GetRSAKeyModulusLengthInput) (*awscryptographyprimitivessmithygeneratedtypes.GetRSAKeyModulusLengthOutput, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + return nil, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.GetRSAKeyModulusLengthInput = GetRSAKeyModulusLengthInput_ToDafny(params) + var dafny_response = client.DafnyClient.GetRSAKeyModulusLength(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + return nil, Error_FromDafny(err) + } + var native_response = GetRSAKeyModulusLengthOutput_FromDafny(dafny_response.Dtor_value().(AwsCryptographyPrimitivesTypes.GetRSAKeyModulusLengthOutput)) + return &native_response, nil + +} + +func (client *Client) RSADecrypt(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.RSADecryptInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.RSADecryptInput = RSADecryptInput_ToDafny(params) + var dafny_response = client.DafnyClient.RSADecrypt(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_RSADecryptOutput_plaintext_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) RSAEncrypt(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.RSAEncryptInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.RSAEncryptInput = RSAEncryptInput_ToDafny(params) + var dafny_response = client.DafnyClient.RSAEncrypt(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_RSAEncryptOutput_cipherText_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) GenerateECDSASignatureKey(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.GenerateECDSASignatureKeyInput) (*awscryptographyprimitivessmithygeneratedtypes.GenerateECDSASignatureKeyOutput, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + return nil, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.GenerateECDSASignatureKeyInput = GenerateECDSASignatureKeyInput_ToDafny(params) + var dafny_response = client.DafnyClient.GenerateECDSASignatureKey(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + return nil, Error_FromDafny(err) + } + var native_response = GenerateECDSASignatureKeyOutput_FromDafny(dafny_response.Dtor_value().(AwsCryptographyPrimitivesTypes.GenerateECDSASignatureKeyOutput)) + return &native_response, nil + +} + +func (client *Client) ECDSASign(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.ECDSASignInput) ([]byte, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal []byte + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.ECDSASignInput = ECDSASignInput_ToDafny(params) + var dafny_response = client.DafnyClient.ECDSASign(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal []byte + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_ECDSASignOutput_signature_FromDafny(dafny_response.Dtor_value().(dafny.Sequence)) + return native_response, nil + +} + +func (client *Client) ECDSAVerify(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.ECDSAVerifyInput) (bool, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + var defaultVal bool + return defaultVal, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.ECDSAVerifyInput = ECDSAVerifyInput_ToDafny(params) + var dafny_response = client.DafnyClient.ECDSAVerify(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + var defaultVal bool + return defaultVal, Error_FromDafny(err) + } + var native_response = Aws_cryptography_primitives_ECDSAVerifyOutput_success_FromDafny(dafny_response.Dtor_value().(bool)) + return native_response, nil + +} + +func (client *Client) GenerateECCKeyPair(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.GenerateECCKeyPairInput) (*awscryptographyprimitivessmithygeneratedtypes.GenerateECCKeyPairOutput, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + return nil, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.GenerateECCKeyPairInput = GenerateECCKeyPairInput_ToDafny(params) + var dafny_response = client.DafnyClient.GenerateECCKeyPair(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + return nil, Error_FromDafny(err) + } + var native_response = GenerateECCKeyPairOutput_FromDafny(dafny_response.Dtor_value().(AwsCryptographyPrimitivesTypes.GenerateECCKeyPairOutput)) + return &native_response, nil + +} + +func (client *Client) GetPublicKeyFromPrivateKey(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.GetPublicKeyFromPrivateKeyInput) (*awscryptographyprimitivessmithygeneratedtypes.GetPublicKeyFromPrivateKeyOutput, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + return nil, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.GetPublicKeyFromPrivateKeyInput = GetPublicKeyFromPrivateKeyInput_ToDafny(params) + var dafny_response = client.DafnyClient.GetPublicKeyFromPrivateKey(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + return nil, Error_FromDafny(err) + } + var native_response = GetPublicKeyFromPrivateKeyOutput_FromDafny(dafny_response.Dtor_value().(AwsCryptographyPrimitivesTypes.GetPublicKeyFromPrivateKeyOutput)) + return &native_response, nil + +} + +func (client *Client) ValidatePublicKey(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.ValidatePublicKeyInput) (*awscryptographyprimitivessmithygeneratedtypes.ValidatePublicKeyOutput, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + return nil, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.ValidatePublicKeyInput = ValidatePublicKeyInput_ToDafny(params) + var dafny_response = client.DafnyClient.ValidatePublicKey(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + return nil, Error_FromDafny(err) + } + var native_response = ValidatePublicKeyOutput_FromDafny(dafny_response.Dtor_value().(AwsCryptographyPrimitivesTypes.ValidatePublicKeyOutput)) + return &native_response, nil + +} + +func (client *Client) DeriveSharedSecret(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.DeriveSharedSecretInput) (*awscryptographyprimitivessmithygeneratedtypes.DeriveSharedSecretOutput, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + return nil, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.DeriveSharedSecretInput = DeriveSharedSecretInput_ToDafny(params) + var dafny_response = client.DafnyClient.DeriveSharedSecret(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + return nil, Error_FromDafny(err) + } + var native_response = DeriveSharedSecretOutput_FromDafny(dafny_response.Dtor_value().(AwsCryptographyPrimitivesTypes.DeriveSharedSecretOutput)) + return &native_response, nil + +} + +func (client *Client) CompressPublicKey(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.CompressPublicKeyInput) (*awscryptographyprimitivessmithygeneratedtypes.CompressPublicKeyOutput, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + return nil, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.CompressPublicKeyInput = CompressPublicKeyInput_ToDafny(params) + var dafny_response = client.DafnyClient.CompressPublicKey(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + return nil, Error_FromDafny(err) + } + var native_response = CompressPublicKeyOutput_FromDafny(dafny_response.Dtor_value().(AwsCryptographyPrimitivesTypes.CompressPublicKeyOutput)) + return &native_response, nil + +} + +func (client *Client) DecompressPublicKey(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.DecompressPublicKeyInput) (*awscryptographyprimitivessmithygeneratedtypes.DecompressPublicKeyOutput, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + return nil, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.DecompressPublicKeyInput = DecompressPublicKeyInput_ToDafny(params) + var dafny_response = client.DafnyClient.DecompressPublicKey(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + return nil, Error_FromDafny(err) + } + var native_response = DecompressPublicKeyOutput_FromDafny(dafny_response.Dtor_value().(AwsCryptographyPrimitivesTypes.DecompressPublicKeyOutput)) + return &native_response, nil + +} + +func (client *Client) ParsePublicKey(ctx context.Context, params awscryptographyprimitivessmithygeneratedtypes.ParsePublicKeyInput) (*awscryptographyprimitivessmithygeneratedtypes.ParsePublicKeyOutput, error) { + err := params.Validate() + if err != nil { + opaqueErr := awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: err, + } + return nil, opaqueErr + } + + var dafny_request AwsCryptographyPrimitivesTypes.ParsePublicKeyInput = ParsePublicKeyInput_ToDafny(params) + var dafny_response = client.DafnyClient.ParsePublicKey(dafny_request) + + if dafny_response.Is_Failure() { + err := dafny_response.Dtor_error().(AwsCryptographyPrimitivesTypes.Error) + return nil, Error_FromDafny(err) + } + var native_response = ParsePublicKeyOutput_FromDafny(dafny_response.Dtor_value().(AwsCryptographyPrimitivesTypes.ParsePublicKeyOutput)) + return &native_response, nil + +} diff --git a/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/awscryptographyprimitivessmithygenerated/to_dafny.go b/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/awscryptographyprimitivessmithygenerated/to_dafny.go new file mode 100644 index 000000000..6727ffcb6 --- /dev/null +++ b/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/awscryptographyprimitivessmithygenerated/to_dafny.go @@ -0,0 +1,1789 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package awscryptographyprimitivessmithygenerated + +import ( + "github.com/aws/aws-cryptographic-material-providers-library/primitives/AwsCryptographyPrimitivesTypes" + "github.com/aws/aws-cryptographic-material-providers-library/primitives/awscryptographyprimitivessmithygeneratedtypes" + "github.com/dafny-lang/DafnyRuntimeGo/v4/dafny" + "github.com/dafny-lang/DafnyStandardLibGo/Wrappers" +) + +func GenerateRandomBytesInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.GenerateRandomBytesInput) AwsCryptographyPrimitivesTypes.GenerateRandomBytesInput { + + return func() AwsCryptographyPrimitivesTypes.GenerateRandomBytesInput { + + return AwsCryptographyPrimitivesTypes.Companion_GenerateRandomBytesInput_.Create_GenerateRandomBytesInput_(aws_cryptography_primitives_GenerateRandomBytesInput_length_ToDafny(nativeInput.Length)) + }() + +} + +func DigestInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.DigestInput) AwsCryptographyPrimitivesTypes.DigestInput { + + return func() AwsCryptographyPrimitivesTypes.DigestInput { + + return AwsCryptographyPrimitivesTypes.Companion_DigestInput_.Create_DigestInput_(aws_cryptography_primitives_DigestInput_digestAlgorithm_ToDafny(nativeInput.DigestAlgorithm), aws_cryptography_primitives_DigestInput_message_ToDafny(nativeInput.Message)) + }() + +} + +func HMacInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.HMacInput) AwsCryptographyPrimitivesTypes.HMacInput { + + return func() AwsCryptographyPrimitivesTypes.HMacInput { + + return AwsCryptographyPrimitivesTypes.Companion_HMacInput_.Create_HMacInput_(aws_cryptography_primitives_HMacInput_digestAlgorithm_ToDafny(nativeInput.DigestAlgorithm), aws_cryptography_primitives_HMacInput_key_ToDafny(nativeInput.Key), aws_cryptography_primitives_HMacInput_message_ToDafny(nativeInput.Message)) + }() + +} + +func HkdfExtractInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.HkdfExtractInput) AwsCryptographyPrimitivesTypes.HkdfExtractInput { + + return func() AwsCryptographyPrimitivesTypes.HkdfExtractInput { + + return AwsCryptographyPrimitivesTypes.Companion_HkdfExtractInput_.Create_HkdfExtractInput_(aws_cryptography_primitives_HkdfExtractInput_digestAlgorithm_ToDafny(nativeInput.DigestAlgorithm), aws_cryptography_primitives_HkdfExtractInput_salt_ToDafny(nativeInput.Salt), aws_cryptography_primitives_HkdfExtractInput_ikm_ToDafny(nativeInput.Ikm)) + }() + +} + +func HkdfExpandInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.HkdfExpandInput) AwsCryptographyPrimitivesTypes.HkdfExpandInput { + + return func() AwsCryptographyPrimitivesTypes.HkdfExpandInput { + + return AwsCryptographyPrimitivesTypes.Companion_HkdfExpandInput_.Create_HkdfExpandInput_(aws_cryptography_primitives_HkdfExpandInput_digestAlgorithm_ToDafny(nativeInput.DigestAlgorithm), aws_cryptography_primitives_HkdfExpandInput_prk_ToDafny(nativeInput.Prk), aws_cryptography_primitives_HkdfExpandInput_info_ToDafny(nativeInput.Info), aws_cryptography_primitives_HkdfExpandInput_expectedLength_ToDafny(nativeInput.ExpectedLength)) + }() + +} + +func HkdfInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.HkdfInput) AwsCryptographyPrimitivesTypes.HkdfInput { + + return func() AwsCryptographyPrimitivesTypes.HkdfInput { + + return AwsCryptographyPrimitivesTypes.Companion_HkdfInput_.Create_HkdfInput_(aws_cryptography_primitives_HkdfInput_digestAlgorithm_ToDafny(nativeInput.DigestAlgorithm), aws_cryptography_primitives_HkdfInput_salt_ToDafny(nativeInput.Salt), aws_cryptography_primitives_HkdfInput_ikm_ToDafny(nativeInput.Ikm), aws_cryptography_primitives_HkdfInput_info_ToDafny(nativeInput.Info), aws_cryptography_primitives_HkdfInput_expectedLength_ToDafny(nativeInput.ExpectedLength)) + }() + +} + +func KdfCtrInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.KdfCtrInput) AwsCryptographyPrimitivesTypes.KdfCtrInput { + + return func() AwsCryptographyPrimitivesTypes.KdfCtrInput { + + return AwsCryptographyPrimitivesTypes.Companion_KdfCtrInput_.Create_KdfCtrInput_(aws_cryptography_primitives_KdfCtrInput_digestAlgorithm_ToDafny(nativeInput.DigestAlgorithm), aws_cryptography_primitives_KdfCtrInput_ikm_ToDafny(nativeInput.Ikm), aws_cryptography_primitives_KdfCtrInput_expectedLength_ToDafny(nativeInput.ExpectedLength), aws_cryptography_primitives_KdfCtrInput_purpose_ToDafny(nativeInput.Purpose), aws_cryptography_primitives_KdfCtrInput_nonce_ToDafny(nativeInput.Nonce)) + }() + +} + +func AesKdfCtrInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.AesKdfCtrInput) AwsCryptographyPrimitivesTypes.AesKdfCtrInput { + + return func() AwsCryptographyPrimitivesTypes.AesKdfCtrInput { + + return AwsCryptographyPrimitivesTypes.Companion_AesKdfCtrInput_.Create_AesKdfCtrInput_(aws_cryptography_primitives_AesKdfCtrInput_ikm_ToDafny(nativeInput.Ikm), aws_cryptography_primitives_AesKdfCtrInput_expectedLength_ToDafny(nativeInput.ExpectedLength), aws_cryptography_primitives_AesKdfCtrInput_nonce_ToDafny(nativeInput.Nonce)) + }() + +} + +func AESEncryptInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.AESEncryptInput) AwsCryptographyPrimitivesTypes.AESEncryptInput { + + return func() AwsCryptographyPrimitivesTypes.AESEncryptInput { + + return AwsCryptographyPrimitivesTypes.Companion_AESEncryptInput_.Create_AESEncryptInput_(aws_cryptography_primitives_AESEncryptInput_encAlg_ToDafny(nativeInput.EncAlg), aws_cryptography_primitives_AESEncryptInput_iv_ToDafny(nativeInput.Iv), aws_cryptography_primitives_AESEncryptInput_key_ToDafny(nativeInput.Key), aws_cryptography_primitives_AESEncryptInput_msg_ToDafny(nativeInput.Msg), aws_cryptography_primitives_AESEncryptInput_aad_ToDafny(nativeInput.Aad)) + }() + +} + +func AESEncryptOutput_ToDafny(nativeOutput awscryptographyprimitivessmithygeneratedtypes.AESEncryptOutput) AwsCryptographyPrimitivesTypes.AESEncryptOutput { + + return func() AwsCryptographyPrimitivesTypes.AESEncryptOutput { + + return AwsCryptographyPrimitivesTypes.Companion_AESEncryptOutput_.Create_AESEncryptOutput_(aws_cryptography_primitives_AESEncryptOutput_cipherText_ToDafny(nativeOutput.CipherText), aws_cryptography_primitives_AESEncryptOutput_authTag_ToDafny(nativeOutput.AuthTag)) + }() + +} + +func AESDecryptInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.AESDecryptInput) AwsCryptographyPrimitivesTypes.AESDecryptInput { + + return func() AwsCryptographyPrimitivesTypes.AESDecryptInput { + + return AwsCryptographyPrimitivesTypes.Companion_AESDecryptInput_.Create_AESDecryptInput_(aws_cryptography_primitives_AESDecryptInput_encAlg_ToDafny(nativeInput.EncAlg), aws_cryptography_primitives_AESDecryptInput_key_ToDafny(nativeInput.Key), aws_cryptography_primitives_AESDecryptInput_cipherTxt_ToDafny(nativeInput.CipherTxt), aws_cryptography_primitives_AESDecryptInput_authTag_ToDafny(nativeInput.AuthTag), aws_cryptography_primitives_AESDecryptInput_iv_ToDafny(nativeInput.Iv), aws_cryptography_primitives_AESDecryptInput_aad_ToDafny(nativeInput.Aad)) + }() + +} + +func GenerateRSAKeyPairInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.GenerateRSAKeyPairInput) AwsCryptographyPrimitivesTypes.GenerateRSAKeyPairInput { + + return func() AwsCryptographyPrimitivesTypes.GenerateRSAKeyPairInput { + + return AwsCryptographyPrimitivesTypes.Companion_GenerateRSAKeyPairInput_.Create_GenerateRSAKeyPairInput_(aws_cryptography_primitives_GenerateRSAKeyPairInput_lengthBits_ToDafny(nativeInput.LengthBits)) + }() + +} + +func GenerateRSAKeyPairOutput_ToDafny(nativeOutput awscryptographyprimitivessmithygeneratedtypes.GenerateRSAKeyPairOutput) AwsCryptographyPrimitivesTypes.GenerateRSAKeyPairOutput { + + return func() AwsCryptographyPrimitivesTypes.GenerateRSAKeyPairOutput { + + return AwsCryptographyPrimitivesTypes.Companion_GenerateRSAKeyPairOutput_.Create_GenerateRSAKeyPairOutput_(aws_cryptography_primitives_GenerateRSAKeyPairOutput_publicKey_ToDafny(nativeOutput.PublicKey), aws_cryptography_primitives_GenerateRSAKeyPairOutput_privateKey_ToDafny(nativeOutput.PrivateKey)) + }() + +} + +func GetRSAKeyModulusLengthInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.GetRSAKeyModulusLengthInput) AwsCryptographyPrimitivesTypes.GetRSAKeyModulusLengthInput { + + return func() AwsCryptographyPrimitivesTypes.GetRSAKeyModulusLengthInput { + + return AwsCryptographyPrimitivesTypes.Companion_GetRSAKeyModulusLengthInput_.Create_GetRSAKeyModulusLengthInput_(aws_cryptography_primitives_GetRSAKeyModulusLengthInput_publicKey_ToDafny(nativeInput.PublicKey)) + }() + +} + +func GetRSAKeyModulusLengthOutput_ToDafny(nativeOutput awscryptographyprimitivessmithygeneratedtypes.GetRSAKeyModulusLengthOutput) AwsCryptographyPrimitivesTypes.GetRSAKeyModulusLengthOutput { + + return func() AwsCryptographyPrimitivesTypes.GetRSAKeyModulusLengthOutput { + + return AwsCryptographyPrimitivesTypes.Companion_GetRSAKeyModulusLengthOutput_.Create_GetRSAKeyModulusLengthOutput_(aws_cryptography_primitives_GetRSAKeyModulusLengthOutput_length_ToDafny(nativeOutput.Length)) + }() + +} + +func RSADecryptInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.RSADecryptInput) AwsCryptographyPrimitivesTypes.RSADecryptInput { + + return func() AwsCryptographyPrimitivesTypes.RSADecryptInput { + + return AwsCryptographyPrimitivesTypes.Companion_RSADecryptInput_.Create_RSADecryptInput_(aws_cryptography_primitives_RSADecryptInput_padding_ToDafny(nativeInput.Padding), aws_cryptography_primitives_RSADecryptInput_privateKey_ToDafny(nativeInput.PrivateKey), aws_cryptography_primitives_RSADecryptInput_cipherText_ToDafny(nativeInput.CipherText)) + }() + +} + +func RSAEncryptInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.RSAEncryptInput) AwsCryptographyPrimitivesTypes.RSAEncryptInput { + + return func() AwsCryptographyPrimitivesTypes.RSAEncryptInput { + + return AwsCryptographyPrimitivesTypes.Companion_RSAEncryptInput_.Create_RSAEncryptInput_(aws_cryptography_primitives_RSAEncryptInput_padding_ToDafny(nativeInput.Padding), aws_cryptography_primitives_RSAEncryptInput_publicKey_ToDafny(nativeInput.PublicKey), aws_cryptography_primitives_RSAEncryptInput_plaintext_ToDafny(nativeInput.Plaintext)) + }() + +} + +func GenerateECDSASignatureKeyInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.GenerateECDSASignatureKeyInput) AwsCryptographyPrimitivesTypes.GenerateECDSASignatureKeyInput { + + return func() AwsCryptographyPrimitivesTypes.GenerateECDSASignatureKeyInput { + + return AwsCryptographyPrimitivesTypes.Companion_GenerateECDSASignatureKeyInput_.Create_GenerateECDSASignatureKeyInput_(aws_cryptography_primitives_GenerateECDSASignatureKeyInput_signatureAlgorithm_ToDafny(nativeInput.SignatureAlgorithm)) + }() + +} + +func GenerateECDSASignatureKeyOutput_ToDafny(nativeOutput awscryptographyprimitivessmithygeneratedtypes.GenerateECDSASignatureKeyOutput) AwsCryptographyPrimitivesTypes.GenerateECDSASignatureKeyOutput { + + return func() AwsCryptographyPrimitivesTypes.GenerateECDSASignatureKeyOutput { + + return AwsCryptographyPrimitivesTypes.Companion_GenerateECDSASignatureKeyOutput_.Create_GenerateECDSASignatureKeyOutput_(aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_signatureAlgorithm_ToDafny(nativeOutput.SignatureAlgorithm), aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_verificationKey_ToDafny(nativeOutput.VerificationKey), aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_signingKey_ToDafny(nativeOutput.SigningKey)) + }() + +} + +func ECDSASignInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.ECDSASignInput) AwsCryptographyPrimitivesTypes.ECDSASignInput { + + return func() AwsCryptographyPrimitivesTypes.ECDSASignInput { + + return AwsCryptographyPrimitivesTypes.Companion_ECDSASignInput_.Create_ECDSASignInput_(aws_cryptography_primitives_ECDSASignInput_signatureAlgorithm_ToDafny(nativeInput.SignatureAlgorithm), aws_cryptography_primitives_ECDSASignInput_signingKey_ToDafny(nativeInput.SigningKey), aws_cryptography_primitives_ECDSASignInput_message_ToDafny(nativeInput.Message)) + }() + +} + +func ECDSAVerifyInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.ECDSAVerifyInput) AwsCryptographyPrimitivesTypes.ECDSAVerifyInput { + + return func() AwsCryptographyPrimitivesTypes.ECDSAVerifyInput { + + return AwsCryptographyPrimitivesTypes.Companion_ECDSAVerifyInput_.Create_ECDSAVerifyInput_(aws_cryptography_primitives_ECDSAVerifyInput_signatureAlgorithm_ToDafny(nativeInput.SignatureAlgorithm), aws_cryptography_primitives_ECDSAVerifyInput_verificationKey_ToDafny(nativeInput.VerificationKey), aws_cryptography_primitives_ECDSAVerifyInput_message_ToDafny(nativeInput.Message), aws_cryptography_primitives_ECDSAVerifyInput_signature_ToDafny(nativeInput.Signature)) + }() + +} + +func GenerateECCKeyPairInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.GenerateECCKeyPairInput) AwsCryptographyPrimitivesTypes.GenerateECCKeyPairInput { + + return func() AwsCryptographyPrimitivesTypes.GenerateECCKeyPairInput { + + return AwsCryptographyPrimitivesTypes.Companion_GenerateECCKeyPairInput_.Create_GenerateECCKeyPairInput_(aws_cryptography_primitives_GenerateECCKeyPairInput_eccCurve_ToDafny(nativeInput.EccCurve)) + }() + +} + +func GenerateECCKeyPairOutput_ToDafny(nativeOutput awscryptographyprimitivessmithygeneratedtypes.GenerateECCKeyPairOutput) AwsCryptographyPrimitivesTypes.GenerateECCKeyPairOutput { + + return func() AwsCryptographyPrimitivesTypes.GenerateECCKeyPairOutput { + + return AwsCryptographyPrimitivesTypes.Companion_GenerateECCKeyPairOutput_.Create_GenerateECCKeyPairOutput_(aws_cryptography_primitives_GenerateECCKeyPairOutput_eccCurve_ToDafny(nativeOutput.EccCurve), aws_cryptography_primitives_GenerateECCKeyPairOutput_privateKey_ToDafny(nativeOutput.PrivateKey), aws_cryptography_primitives_GenerateECCKeyPairOutput_publicKey_ToDafny(nativeOutput.PublicKey)) + }() + +} + +func GetPublicKeyFromPrivateKeyInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.GetPublicKeyFromPrivateKeyInput) AwsCryptographyPrimitivesTypes.GetPublicKeyFromPrivateKeyInput { + + return func() AwsCryptographyPrimitivesTypes.GetPublicKeyFromPrivateKeyInput { + + return AwsCryptographyPrimitivesTypes.Companion_GetPublicKeyFromPrivateKeyInput_.Create_GetPublicKeyFromPrivateKeyInput_(aws_cryptography_primitives_GetPublicKeyFromPrivateKeyInput_eccCurve_ToDafny(nativeInput.EccCurve), aws_cryptography_primitives_GetPublicKeyFromPrivateKeyInput_privateKey_ToDafny(nativeInput.PrivateKey)) + }() + +} + +func GetPublicKeyFromPrivateKeyOutput_ToDafny(nativeOutput awscryptographyprimitivessmithygeneratedtypes.GetPublicKeyFromPrivateKeyOutput) AwsCryptographyPrimitivesTypes.GetPublicKeyFromPrivateKeyOutput { + + return func() AwsCryptographyPrimitivesTypes.GetPublicKeyFromPrivateKeyOutput { + + return AwsCryptographyPrimitivesTypes.Companion_GetPublicKeyFromPrivateKeyOutput_.Create_GetPublicKeyFromPrivateKeyOutput_(aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_eccCurve_ToDafny(nativeOutput.EccCurve), aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_privateKey_ToDafny(nativeOutput.PrivateKey), aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_publicKey_ToDafny(nativeOutput.PublicKey)) + }() + +} + +func ValidatePublicKeyInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.ValidatePublicKeyInput) AwsCryptographyPrimitivesTypes.ValidatePublicKeyInput { + + return func() AwsCryptographyPrimitivesTypes.ValidatePublicKeyInput { + + return AwsCryptographyPrimitivesTypes.Companion_ValidatePublicKeyInput_.Create_ValidatePublicKeyInput_(aws_cryptography_primitives_ValidatePublicKeyInput_eccCurve_ToDafny(nativeInput.EccCurve), aws_cryptography_primitives_ValidatePublicKeyInput_publicKey_ToDafny(nativeInput.PublicKey)) + }() + +} + +func ValidatePublicKeyOutput_ToDafny(nativeOutput awscryptographyprimitivessmithygeneratedtypes.ValidatePublicKeyOutput) AwsCryptographyPrimitivesTypes.ValidatePublicKeyOutput { + + return func() AwsCryptographyPrimitivesTypes.ValidatePublicKeyOutput { + + return AwsCryptographyPrimitivesTypes.Companion_ValidatePublicKeyOutput_.Create_ValidatePublicKeyOutput_(aws_cryptography_primitives_ValidatePublicKeyOutput_success_ToDafny(nativeOutput.Success)) + }() + +} + +func DeriveSharedSecretInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.DeriveSharedSecretInput) AwsCryptographyPrimitivesTypes.DeriveSharedSecretInput { + + return func() AwsCryptographyPrimitivesTypes.DeriveSharedSecretInput { + + return AwsCryptographyPrimitivesTypes.Companion_DeriveSharedSecretInput_.Create_DeriveSharedSecretInput_(aws_cryptography_primitives_DeriveSharedSecretInput_eccCurve_ToDafny(nativeInput.EccCurve), aws_cryptography_primitives_DeriveSharedSecretInput_privateKey_ToDafny(nativeInput.PrivateKey), aws_cryptography_primitives_DeriveSharedSecretInput_publicKey_ToDafny(nativeInput.PublicKey)) + }() + +} + +func DeriveSharedSecretOutput_ToDafny(nativeOutput awscryptographyprimitivessmithygeneratedtypes.DeriveSharedSecretOutput) AwsCryptographyPrimitivesTypes.DeriveSharedSecretOutput { + + return func() AwsCryptographyPrimitivesTypes.DeriveSharedSecretOutput { + + return AwsCryptographyPrimitivesTypes.Companion_DeriveSharedSecretOutput_.Create_DeriveSharedSecretOutput_(aws_cryptography_primitives_DeriveSharedSecretOutput_sharedSecret_ToDafny(nativeOutput.SharedSecret)) + }() + +} + +func CompressPublicKeyInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.CompressPublicKeyInput) AwsCryptographyPrimitivesTypes.CompressPublicKeyInput { + + return func() AwsCryptographyPrimitivesTypes.CompressPublicKeyInput { + + return AwsCryptographyPrimitivesTypes.Companion_CompressPublicKeyInput_.Create_CompressPublicKeyInput_(aws_cryptography_primitives_CompressPublicKeyInput_publicKey_ToDafny(nativeInput.PublicKey), aws_cryptography_primitives_CompressPublicKeyInput_eccCurve_ToDafny(nativeInput.EccCurve)) + }() + +} + +func CompressPublicKeyOutput_ToDafny(nativeOutput awscryptographyprimitivessmithygeneratedtypes.CompressPublicKeyOutput) AwsCryptographyPrimitivesTypes.CompressPublicKeyOutput { + + return func() AwsCryptographyPrimitivesTypes.CompressPublicKeyOutput { + + return AwsCryptographyPrimitivesTypes.Companion_CompressPublicKeyOutput_.Create_CompressPublicKeyOutput_(aws_cryptography_primitives_CompressPublicKeyOutput_compressedPublicKey_ToDafny(nativeOutput.CompressedPublicKey)) + }() + +} + +func DecompressPublicKeyInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.DecompressPublicKeyInput) AwsCryptographyPrimitivesTypes.DecompressPublicKeyInput { + + return func() AwsCryptographyPrimitivesTypes.DecompressPublicKeyInput { + + return AwsCryptographyPrimitivesTypes.Companion_DecompressPublicKeyInput_.Create_DecompressPublicKeyInput_(aws_cryptography_primitives_DecompressPublicKeyInput_compressedPublicKey_ToDafny(nativeInput.CompressedPublicKey), aws_cryptography_primitives_DecompressPublicKeyInput_eccCurve_ToDafny(nativeInput.EccCurve)) + }() + +} + +func DecompressPublicKeyOutput_ToDafny(nativeOutput awscryptographyprimitivessmithygeneratedtypes.DecompressPublicKeyOutput) AwsCryptographyPrimitivesTypes.DecompressPublicKeyOutput { + + return func() AwsCryptographyPrimitivesTypes.DecompressPublicKeyOutput { + + return AwsCryptographyPrimitivesTypes.Companion_DecompressPublicKeyOutput_.Create_DecompressPublicKeyOutput_(aws_cryptography_primitives_DecompressPublicKeyOutput_publicKey_ToDafny(nativeOutput.PublicKey)) + }() + +} + +func ParsePublicKeyInput_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.ParsePublicKeyInput) AwsCryptographyPrimitivesTypes.ParsePublicKeyInput { + + return func() AwsCryptographyPrimitivesTypes.ParsePublicKeyInput { + + return AwsCryptographyPrimitivesTypes.Companion_ParsePublicKeyInput_.Create_ParsePublicKeyInput_(aws_cryptography_primitives_ParsePublicKeyInput_publicKey_ToDafny(nativeInput.PublicKey)) + }() + +} + +func ParsePublicKeyOutput_ToDafny(nativeOutput awscryptographyprimitivessmithygeneratedtypes.ParsePublicKeyOutput) AwsCryptographyPrimitivesTypes.ParsePublicKeyOutput { + + return func() AwsCryptographyPrimitivesTypes.ParsePublicKeyOutput { + + return AwsCryptographyPrimitivesTypes.Companion_ParsePublicKeyOutput_.Create_ParsePublicKeyOutput_(aws_cryptography_primitives_ParsePublicKeyOutput_publicKey_ToDafny(nativeOutput.PublicKey)) + }() + +} + +func AwsCryptographicPrimitivesError_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.AwsCryptographicPrimitivesError) AwsCryptographyPrimitivesTypes.Error { + return func() AwsCryptographyPrimitivesTypes.Error { + + return AwsCryptographyPrimitivesTypes.Companion_Error_.Create_AwsCryptographicPrimitivesError_(aws_cryptography_primitives_AwsCryptographicPrimitivesError_message_ToDafny(nativeInput.Message)) + }() + +} + +func CollectionOfErrors_Input_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.CollectionOfErrors) AwsCryptographyPrimitivesTypes.Error { + var e []interface{} + for _, i2 := range nativeInput.ListOfErrors { + e = append(e, Error_ToDafny(i2)) + } + return AwsCryptographyPrimitivesTypes.Companion_Error_.Create_CollectionOfErrors_(dafny.SeqOf(e...), dafny.SeqOfChars([]dafny.Char(nativeInput.Message)...)) +} +func OpaqueError_Input_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.OpaqueError) AwsCryptographyPrimitivesTypes.Error { + return AwsCryptographyPrimitivesTypes.Companion_Error_.Create_Opaque_(nativeInput.ErrObject) +} + +func Error_ToDafny(err error) AwsCryptographyPrimitivesTypes.Error { + switch err.(type) { + // Service Errors + case awscryptographyprimitivessmithygeneratedtypes.AwsCryptographicPrimitivesError: + return AwsCryptographicPrimitivesError_ToDafny(err.(awscryptographyprimitivessmithygeneratedtypes.AwsCryptographicPrimitivesError)) + + //DependentErrors + + //Unmodelled Errors + case awscryptographyprimitivessmithygeneratedtypes.CollectionOfErrors: + return CollectionOfErrors_Input_ToDafny(err.(awscryptographyprimitivessmithygeneratedtypes.CollectionOfErrors)) + + default: + error, ok := err.(awscryptographyprimitivessmithygeneratedtypes.OpaqueError) + if !ok { + panic("Error is not an OpaqueError") + } + return OpaqueError_Input_ToDafny(error) + } +} + +func CryptoConfig_ToDafny(nativeInput awscryptographyprimitivessmithygeneratedtypes.CryptoConfig) AwsCryptographyPrimitivesTypes.CryptoConfig { + return func() AwsCryptographyPrimitivesTypes.CryptoConfig { + + return AwsCryptographyPrimitivesTypes.Companion_CryptoConfig_.Create_CryptoConfig_() + }() + +} + +func Aws_cryptography_primitives_GenerateRandomBytesOutput_data_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_AESDecryptInput_key_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_ECDSAVerifyInput_message_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_DeriveSharedSecretInput_publicKey_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey) AwsCryptographyPrimitivesTypes.ECCPublicKey { + return func() AwsCryptographyPrimitivesTypes.ECCPublicKey { + + return AwsCryptographyPrimitivesTypes.Companion_ECCPublicKey_.Create_ECCPublicKey_(aws_cryptography_primitives_ECCPublicKey_der_ToDafny(input.Der)) + }() +} + +func aws_cryptography_primitives_ECDSAVerifyInput_signatureAlgorithm_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm) AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm { + return func() AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDSASignatureAlgorithm_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm) + }() +} + +func aws_cryptography_primitives_AESEncryptInput_iv_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_RSADecryptInput_privateKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_HkdfInput_expectedLength_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func Aws_cryptography_primitives_ECDSAVerifyOutput_success_ToDafny(input bool) bool { + return func() bool { + + return input + }() +} + +func Aws_cryptography_primitives_HkdfOutput_okm_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_HkdfExpandInput_expectedLength_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func aws_cryptography_primitives_GenerateECCKeyPairOutput_publicKey_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey) AwsCryptographyPrimitivesTypes.ECCPublicKey { + return func() AwsCryptographyPrimitivesTypes.ECCPublicKey { + + return AwsCryptographyPrimitivesTypes.Companion_ECCPublicKey_.Create_ECCPublicKey_(aws_cryptography_primitives_ECCPublicKey_der_ToDafny(input.Der)) + }() +} + +func aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_publicKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_HMacInput_digestAlgorithm_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm) AwsCryptographyPrimitivesTypes.DigestAlgorithm { + return func() AwsCryptographyPrimitivesTypes.DigestAlgorithm { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + }() +} + +func Aws_cryptography_primitives_AESDecryptOutput_plaintext_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_ValidatePublicKeyInput_publicKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_GenerateRandomBytesInput_length_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func aws_cryptography_primitives_AESDecryptInput_authTag_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_RSAEncryptInput_plaintext_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func Aws_cryptography_primitives_KdfCtrOutput_okm_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_KdfCtrInput_ikm_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_ParsePublicKeyOutput_publicKey_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey) AwsCryptographyPrimitivesTypes.ECCPublicKey { + return func() AwsCryptographyPrimitivesTypes.ECCPublicKey { + + return AwsCryptographyPrimitivesTypes.Companion_ECCPublicKey_.Create_ECCPublicKey_(aws_cryptography_primitives_ECCPublicKey_der_ToDafny(input.Der)) + }() +} + +func aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_eccCurve_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec) AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + return func() AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + }() +} + +func aws_cryptography_primitives_HkdfExtractInput_ikm_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_GetRSAKeyModulusLengthOutput_length_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func aws_cryptography_primitives_KdfCtrInput_purpose_ToDafny(input []byte) Wrappers.Option { + return func() Wrappers.Option { + var v []interface{} + if input == nil { + return Wrappers.Companion_Option_.Create_None_() + } + for _, e := range input { + v = append(v, e) + } + return Wrappers.Companion_Option_.Create_Some_(dafny.SeqOf(v...)) + }() +} + +func aws_cryptography_primitives_AesKdfCtrInput_expectedLength_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func aws_cryptography_primitives_RSAPublicKey_lengthBits_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_privateKey_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey) AwsCryptographyPrimitivesTypes.ECCPrivateKey { + return func() AwsCryptographyPrimitivesTypes.ECCPrivateKey { + + return AwsCryptographyPrimitivesTypes.Companion_ECCPrivateKey_.Create_ECCPrivateKey_(aws_cryptography_primitives_ECCPrivateKey_pem_ToDafny(input.Pem)) + }() +} + +func aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_signingKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_RSADecryptInput_cipherText_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_AESEncryptInput_aad_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_DecompressPublicKeyInput_eccCurve_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec) AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + return func() AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + }() +} + +func Aws_cryptography_primitives_ECDSASignOutput_signature_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_ValidatePublicKeyInput_eccCurve_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec) AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + return func() AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + }() +} + +func aws_cryptography_primitives_DeriveSharedSecretInput_eccCurve_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec) AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + return func() AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + }() +} + +func aws_cryptography_primitives_AES_GCM_ivLength_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func aws_cryptography_primitives_HkdfInput_info_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_HkdfExpandInput_info_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_HMacInput_key_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func Aws_cryptography_primitives_DigestOutput_digest_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_AESEncryptOutput_cipherText_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_AESEncryptInput_key_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_RSAPrivateKey_lengthBits_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func aws_cryptography_primitives_GenerateRSAKeyPairInput_lengthBits_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func aws_cryptography_primitives_DigestInput_message_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_RSAPublicKey_pem_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_ParsePublicKeyInput_publicKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_HkdfExpandInput_prk_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_GetRSAKeyModulusLengthInput_publicKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_GenerateRSAKeyPairOutput_publicKey_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.RSAPublicKey) AwsCryptographyPrimitivesTypes.RSAPublicKey { + return func() AwsCryptographyPrimitivesTypes.RSAPublicKey { + + return AwsCryptographyPrimitivesTypes.Companion_RSAPublicKey_.Create_RSAPublicKey_(aws_cryptography_primitives_RSAPublicKey_lengthBits_ToDafny(input.LengthBits), aws_cryptography_primitives_RSAPublicKey_pem_ToDafny(input.Pem)) + }() +} + +func aws_cryptography_primitives_AESEncryptInput_msg_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_DecompressPublicKeyInput_compressedPublicKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_RSAEncryptInput_publicKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_RSAPrivateKey_pem_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_GenerateRSAKeyPairOutput_privateKey_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.RSAPrivateKey) AwsCryptographyPrimitivesTypes.RSAPrivateKey { + return func() AwsCryptographyPrimitivesTypes.RSAPrivateKey { + + return AwsCryptographyPrimitivesTypes.Companion_RSAPrivateKey_.Create_RSAPrivateKey_(aws_cryptography_primitives_RSAPrivateKey_lengthBits_ToDafny(input.LengthBits), aws_cryptography_primitives_RSAPrivateKey_pem_ToDafny(input.Pem)) + }() +} + +func aws_cryptography_primitives_AESEncryptOutput_authTag_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_ECDSASignInput_signingKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_ECDSAVerifyInput_verificationKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_AesKdfCtrInput_nonce_ToDafny(input []byte) Wrappers.Option { + return func() Wrappers.Option { + var v []interface{} + if input == nil { + return Wrappers.Companion_Option_.Create_None_() + } + for _, e := range input { + v = append(v, e) + } + return Wrappers.Companion_Option_.Create_Some_(dafny.SeqOf(v...)) + }() +} + +func aws_cryptography_primitives_HMacInput_message_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_CompressPublicKeyInput_publicKey_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey) AwsCryptographyPrimitivesTypes.ECCPublicKey { + return func() AwsCryptographyPrimitivesTypes.ECCPublicKey { + + return AwsCryptographyPrimitivesTypes.Companion_ECCPublicKey_.Create_ECCPublicKey_(aws_cryptography_primitives_ECCPublicKey_der_ToDafny(input.Der)) + }() +} + +func aws_cryptography_primitives_DigestInput_digestAlgorithm_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm) AwsCryptographyPrimitivesTypes.DigestAlgorithm { + return func() AwsCryptographyPrimitivesTypes.DigestAlgorithm { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + }() +} + +func aws_cryptography_primitives_AES_GCM_tagLength_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func aws_cryptography_primitives_ValidatePublicKeyOutput_success_ToDafny(input bool) bool { + return func() bool { + + return input + }() +} + +func aws_cryptography_primitives_ECDSASignInput_signatureAlgorithm_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm) AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm { + return func() AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDSASignatureAlgorithm_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm) + }() +} + +func aws_cryptography_primitives_RSADecryptInput_padding_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.RSAPaddingMode) AwsCryptographyPrimitivesTypes.RSAPaddingMode { + return func() AwsCryptographyPrimitivesTypes.RSAPaddingMode { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_RSAPaddingMode_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.RSAPaddingMode) + }() +} + +func Aws_cryptography_primitives_HkdfExtractOutput_prk_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func Aws_cryptography_primitives_RSADecryptOutput_plaintext_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_GetPublicKeyFromPrivateKeyInput_privateKey_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey) AwsCryptographyPrimitivesTypes.ECCPrivateKey { + return func() AwsCryptographyPrimitivesTypes.ECCPrivateKey { + + return AwsCryptographyPrimitivesTypes.Companion_ECCPrivateKey_.Create_ECCPrivateKey_(aws_cryptography_primitives_ECCPrivateKey_pem_ToDafny(input.Pem)) + }() +} + +func aws_cryptography_primitives_ECDSAVerifyInput_signature_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_AESDecryptInput_encAlg_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.AES_GCM) AwsCryptographyPrimitivesTypes.AES__GCM { + return func() AwsCryptographyPrimitivesTypes.AES__GCM { + + return AwsCryptographyPrimitivesTypes.Companion_AES__GCM_.Create_AES__GCM_(aws_cryptography_primitives_AES_GCM_keyLength_ToDafny(input.KeyLength), aws_cryptography_primitives_AES_GCM_tagLength_ToDafny(input.TagLength), aws_cryptography_primitives_AES_GCM_ivLength_ToDafny(input.IvLength)) + }() +} + +func aws_cryptography_primitives_HkdfExpandInput_digestAlgorithm_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm) AwsCryptographyPrimitivesTypes.DigestAlgorithm { + return func() AwsCryptographyPrimitivesTypes.DigestAlgorithm { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + }() +} + +func Aws_cryptography_primitives_HkdfExpandOutput_okm_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_GetPublicKeyFromPrivateKeyInput_eccCurve_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec) AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + return func() AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + }() +} + +func aws_cryptography_primitives_RSAEncryptInput_padding_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.RSAPaddingMode) AwsCryptographyPrimitivesTypes.RSAPaddingMode { + return func() AwsCryptographyPrimitivesTypes.RSAPaddingMode { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_RSAPaddingMode_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.RSAPaddingMode) + }() +} + +func aws_cryptography_primitives_DeriveSharedSecretInput_privateKey_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey) AwsCryptographyPrimitivesTypes.ECCPrivateKey { + return func() AwsCryptographyPrimitivesTypes.ECCPrivateKey { + + return AwsCryptographyPrimitivesTypes.Companion_ECCPrivateKey_.Create_ECCPrivateKey_(aws_cryptography_primitives_ECCPrivateKey_pem_ToDafny(input.Pem)) + }() +} + +func aws_cryptography_primitives_ECCPublicKey_der_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_HkdfInput_ikm_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_GenerateECDSASignatureKeyInput_signatureAlgorithm_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm) AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm { + return func() AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDSASignatureAlgorithm_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm) + }() +} + +func aws_cryptography_primitives_AESDecryptInput_cipherTxt_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_KdfCtrInput_digestAlgorithm_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm) AwsCryptographyPrimitivesTypes.DigestAlgorithm { + return func() AwsCryptographyPrimitivesTypes.DigestAlgorithm { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + }() +} + +func aws_cryptography_primitives_HkdfExtractInput_salt_ToDafny(input []byte) Wrappers.Option { + return func() Wrappers.Option { + var v []interface{} + if input == nil { + return Wrappers.Companion_Option_.Create_None_() + } + for _, e := range input { + v = append(v, e) + } + return Wrappers.Companion_Option_.Create_Some_(dafny.SeqOf(v...)) + }() +} + +func Aws_cryptography_primitives_HMacOutput_digest_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_KdfCtrInput_nonce_ToDafny(input []byte) Wrappers.Option { + return func() Wrappers.Option { + var v []interface{} + if input == nil { + return Wrappers.Companion_Option_.Create_None_() + } + for _, e := range input { + v = append(v, e) + } + return Wrappers.Companion_Option_.Create_Some_(dafny.SeqOf(v...)) + }() +} + +func aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_signatureAlgorithm_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm) AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm { + return func() AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDSASignatureAlgorithm_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm) + }() +} + +func aws_cryptography_primitives_CompressPublicKeyInput_eccCurve_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec) AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + return func() AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + }() +} + +func aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_verificationKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_DecompressPublicKeyOutput_publicKey_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey) AwsCryptographyPrimitivesTypes.ECCPublicKey { + return func() AwsCryptographyPrimitivesTypes.ECCPublicKey { + + return AwsCryptographyPrimitivesTypes.Companion_ECCPublicKey_.Create_ECCPublicKey_(aws_cryptography_primitives_ECCPublicKey_der_ToDafny(input.Der)) + }() +} + +func aws_cryptography_primitives_HkdfExtractInput_digestAlgorithm_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm) AwsCryptographyPrimitivesTypes.DigestAlgorithm { + return func() AwsCryptographyPrimitivesTypes.DigestAlgorithm { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + }() +} + +func Aws_cryptography_primitives_RSAEncryptOutput_cipherText_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_GenerateECCKeyPairOutput_eccCurve_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec) AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + return func() AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + }() +} + +func aws_cryptography_primitives_HkdfInput_salt_ToDafny(input []byte) Wrappers.Option { + return func() Wrappers.Option { + var v []interface{} + if input == nil { + return Wrappers.Companion_Option_.Create_None_() + } + for _, e := range input { + v = append(v, e) + } + return Wrappers.Companion_Option_.Create_Some_(dafny.SeqOf(v...)) + }() +} + +func aws_cryptography_primitives_ECCPrivateKey_pem_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_AESDecryptInput_aad_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_AwsCryptographicPrimitivesError_message_ToDafny(input string) dafny.Sequence { + return func() dafny.Sequence { + + return dafny.SeqOfChars([]dafny.Char(input)...) + }() +} + +func aws_cryptography_primitives_AES_GCM_keyLength_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func aws_cryptography_primitives_HkdfInput_digestAlgorithm_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm) AwsCryptographyPrimitivesTypes.DigestAlgorithm { + return func() AwsCryptographyPrimitivesTypes.DigestAlgorithm { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + }() +} + +func aws_cryptography_primitives_AesKdfCtrInput_ikm_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_GenerateECCKeyPairInput_eccCurve_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec) AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + return func() AwsCryptographyPrimitivesTypes.ECDHCurveSpec { + + var index int + for _, enumVal := range input.Values() { + index++ + if enumVal == input { + break + } + } + var enum interface{} + for allEnums, i := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()), 0; i < index; i++ { + var ok bool + enum, ok = allEnums() + if !ok { + break + } + } + return enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + }() +} + +func aws_cryptography_primitives_AESEncryptInput_encAlg_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.AES_GCM) AwsCryptographyPrimitivesTypes.AES__GCM { + return func() AwsCryptographyPrimitivesTypes.AES__GCM { + + return AwsCryptographyPrimitivesTypes.Companion_AES__GCM_.Create_AES__GCM_(aws_cryptography_primitives_AES_GCM_keyLength_ToDafny(input.KeyLength), aws_cryptography_primitives_AES_GCM_tagLength_ToDafny(input.TagLength), aws_cryptography_primitives_AES_GCM_ivLength_ToDafny(input.IvLength)) + }() +} + +func aws_cryptography_primitives_CompressPublicKeyOutput_compressedPublicKey_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_AESDecryptInput_iv_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_KdfCtrInput_expectedLength_ToDafny(input int32) int32 { + return func() int32 { + + return input + }() +} + +func aws_cryptography_primitives_ECDSASignInput_message_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_DeriveSharedSecretOutput_sharedSecret_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func Aws_cryptography_primitives_AesKdfCtrOutput_okm_ToDafny(input []byte) dafny.Sequence { + return func() dafny.Sequence { + var v []interface{} + if input == nil { + return nil + } + for _, e := range input { + v = append(v, e) + } + return dafny.SeqOf(v...) + }() +} + +func aws_cryptography_primitives_GenerateECCKeyPairOutput_privateKey_ToDafny(input awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey) AwsCryptographyPrimitivesTypes.ECCPrivateKey { + return func() AwsCryptographyPrimitivesTypes.ECCPrivateKey { + + return AwsCryptographyPrimitivesTypes.Companion_ECCPrivateKey_.Create_ECCPrivateKey_(aws_cryptography_primitives_ECCPrivateKey_pem_ToDafny(input.Pem)) + }() +} diff --git a/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/awscryptographyprimitivessmithygenerated/to_native.go b/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/awscryptographyprimitivessmithygenerated/to_native.go new file mode 100644 index 000000000..b33c76b63 --- /dev/null +++ b/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/awscryptographyprimitivessmithygenerated/to_native.go @@ -0,0 +1,1811 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package awscryptographyprimitivessmithygenerated + +import ( + "github.com/aws/aws-cryptographic-material-providers-library/primitives/AwsCryptographyPrimitivesTypes" + "github.com/aws/aws-cryptographic-material-providers-library/primitives/awscryptographyprimitivessmithygeneratedtypes" + "github.com/dafny-lang/DafnyRuntimeGo/v4/dafny" +) + +func GenerateRandomBytesInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.GenerateRandomBytesInput) awscryptographyprimitivessmithygeneratedtypes.GenerateRandomBytesInput { + + return awscryptographyprimitivessmithygeneratedtypes.GenerateRandomBytesInput{Length: aws_cryptography_primitives_GenerateRandomBytesInput_length_FromDafny(dafnyInput.Dtor_length())} + +} + +func DigestInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.DigestInput) awscryptographyprimitivessmithygeneratedtypes.DigestInput { + + return awscryptographyprimitivessmithygeneratedtypes.DigestInput{DigestAlgorithm: aws_cryptography_primitives_DigestInput_digestAlgorithm_FromDafny(dafnyInput.Dtor_digestAlgorithm()), + Message: aws_cryptography_primitives_DigestInput_message_FromDafny(dafnyInput.Dtor_message()), + } + +} + +func HMacInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.HMacInput) awscryptographyprimitivessmithygeneratedtypes.HMacInput { + + return awscryptographyprimitivessmithygeneratedtypes.HMacInput{DigestAlgorithm: aws_cryptography_primitives_HMacInput_digestAlgorithm_FromDafny(dafnyInput.Dtor_digestAlgorithm()), + Key: aws_cryptography_primitives_HMacInput_key_FromDafny(dafnyInput.Dtor_key()), + Message: aws_cryptography_primitives_HMacInput_message_FromDafny(dafnyInput.Dtor_message()), + } + +} + +func HkdfExtractInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.HkdfExtractInput) awscryptographyprimitivessmithygeneratedtypes.HkdfExtractInput { + + return awscryptographyprimitivessmithygeneratedtypes.HkdfExtractInput{DigestAlgorithm: aws_cryptography_primitives_HkdfExtractInput_digestAlgorithm_FromDafny(dafnyInput.Dtor_digestAlgorithm()), + Salt: aws_cryptography_primitives_HkdfExtractInput_salt_FromDafny(dafnyInput.Dtor_salt().UnwrapOr(nil)), + Ikm: aws_cryptography_primitives_HkdfExtractInput_ikm_FromDafny(dafnyInput.Dtor_ikm()), + } + +} + +func HkdfExpandInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.HkdfExpandInput) awscryptographyprimitivessmithygeneratedtypes.HkdfExpandInput { + + return awscryptographyprimitivessmithygeneratedtypes.HkdfExpandInput{DigestAlgorithm: aws_cryptography_primitives_HkdfExpandInput_digestAlgorithm_FromDafny(dafnyInput.Dtor_digestAlgorithm()), + Prk: aws_cryptography_primitives_HkdfExpandInput_prk_FromDafny(dafnyInput.Dtor_prk()), + Info: aws_cryptography_primitives_HkdfExpandInput_info_FromDafny(dafnyInput.Dtor_info()), + ExpectedLength: aws_cryptography_primitives_HkdfExpandInput_expectedLength_FromDafny(dafnyInput.Dtor_expectedLength()), + } + +} + +func HkdfInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.HkdfInput) awscryptographyprimitivessmithygeneratedtypes.HkdfInput { + + return awscryptographyprimitivessmithygeneratedtypes.HkdfInput{DigestAlgorithm: aws_cryptography_primitives_HkdfInput_digestAlgorithm_FromDafny(dafnyInput.Dtor_digestAlgorithm()), + Salt: aws_cryptography_primitives_HkdfInput_salt_FromDafny(dafnyInput.Dtor_salt().UnwrapOr(nil)), + Ikm: aws_cryptography_primitives_HkdfInput_ikm_FromDafny(dafnyInput.Dtor_ikm()), + Info: aws_cryptography_primitives_HkdfInput_info_FromDafny(dafnyInput.Dtor_info()), + ExpectedLength: aws_cryptography_primitives_HkdfInput_expectedLength_FromDafny(dafnyInput.Dtor_expectedLength()), + } + +} + +func KdfCtrInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.KdfCtrInput) awscryptographyprimitivessmithygeneratedtypes.KdfCtrInput { + + return awscryptographyprimitivessmithygeneratedtypes.KdfCtrInput{DigestAlgorithm: aws_cryptography_primitives_KdfCtrInput_digestAlgorithm_FromDafny(dafnyInput.Dtor_digestAlgorithm()), + Ikm: aws_cryptography_primitives_KdfCtrInput_ikm_FromDafny(dafnyInput.Dtor_ikm()), + ExpectedLength: aws_cryptography_primitives_KdfCtrInput_expectedLength_FromDafny(dafnyInput.Dtor_expectedLength()), + Purpose: aws_cryptography_primitives_KdfCtrInput_purpose_FromDafny(dafnyInput.Dtor_purpose().UnwrapOr(nil)), + Nonce: aws_cryptography_primitives_KdfCtrInput_nonce_FromDafny(dafnyInput.Dtor_nonce().UnwrapOr(nil)), + } + +} + +func AesKdfCtrInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.AesKdfCtrInput) awscryptographyprimitivessmithygeneratedtypes.AesKdfCtrInput { + + return awscryptographyprimitivessmithygeneratedtypes.AesKdfCtrInput{Ikm: aws_cryptography_primitives_AesKdfCtrInput_ikm_FromDafny(dafnyInput.Dtor_ikm()), + ExpectedLength: aws_cryptography_primitives_AesKdfCtrInput_expectedLength_FromDafny(dafnyInput.Dtor_expectedLength()), + Nonce: aws_cryptography_primitives_AesKdfCtrInput_nonce_FromDafny(dafnyInput.Dtor_nonce().UnwrapOr(nil)), + } + +} + +func AESEncryptInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.AESEncryptInput) awscryptographyprimitivessmithygeneratedtypes.AESEncryptInput { + + return awscryptographyprimitivessmithygeneratedtypes.AESEncryptInput{EncAlg: aws_cryptography_primitives_AESEncryptInput_encAlg_FromDafny(dafnyInput.Dtor_encAlg()), + Iv: aws_cryptography_primitives_AESEncryptInput_iv_FromDafny(dafnyInput.Dtor_iv()), + Key: aws_cryptography_primitives_AESEncryptInput_key_FromDafny(dafnyInput.Dtor_key()), + Msg: aws_cryptography_primitives_AESEncryptInput_msg_FromDafny(dafnyInput.Dtor_msg()), + Aad: aws_cryptography_primitives_AESEncryptInput_aad_FromDafny(dafnyInput.Dtor_aad()), + } + +} + +func AESEncryptOutput_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.AESEncryptOutput) awscryptographyprimitivessmithygeneratedtypes.AESEncryptOutput { + + return awscryptographyprimitivessmithygeneratedtypes.AESEncryptOutput{CipherText: aws_cryptography_primitives_AESEncryptOutput_cipherText_FromDafny(dafnyOutput.Dtor_cipherText()), + AuthTag: aws_cryptography_primitives_AESEncryptOutput_authTag_FromDafny(dafnyOutput.Dtor_authTag()), + } + +} + +func AESDecryptInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.AESDecryptInput) awscryptographyprimitivessmithygeneratedtypes.AESDecryptInput { + + return awscryptographyprimitivessmithygeneratedtypes.AESDecryptInput{EncAlg: aws_cryptography_primitives_AESDecryptInput_encAlg_FromDafny(dafnyInput.Dtor_encAlg()), + Key: aws_cryptography_primitives_AESDecryptInput_key_FromDafny(dafnyInput.Dtor_key()), + CipherTxt: aws_cryptography_primitives_AESDecryptInput_cipherTxt_FromDafny(dafnyInput.Dtor_cipherTxt()), + AuthTag: aws_cryptography_primitives_AESDecryptInput_authTag_FromDafny(dafnyInput.Dtor_authTag()), + Iv: aws_cryptography_primitives_AESDecryptInput_iv_FromDafny(dafnyInput.Dtor_iv()), + Aad: aws_cryptography_primitives_AESDecryptInput_aad_FromDafny(dafnyInput.Dtor_aad()), + } + +} + +func GenerateRSAKeyPairInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.GenerateRSAKeyPairInput) awscryptographyprimitivessmithygeneratedtypes.GenerateRSAKeyPairInput { + + return awscryptographyprimitivessmithygeneratedtypes.GenerateRSAKeyPairInput{LengthBits: aws_cryptography_primitives_GenerateRSAKeyPairInput_lengthBits_FromDafny(dafnyInput.Dtor_lengthBits())} + +} + +func GenerateRSAKeyPairOutput_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.GenerateRSAKeyPairOutput) awscryptographyprimitivessmithygeneratedtypes.GenerateRSAKeyPairOutput { + + return awscryptographyprimitivessmithygeneratedtypes.GenerateRSAKeyPairOutput{PublicKey: aws_cryptography_primitives_GenerateRSAKeyPairOutput_publicKey_FromDafny(dafnyOutput.Dtor_publicKey()), + PrivateKey: aws_cryptography_primitives_GenerateRSAKeyPairOutput_privateKey_FromDafny(dafnyOutput.Dtor_privateKey()), + } + +} + +func GetRSAKeyModulusLengthInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.GetRSAKeyModulusLengthInput) awscryptographyprimitivessmithygeneratedtypes.GetRSAKeyModulusLengthInput { + + return awscryptographyprimitivessmithygeneratedtypes.GetRSAKeyModulusLengthInput{PublicKey: aws_cryptography_primitives_GetRSAKeyModulusLengthInput_publicKey_FromDafny(dafnyInput.Dtor_publicKey())} + +} + +func GetRSAKeyModulusLengthOutput_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.GetRSAKeyModulusLengthOutput) awscryptographyprimitivessmithygeneratedtypes.GetRSAKeyModulusLengthOutput { + + return awscryptographyprimitivessmithygeneratedtypes.GetRSAKeyModulusLengthOutput{Length: aws_cryptography_primitives_GetRSAKeyModulusLengthOutput_length_FromDafny(dafnyOutput.Dtor_length())} + +} + +func RSADecryptInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.RSADecryptInput) awscryptographyprimitivessmithygeneratedtypes.RSADecryptInput { + + return awscryptographyprimitivessmithygeneratedtypes.RSADecryptInput{Padding: aws_cryptography_primitives_RSADecryptInput_padding_FromDafny(dafnyInput.Dtor_padding()), + PrivateKey: aws_cryptography_primitives_RSADecryptInput_privateKey_FromDafny(dafnyInput.Dtor_privateKey()), + CipherText: aws_cryptography_primitives_RSADecryptInput_cipherText_FromDafny(dafnyInput.Dtor_cipherText()), + } + +} + +func RSAEncryptInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.RSAEncryptInput) awscryptographyprimitivessmithygeneratedtypes.RSAEncryptInput { + + return awscryptographyprimitivessmithygeneratedtypes.RSAEncryptInput{Padding: aws_cryptography_primitives_RSAEncryptInput_padding_FromDafny(dafnyInput.Dtor_padding()), + PublicKey: aws_cryptography_primitives_RSAEncryptInput_publicKey_FromDafny(dafnyInput.Dtor_publicKey()), + Plaintext: aws_cryptography_primitives_RSAEncryptInput_plaintext_FromDafny(dafnyInput.Dtor_plaintext()), + } + +} + +func GenerateECDSASignatureKeyInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.GenerateECDSASignatureKeyInput) awscryptographyprimitivessmithygeneratedtypes.GenerateECDSASignatureKeyInput { + + return awscryptographyprimitivessmithygeneratedtypes.GenerateECDSASignatureKeyInput{SignatureAlgorithm: aws_cryptography_primitives_GenerateECDSASignatureKeyInput_signatureAlgorithm_FromDafny(dafnyInput.Dtor_signatureAlgorithm())} + +} + +func GenerateECDSASignatureKeyOutput_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.GenerateECDSASignatureKeyOutput) awscryptographyprimitivessmithygeneratedtypes.GenerateECDSASignatureKeyOutput { + + return awscryptographyprimitivessmithygeneratedtypes.GenerateECDSASignatureKeyOutput{SignatureAlgorithm: aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_signatureAlgorithm_FromDafny(dafnyOutput.Dtor_signatureAlgorithm()), + VerificationKey: aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_verificationKey_FromDafny(dafnyOutput.Dtor_verificationKey()), + SigningKey: aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_signingKey_FromDafny(dafnyOutput.Dtor_signingKey()), + } + +} + +func ECDSASignInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.ECDSASignInput) awscryptographyprimitivessmithygeneratedtypes.ECDSASignInput { + + return awscryptographyprimitivessmithygeneratedtypes.ECDSASignInput{SignatureAlgorithm: aws_cryptography_primitives_ECDSASignInput_signatureAlgorithm_FromDafny(dafnyInput.Dtor_signatureAlgorithm()), + SigningKey: aws_cryptography_primitives_ECDSASignInput_signingKey_FromDafny(dafnyInput.Dtor_signingKey()), + Message: aws_cryptography_primitives_ECDSASignInput_message_FromDafny(dafnyInput.Dtor_message()), + } + +} + +func ECDSAVerifyInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.ECDSAVerifyInput) awscryptographyprimitivessmithygeneratedtypes.ECDSAVerifyInput { + + return awscryptographyprimitivessmithygeneratedtypes.ECDSAVerifyInput{SignatureAlgorithm: aws_cryptography_primitives_ECDSAVerifyInput_signatureAlgorithm_FromDafny(dafnyInput.Dtor_signatureAlgorithm()), + VerificationKey: aws_cryptography_primitives_ECDSAVerifyInput_verificationKey_FromDafny(dafnyInput.Dtor_verificationKey()), + Message: aws_cryptography_primitives_ECDSAVerifyInput_message_FromDafny(dafnyInput.Dtor_message()), + Signature: aws_cryptography_primitives_ECDSAVerifyInput_signature_FromDafny(dafnyInput.Dtor_signature()), + } + +} + +func GenerateECCKeyPairInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.GenerateECCKeyPairInput) awscryptographyprimitivessmithygeneratedtypes.GenerateECCKeyPairInput { + + return awscryptographyprimitivessmithygeneratedtypes.GenerateECCKeyPairInput{EccCurve: aws_cryptography_primitives_GenerateECCKeyPairInput_eccCurve_FromDafny(dafnyInput.Dtor_eccCurve())} + +} + +func GenerateECCKeyPairOutput_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.GenerateECCKeyPairOutput) awscryptographyprimitivessmithygeneratedtypes.GenerateECCKeyPairOutput { + + return awscryptographyprimitivessmithygeneratedtypes.GenerateECCKeyPairOutput{EccCurve: aws_cryptography_primitives_GenerateECCKeyPairOutput_eccCurve_FromDafny(dafnyOutput.Dtor_eccCurve()), + PrivateKey: aws_cryptography_primitives_GenerateECCKeyPairOutput_privateKey_FromDafny(dafnyOutput.Dtor_privateKey()), + PublicKey: aws_cryptography_primitives_GenerateECCKeyPairOutput_publicKey_FromDafny(dafnyOutput.Dtor_publicKey()), + } + +} + +func GetPublicKeyFromPrivateKeyInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.GetPublicKeyFromPrivateKeyInput) awscryptographyprimitivessmithygeneratedtypes.GetPublicKeyFromPrivateKeyInput { + + return awscryptographyprimitivessmithygeneratedtypes.GetPublicKeyFromPrivateKeyInput{EccCurve: aws_cryptography_primitives_GetPublicKeyFromPrivateKeyInput_eccCurve_FromDafny(dafnyInput.Dtor_eccCurve()), + PrivateKey: aws_cryptography_primitives_GetPublicKeyFromPrivateKeyInput_privateKey_FromDafny(dafnyInput.Dtor_privateKey()), + } + +} + +func GetPublicKeyFromPrivateKeyOutput_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.GetPublicKeyFromPrivateKeyOutput) awscryptographyprimitivessmithygeneratedtypes.GetPublicKeyFromPrivateKeyOutput { + + return awscryptographyprimitivessmithygeneratedtypes.GetPublicKeyFromPrivateKeyOutput{EccCurve: aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_eccCurve_FromDafny(dafnyOutput.Dtor_eccCurve()), + PrivateKey: aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_privateKey_FromDafny(dafnyOutput.Dtor_privateKey()), + PublicKey: aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_publicKey_FromDafny(dafnyOutput.Dtor_publicKey()), + } + +} + +func ValidatePublicKeyInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.ValidatePublicKeyInput) awscryptographyprimitivessmithygeneratedtypes.ValidatePublicKeyInput { + + return awscryptographyprimitivessmithygeneratedtypes.ValidatePublicKeyInput{EccCurve: aws_cryptography_primitives_ValidatePublicKeyInput_eccCurve_FromDafny(dafnyInput.Dtor_eccCurve()), + PublicKey: aws_cryptography_primitives_ValidatePublicKeyInput_publicKey_FromDafny(dafnyInput.Dtor_publicKey()), + } + +} + +func ValidatePublicKeyOutput_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.ValidatePublicKeyOutput) awscryptographyprimitivessmithygeneratedtypes.ValidatePublicKeyOutput { + + return awscryptographyprimitivessmithygeneratedtypes.ValidatePublicKeyOutput{Success: aws_cryptography_primitives_ValidatePublicKeyOutput_success_FromDafny(dafnyOutput.Dtor_success())} + +} + +func DeriveSharedSecretInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.DeriveSharedSecretInput) awscryptographyprimitivessmithygeneratedtypes.DeriveSharedSecretInput { + + return awscryptographyprimitivessmithygeneratedtypes.DeriveSharedSecretInput{EccCurve: aws_cryptography_primitives_DeriveSharedSecretInput_eccCurve_FromDafny(dafnyInput.Dtor_eccCurve()), + PrivateKey: aws_cryptography_primitives_DeriveSharedSecretInput_privateKey_FromDafny(dafnyInput.Dtor_privateKey()), + PublicKey: aws_cryptography_primitives_DeriveSharedSecretInput_publicKey_FromDafny(dafnyInput.Dtor_publicKey()), + } + +} + +func DeriveSharedSecretOutput_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.DeriveSharedSecretOutput) awscryptographyprimitivessmithygeneratedtypes.DeriveSharedSecretOutput { + + return awscryptographyprimitivessmithygeneratedtypes.DeriveSharedSecretOutput{SharedSecret: aws_cryptography_primitives_DeriveSharedSecretOutput_sharedSecret_FromDafny(dafnyOutput.Dtor_sharedSecret())} + +} + +func CompressPublicKeyInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.CompressPublicKeyInput) awscryptographyprimitivessmithygeneratedtypes.CompressPublicKeyInput { + + return awscryptographyprimitivessmithygeneratedtypes.CompressPublicKeyInput{PublicKey: aws_cryptography_primitives_CompressPublicKeyInput_publicKey_FromDafny(dafnyInput.Dtor_publicKey()), + EccCurve: aws_cryptography_primitives_CompressPublicKeyInput_eccCurve_FromDafny(dafnyInput.Dtor_eccCurve()), + } + +} + +func CompressPublicKeyOutput_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.CompressPublicKeyOutput) awscryptographyprimitivessmithygeneratedtypes.CompressPublicKeyOutput { + + return awscryptographyprimitivessmithygeneratedtypes.CompressPublicKeyOutput{CompressedPublicKey: aws_cryptography_primitives_CompressPublicKeyOutput_compressedPublicKey_FromDafny(dafnyOutput.Dtor_compressedPublicKey())} + +} + +func DecompressPublicKeyInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.DecompressPublicKeyInput) awscryptographyprimitivessmithygeneratedtypes.DecompressPublicKeyInput { + + return awscryptographyprimitivessmithygeneratedtypes.DecompressPublicKeyInput{CompressedPublicKey: aws_cryptography_primitives_DecompressPublicKeyInput_compressedPublicKey_FromDafny(dafnyInput.Dtor_compressedPublicKey()), + EccCurve: aws_cryptography_primitives_DecompressPublicKeyInput_eccCurve_FromDafny(dafnyInput.Dtor_eccCurve()), + } + +} + +func DecompressPublicKeyOutput_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.DecompressPublicKeyOutput) awscryptographyprimitivessmithygeneratedtypes.DecompressPublicKeyOutput { + + return awscryptographyprimitivessmithygeneratedtypes.DecompressPublicKeyOutput{PublicKey: aws_cryptography_primitives_DecompressPublicKeyOutput_publicKey_FromDafny(dafnyOutput.Dtor_publicKey())} + +} + +func ParsePublicKeyInput_FromDafny(dafnyInput AwsCryptographyPrimitivesTypes.ParsePublicKeyInput) awscryptographyprimitivessmithygeneratedtypes.ParsePublicKeyInput { + + return awscryptographyprimitivessmithygeneratedtypes.ParsePublicKeyInput{PublicKey: aws_cryptography_primitives_ParsePublicKeyInput_publicKey_FromDafny(dafnyInput.Dtor_publicKey())} + +} + +func ParsePublicKeyOutput_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.ParsePublicKeyOutput) awscryptographyprimitivessmithygeneratedtypes.ParsePublicKeyOutput { + + return awscryptographyprimitivessmithygeneratedtypes.ParsePublicKeyOutput{PublicKey: aws_cryptography_primitives_ParsePublicKeyOutput_publicKey_FromDafny(dafnyOutput.Dtor_publicKey())} + +} + +func AwsCryptographicPrimitivesError_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.Error) awscryptographyprimitivessmithygeneratedtypes.AwsCryptographicPrimitivesError { + return awscryptographyprimitivessmithygeneratedtypes.AwsCryptographicPrimitivesError{Message: aws_cryptography_primitives_AwsCryptographicPrimitivesError_message_FromDafny(dafnyOutput.Dtor_message())} + +} + +func CollectionOfErrors_Output_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.Error) awscryptographyprimitivessmithygeneratedtypes.CollectionOfErrors { + listOfErrors := dafnyOutput.Dtor_list() + message := dafnyOutput.Dtor_message() + t := awscryptographyprimitivessmithygeneratedtypes.CollectionOfErrors{} + for i := dafny.Iterate(listOfErrors); ; { + val, ok := i() + if !ok { + break + } + err := val.(AwsCryptographyPrimitivesTypes.Error) + t.ListOfErrors = append(t.ListOfErrors, Error_FromDafny(err)) + + } + t.Message = func() string { + var s string + for i := dafny.Iterate(message); ; { + val, ok := i() + if !ok { + return s + } else { + s = s + string(val.(dafny.Char)) + } + } + }() + return t +} +func OpaqueError_Output_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.Error) awscryptographyprimitivessmithygeneratedtypes.OpaqueError { + return awscryptographyprimitivessmithygeneratedtypes.OpaqueError{ + ErrObject: dafnyOutput.Dtor_obj(), + } +} + +func Error_FromDafny(err AwsCryptographyPrimitivesTypes.Error) error { + // Service Errors + if err.Is_AwsCryptographicPrimitivesError() { + return AwsCryptographicPrimitivesError_FromDafny(err) + } + + //DependentErrors + + //Unmodelled Errors + if err.Is_CollectionOfErrors() { + return CollectionOfErrors_Output_FromDafny(err) + } + + return OpaqueError_Output_FromDafny(err) +} + +func CryptoConfig_FromDafny(dafnyOutput AwsCryptographyPrimitivesTypes.CryptoConfig) awscryptographyprimitivessmithygeneratedtypes.CryptoConfig { + return awscryptographyprimitivessmithygeneratedtypes.CryptoConfig{} + +} + +func Aws_cryptography_primitives_GenerateRandomBytesOutput_data_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_AESDecryptInput_key_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_ECDSAVerifyInput_message_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_DeriveSharedSecretInput_publicKey_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey { + return awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey{Der: aws_cryptography_primitives_ECCPublicKey_der_FromDafny(input.(AwsCryptographyPrimitivesTypes.ECCPublicKey).Dtor_der())} +} +func aws_cryptography_primitives_ECDSAVerifyInput_signatureAlgorithm_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm { + var u awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDSASignatureAlgorithm_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_AESEncryptInput_iv_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_RSADecryptInput_privateKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_HkdfInput_expectedLength_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func Aws_cryptography_primitives_ECDSAVerifyOutput_success_FromDafny(input interface{}) bool { + return input.(bool) +} +func Aws_cryptography_primitives_HkdfOutput_okm_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_HkdfExpandInput_expectedLength_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func aws_cryptography_primitives_GenerateECCKeyPairOutput_publicKey_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey { + return awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey{Der: aws_cryptography_primitives_ECCPublicKey_der_FromDafny(input.(AwsCryptographyPrimitivesTypes.ECCPublicKey).Dtor_der())} +} +func aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_publicKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_HMacInput_digestAlgorithm_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + return func() awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + var u awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm + inputEnum := input.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func Aws_cryptography_primitives_AESDecryptOutput_plaintext_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_ValidatePublicKeyInput_publicKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GenerateRandomBytesInput_length_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func aws_cryptography_primitives_AESDecryptInput_authTag_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_RSAEncryptInput_plaintext_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func Aws_cryptography_primitives_KdfCtrOutput_okm_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_KdfCtrInput_ikm_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_ParsePublicKeyOutput_publicKey_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey { + return awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey{Der: aws_cryptography_primitives_ECCPublicKey_der_FromDafny(input.(AwsCryptographyPrimitivesTypes.ECCPublicKey).Dtor_der())} +} +func aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_eccCurve_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + var u awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_HkdfExtractInput_ikm_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GetRSAKeyModulusLengthOutput_length_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func aws_cryptography_primitives_KdfCtrInput_purpose_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_AesKdfCtrInput_expectedLength_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func aws_cryptography_primitives_RSAPublicKey_lengthBits_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func aws_cryptography_primitives_GetPublicKeyFromPrivateKeyOutput_privateKey_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey { + return awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey{Pem: aws_cryptography_primitives_ECCPrivateKey_pem_FromDafny(input.(AwsCryptographyPrimitivesTypes.ECCPrivateKey).Dtor_pem())} +} +func aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_signingKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_RSADecryptInput_cipherText_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_AESEncryptInput_aad_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_DecompressPublicKeyInput_eccCurve_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + var u awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func Aws_cryptography_primitives_ECDSASignOutput_signature_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_ValidatePublicKeyInput_eccCurve_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + var u awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_DeriveSharedSecretInput_eccCurve_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + var u awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_AES_GCM_ivLength_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func aws_cryptography_primitives_HkdfInput_info_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_HkdfExpandInput_info_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_HMacInput_key_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func Aws_cryptography_primitives_DigestOutput_digest_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_AESEncryptOutput_cipherText_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_AESEncryptInput_key_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_RSAPrivateKey_lengthBits_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func aws_cryptography_primitives_GenerateRSAKeyPairInput_lengthBits_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func aws_cryptography_primitives_DigestInput_message_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_RSAPublicKey_pem_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_ParsePublicKeyInput_publicKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_HkdfExpandInput_prk_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GetRSAKeyModulusLengthInput_publicKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GenerateRSAKeyPairOutput_publicKey_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.RSAPublicKey { + return awscryptographyprimitivessmithygeneratedtypes.RSAPublicKey{LengthBits: aws_cryptography_primitives_RSAPublicKey_lengthBits_FromDafny(input.(AwsCryptographyPrimitivesTypes.RSAPublicKey).Dtor_lengthBits()), + Pem: aws_cryptography_primitives_RSAPublicKey_pem_FromDafny(input.(AwsCryptographyPrimitivesTypes.RSAPublicKey).Dtor_pem()), + } +} +func aws_cryptography_primitives_AESEncryptInput_msg_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_DecompressPublicKeyInput_compressedPublicKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_RSAEncryptInput_publicKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_RSAPrivateKey_pem_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GenerateRSAKeyPairOutput_privateKey_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.RSAPrivateKey { + return awscryptographyprimitivessmithygeneratedtypes.RSAPrivateKey{LengthBits: aws_cryptography_primitives_RSAPrivateKey_lengthBits_FromDafny(input.(AwsCryptographyPrimitivesTypes.RSAPrivateKey).Dtor_lengthBits()), + Pem: aws_cryptography_primitives_RSAPrivateKey_pem_FromDafny(input.(AwsCryptographyPrimitivesTypes.RSAPrivateKey).Dtor_pem()), + } +} +func aws_cryptography_primitives_AESEncryptOutput_authTag_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_ECDSASignInput_signingKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_ECDSAVerifyInput_verificationKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_AesKdfCtrInput_nonce_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_HMacInput_message_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_CompressPublicKeyInput_publicKey_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey { + return awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey{Der: aws_cryptography_primitives_ECCPublicKey_der_FromDafny(input.(AwsCryptographyPrimitivesTypes.ECCPublicKey).Dtor_der())} +} +func aws_cryptography_primitives_DigestInput_digestAlgorithm_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + return func() awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + var u awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm + inputEnum := input.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_AES_GCM_tagLength_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func aws_cryptography_primitives_ValidatePublicKeyOutput_success_FromDafny(input interface{}) bool { + return input.(bool) +} +func aws_cryptography_primitives_ECDSASignInput_signatureAlgorithm_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm { + var u awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDSASignatureAlgorithm_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_RSADecryptInput_padding_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.RSAPaddingMode { + return func() awscryptographyprimitivessmithygeneratedtypes.RSAPaddingMode { + var u awscryptographyprimitivessmithygeneratedtypes.RSAPaddingMode + inputEnum := input.(AwsCryptographyPrimitivesTypes.RSAPaddingMode) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_RSAPaddingMode_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.RSAPaddingMode).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func Aws_cryptography_primitives_HkdfExtractOutput_prk_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func Aws_cryptography_primitives_RSADecryptOutput_plaintext_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GetPublicKeyFromPrivateKeyInput_privateKey_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey { + return awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey{Pem: aws_cryptography_primitives_ECCPrivateKey_pem_FromDafny(input.(AwsCryptographyPrimitivesTypes.ECCPrivateKey).Dtor_pem())} +} +func aws_cryptography_primitives_ECDSAVerifyInput_signature_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_AESDecryptInput_encAlg_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.AES_GCM { + return awscryptographyprimitivessmithygeneratedtypes.AES_GCM{KeyLength: aws_cryptography_primitives_AES_GCM_keyLength_FromDafny(input.(AwsCryptographyPrimitivesTypes.AES__GCM).Dtor_keyLength()), + TagLength: aws_cryptography_primitives_AES_GCM_tagLength_FromDafny(input.(AwsCryptographyPrimitivesTypes.AES__GCM).Dtor_tagLength()), + IvLength: aws_cryptography_primitives_AES_GCM_ivLength_FromDafny(input.(AwsCryptographyPrimitivesTypes.AES__GCM).Dtor_ivLength()), + } +} +func aws_cryptography_primitives_HkdfExpandInput_digestAlgorithm_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + return func() awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + var u awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm + inputEnum := input.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func Aws_cryptography_primitives_HkdfExpandOutput_okm_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GetPublicKeyFromPrivateKeyInput_eccCurve_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + var u awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_RSAEncryptInput_padding_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.RSAPaddingMode { + return func() awscryptographyprimitivessmithygeneratedtypes.RSAPaddingMode { + var u awscryptographyprimitivessmithygeneratedtypes.RSAPaddingMode + inputEnum := input.(AwsCryptographyPrimitivesTypes.RSAPaddingMode) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_RSAPaddingMode_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.RSAPaddingMode).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_DeriveSharedSecretInput_privateKey_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey { + return awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey{Pem: aws_cryptography_primitives_ECCPrivateKey_pem_FromDafny(input.(AwsCryptographyPrimitivesTypes.ECCPrivateKey).Dtor_pem())} +} +func aws_cryptography_primitives_ECCPublicKey_der_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_HkdfInput_ikm_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GenerateECDSASignatureKeyInput_signatureAlgorithm_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm { + var u awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDSASignatureAlgorithm_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_AESDecryptInput_cipherTxt_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_KdfCtrInput_digestAlgorithm_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + return func() awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + var u awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm + inputEnum := input.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_HkdfExtractInput_salt_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func Aws_cryptography_primitives_HMacOutput_digest_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_KdfCtrInput_nonce_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_signatureAlgorithm_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm { + var u awscryptographyprimitivessmithygeneratedtypes.ECDSASignatureAlgorithm + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDSASignatureAlgorithm_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_CompressPublicKeyInput_eccCurve_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + var u awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_GenerateECDSASignatureKeyOutput_verificationKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_DecompressPublicKeyOutput_publicKey_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey { + return awscryptographyprimitivessmithygeneratedtypes.ECCPublicKey{Der: aws_cryptography_primitives_ECCPublicKey_der_FromDafny(input.(AwsCryptographyPrimitivesTypes.ECCPublicKey).Dtor_der())} +} +func aws_cryptography_primitives_HkdfExtractInput_digestAlgorithm_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + return func() awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + var u awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm + inputEnum := input.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func Aws_cryptography_primitives_RSAEncryptOutput_cipherText_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GenerateECCKeyPairOutput_eccCurve_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + var u awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_HkdfInput_salt_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_ECCPrivateKey_pem_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_AESDecryptInput_aad_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_AwsCryptographicPrimitivesError_message_FromDafny(input interface{}) string { + return func() string { + var s string + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return s + } else { + s = s + string(val.(dafny.Char)) + } + } + }() +} +func aws_cryptography_primitives_AES_GCM_keyLength_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func aws_cryptography_primitives_HkdfInput_digestAlgorithm_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + return func() awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm { + var u awscryptographyprimitivessmithygeneratedtypes.DigestAlgorithm + inputEnum := input.(AwsCryptographyPrimitivesTypes.DigestAlgorithm) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_DigestAlgorithm_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.DigestAlgorithm).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_AesKdfCtrInput_ikm_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GenerateECCKeyPairInput_eccCurve_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + return func() awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec { + var u awscryptographyprimitivessmithygeneratedtypes.ECDHCurveSpec + inputEnum := input.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec) + index := -1 + for allEnums := dafny.Iterate(AwsCryptographyPrimitivesTypes.CompanionStruct_ECDHCurveSpec_{}.AllSingletonConstructors()); ; { + enum, ok := allEnums() + if ok { + index++ + if enum.(AwsCryptographyPrimitivesTypes.ECDHCurveSpec).Equals(inputEnum) { + break + } + } + } + + return u.Values()[index] + }() +} +func aws_cryptography_primitives_AESEncryptInput_encAlg_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.AES_GCM { + return awscryptographyprimitivessmithygeneratedtypes.AES_GCM{KeyLength: aws_cryptography_primitives_AES_GCM_keyLength_FromDafny(input.(AwsCryptographyPrimitivesTypes.AES__GCM).Dtor_keyLength()), + TagLength: aws_cryptography_primitives_AES_GCM_tagLength_FromDafny(input.(AwsCryptographyPrimitivesTypes.AES__GCM).Dtor_tagLength()), + IvLength: aws_cryptography_primitives_AES_GCM_ivLength_FromDafny(input.(AwsCryptographyPrimitivesTypes.AES__GCM).Dtor_ivLength()), + } +} +func aws_cryptography_primitives_CompressPublicKeyOutput_compressedPublicKey_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_AESDecryptInput_iv_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_KdfCtrInput_expectedLength_FromDafny(input interface{}) int32 { + return func() int32 { + var b = input.(int32) + return b + }() +} +func aws_cryptography_primitives_ECDSASignInput_message_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_DeriveSharedSecretOutput_sharedSecret_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func Aws_cryptography_primitives_AesKdfCtrOutput_okm_FromDafny(input interface{}) []byte { + return func() []byte { + var b []byte + if input == nil { + return nil + } + for i := dafny.Iterate(input); ; { + val, ok := i() + if !ok { + return b + } else { + b = append(b, val.(byte)) + } + } + }() +} +func aws_cryptography_primitives_GenerateECCKeyPairOutput_privateKey_FromDafny(input interface{}) awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey { + return awscryptographyprimitivessmithygeneratedtypes.ECCPrivateKey{Pem: aws_cryptography_primitives_ECCPrivateKey_pem_FromDafny(input.(AwsCryptographyPrimitivesTypes.ECCPrivateKey).Dtor_pem())} +} diff --git a/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/enums.go b/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/enums.go new file mode 100644 index 000000000..11a7802a1 --- /dev/null +++ b/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/enums.go @@ -0,0 +1,71 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package awscryptographyprimitivessmithygeneratedtypes + +type ECDHCurveSpec string + +const ( + ECDHCurveSpecEccNistP256 ECDHCurveSpec = "ECC_NIST_P256" + ECDHCurveSpecEccNistP384 ECDHCurveSpec = "ECC_NIST_P384" + ECDHCurveSpecEccNistP521 ECDHCurveSpec = "ECC_NIST_P521" + ECDHCurveSpecSm2 ECDHCurveSpec = "SM2" +) + +func (ECDHCurveSpec) Values() []ECDHCurveSpec { + return []ECDHCurveSpec{ + "ECC_NIST_P256", + "ECC_NIST_P384", + "ECC_NIST_P521", + "SM2", + } +} + +type DigestAlgorithm string + +const ( + DigestAlgorithmSha512 DigestAlgorithm = "SHA_512" + DigestAlgorithmSha384 DigestAlgorithm = "SHA_384" + DigestAlgorithmSha256 DigestAlgorithm = "SHA_256" +) + +func (DigestAlgorithm) Values() []DigestAlgorithm { + return []DigestAlgorithm{ + "SHA_512", + "SHA_384", + "SHA_256", + } +} + +type ECDSASignatureAlgorithm string + +const ( + ECDSASignatureAlgorithmEcdsaP384 ECDSASignatureAlgorithm = "ECDSA_P384" + ECDSASignatureAlgorithmEcdsaP256 ECDSASignatureAlgorithm = "ECDSA_P256" +) + +func (ECDSASignatureAlgorithm) Values() []ECDSASignatureAlgorithm { + return []ECDSASignatureAlgorithm{ + "ECDSA_P384", + "ECDSA_P256", + } +} + +type RSAPaddingMode string + +const ( + RSAPaddingModePkcs1 RSAPaddingMode = "PKCS1" + RSAPaddingModeOaepSha1 RSAPaddingMode = "OAEP_SHA1" + RSAPaddingModeOaepSha256 RSAPaddingMode = "OAEP_SHA256" + RSAPaddingModeOaepSha384 RSAPaddingMode = "OAEP_SHA384" + RSAPaddingModeOaepSha512 RSAPaddingMode = "OAEP_SHA512" +) + +func (RSAPaddingMode) Values() []RSAPaddingMode { + return []RSAPaddingMode{ + "PKCS1", + "OAEP_SHA1", + "OAEP_SHA256", + "OAEP_SHA384", + "OAEP_SHA512", + } +} diff --git a/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/errors.go b/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/errors.go new file mode 100644 index 000000000..0acaacb8b --- /dev/null +++ b/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/errors.go @@ -0,0 +1,17 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package awscryptographyprimitivessmithygeneratedtypes + +import ( + "fmt" +) + +type AwsCryptographicPrimitivesError struct { + AwsCryptographicPrimitivesBaseException + Message string + ErrorCodeOverride *string +} + +func (e AwsCryptographicPrimitivesError) Error() string { + return fmt.Sprintf("%s: %s", e.ErrorCodeOverride, e.Message) +} diff --git a/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/types.go b/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/types.go new file mode 100644 index 000000000..9d2605d70 --- /dev/null +++ b/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/types.go @@ -0,0 +1,717 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package awscryptographyprimitivessmithygeneratedtypes + +import ( + "fmt" +) + +type AES_GCM struct { + IvLength int32 + + KeyLength int32 + + TagLength int32 +} + +func (input AES_GCM) Validate() error { + if input.IvLength < 0 { + return fmt.Errorf("Uint8Bits has a minimum of 0 but has the value of %d.", input.IvLength) + } + if input.IvLength > 255 { + return fmt.Errorf("Uint8Bits has a maximum of 255 but has the value of %d.", input.IvLength) + } + if input.KeyLength < 1 { + return fmt.Errorf("SymmetricKeyLength has a minimum of 1 but has the value of %d.", input.KeyLength) + } + if input.KeyLength > 32 { + return fmt.Errorf("SymmetricKeyLength has a maximum of 32 but has the value of %d.", input.KeyLength) + } + if input.TagLength < 0 { + return fmt.Errorf("Uint8Bytes has a minimum of 0 but has the value of %d.", input.TagLength) + } + if input.TagLength > 32 { + return fmt.Errorf("Uint8Bytes has a maximum of 32 but has the value of %d.", input.TagLength) + } + + return nil +} + +type AESDecryptInput struct { + Aad []byte + + AuthTag []byte + + CipherTxt []byte + + EncAlg AES_GCM + + Iv []byte + + Key []byte +} + +func (input AESDecryptInput) Validate() error { + if input.EncAlg.Validate() != nil { + return input.EncAlg.Validate() + } + + return nil +} + +type AESDecryptOutput struct { + Plaintext []byte +} + +func (input AESDecryptOutput) Validate() error { + + return nil +} + +type AESEncryptInput struct { + Aad []byte + + EncAlg AES_GCM + + Iv []byte + + Key []byte + + Msg []byte +} + +func (input AESEncryptInput) Validate() error { + if input.EncAlg.Validate() != nil { + return input.EncAlg.Validate() + } + + return nil +} + +type AESEncryptOutput struct { + AuthTag []byte + + CipherText []byte +} + +func (input AESEncryptOutput) Validate() error { + + return nil +} + +type AesKdfCtrInput struct { + ExpectedLength int32 + + Ikm []byte + + Nonce []byte +} + +func (input AesKdfCtrInput) Validate() error { + if input.ExpectedLength < 0 { + return fmt.Errorf("PositiveInteger has a minimum of 0 but has the value of %d.", input.ExpectedLength) + } + + return nil +} + +type AesKdfCtrOutput struct { + Okm []byte +} + +func (input AesKdfCtrOutput) Validate() error { + + return nil +} + +type ECCPublicKey struct { + Der []byte +} + +func (input ECCPublicKey) Validate() error { + + return nil +} + +type CompressPublicKeyInput struct { + EccCurve ECDHCurveSpec + + PublicKey ECCPublicKey +} + +func (input CompressPublicKeyInput) Validate() error { + if input.PublicKey.Validate() != nil { + return input.PublicKey.Validate() + } + + return nil +} + +type CompressPublicKeyOutput struct { + CompressedPublicKey []byte +} + +func (input CompressPublicKeyOutput) Validate() error { + + return nil +} + +type DecompressPublicKeyInput struct { + CompressedPublicKey []byte + + EccCurve ECDHCurveSpec +} + +func (input DecompressPublicKeyInput) Validate() error { + + return nil +} + +type DecompressPublicKeyOutput struct { + PublicKey ECCPublicKey +} + +func (input DecompressPublicKeyOutput) Validate() error { + if input.PublicKey.Validate() != nil { + return input.PublicKey.Validate() + } + + return nil +} + +type ECCPrivateKey struct { + Pem []byte +} + +func (input ECCPrivateKey) Validate() error { + + return nil +} + +type DeriveSharedSecretInput struct { + EccCurve ECDHCurveSpec + + PrivateKey ECCPrivateKey + + PublicKey ECCPublicKey +} + +func (input DeriveSharedSecretInput) Validate() error { + if input.PrivateKey.Validate() != nil { + return input.PrivateKey.Validate() + } + if input.PublicKey.Validate() != nil { + return input.PublicKey.Validate() + } + + return nil +} + +type DeriveSharedSecretOutput struct { + SharedSecret []byte +} + +func (input DeriveSharedSecretOutput) Validate() error { + + return nil +} + +type DigestInput struct { + DigestAlgorithm DigestAlgorithm + + Message []byte +} + +func (input DigestInput) Validate() error { + + return nil +} + +type DigestOutput struct { + Digest []byte +} + +func (input DigestOutput) Validate() error { + + return nil +} + +type ECDSASignInput struct { + Message []byte + + SignatureAlgorithm ECDSASignatureAlgorithm + + SigningKey []byte +} + +func (input ECDSASignInput) Validate() error { + + return nil +} + +type ECDSASignOutput struct { + Signature []byte +} + +func (input ECDSASignOutput) Validate() error { + + return nil +} + +type ECDSAVerifyInput struct { + Message []byte + + Signature []byte + + SignatureAlgorithm ECDSASignatureAlgorithm + + VerificationKey []byte +} + +func (input ECDSAVerifyInput) Validate() error { + + return nil +} + +type ECDSAVerifyOutput struct { + Success bool +} + +func (input ECDSAVerifyOutput) Validate() error { + + return nil +} + +type GenerateECCKeyPairInput struct { + EccCurve ECDHCurveSpec +} + +func (input GenerateECCKeyPairInput) Validate() error { + + return nil +} + +type GenerateECCKeyPairOutput struct { + EccCurve ECDHCurveSpec + + PrivateKey ECCPrivateKey + + PublicKey ECCPublicKey +} + +func (input GenerateECCKeyPairOutput) Validate() error { + if input.PrivateKey.Validate() != nil { + return input.PrivateKey.Validate() + } + if input.PublicKey.Validate() != nil { + return input.PublicKey.Validate() + } + + return nil +} + +type GenerateECDSASignatureKeyInput struct { + SignatureAlgorithm ECDSASignatureAlgorithm +} + +func (input GenerateECDSASignatureKeyInput) Validate() error { + + return nil +} + +type GenerateECDSASignatureKeyOutput struct { + SignatureAlgorithm ECDSASignatureAlgorithm + + SigningKey []byte + + VerificationKey []byte +} + +func (input GenerateECDSASignatureKeyOutput) Validate() error { + + return nil +} + +type GenerateRandomBytesInput struct { + Length int32 +} + +func (input GenerateRandomBytesInput) Validate() error { + if input.Length < 0 { + return fmt.Errorf("PositiveInteger has a minimum of 0 but has the value of %d.", input.Length) + } + + return nil +} + +type GenerateRandomBytesOutput struct { + Data []byte +} + +func (input GenerateRandomBytesOutput) Validate() error { + + return nil +} + +type GenerateRSAKeyPairInput struct { + LengthBits int32 +} + +func (input GenerateRSAKeyPairInput) Validate() error { + if input.LengthBits < 81 { + return fmt.Errorf("RSAModulusLengthBitsToGenerate has a minimum of 81 but has the value of %d.", input.LengthBits) + } + if input.LengthBits > 4096 { + return fmt.Errorf("RSAModulusLengthBitsToGenerate has a maximum of 4096 but has the value of %d.", input.LengthBits) + } + + return nil +} + +type RSAPrivateKey struct { + LengthBits int32 + + Pem []byte +} + +func (input RSAPrivateKey) Validate() error { + if input.LengthBits < 81 { + return fmt.Errorf("RSAModulusLengthBits has a minimum of 81 but has the value of %d.", input.LengthBits) + } + + return nil +} + +type RSAPublicKey struct { + LengthBits int32 + + Pem []byte +} + +func (input RSAPublicKey) Validate() error { + if input.LengthBits < 81 { + return fmt.Errorf("RSAModulusLengthBits has a minimum of 81 but has the value of %d.", input.LengthBits) + } + + return nil +} + +type GenerateRSAKeyPairOutput struct { + PrivateKey RSAPrivateKey + + PublicKey RSAPublicKey +} + +func (input GenerateRSAKeyPairOutput) Validate() error { + if input.PrivateKey.Validate() != nil { + return input.PrivateKey.Validate() + } + if input.PublicKey.Validate() != nil { + return input.PublicKey.Validate() + } + + return nil +} + +type GetPublicKeyFromPrivateKeyInput struct { + EccCurve ECDHCurveSpec + + PrivateKey ECCPrivateKey +} + +func (input GetPublicKeyFromPrivateKeyInput) Validate() error { + if input.PrivateKey.Validate() != nil { + return input.PrivateKey.Validate() + } + + return nil +} + +type GetPublicKeyFromPrivateKeyOutput struct { + EccCurve ECDHCurveSpec + + PrivateKey ECCPrivateKey + + PublicKey []byte +} + +func (input GetPublicKeyFromPrivateKeyOutput) Validate() error { + if input.PrivateKey.Validate() != nil { + return input.PrivateKey.Validate() + } + + return nil +} + +type GetRSAKeyModulusLengthInput struct { + PublicKey []byte +} + +func (input GetRSAKeyModulusLengthInput) Validate() error { + + return nil +} + +type GetRSAKeyModulusLengthOutput struct { + Length int32 +} + +func (input GetRSAKeyModulusLengthOutput) Validate() error { + if input.Length < 81 { + return fmt.Errorf("RSAModulusLengthBits has a minimum of 81 but has the value of %d.", input.Length) + } + + return nil +} + +type HkdfInput struct { + DigestAlgorithm DigestAlgorithm + + ExpectedLength int32 + + Ikm []byte + + Info []byte + + Salt []byte +} + +func (input HkdfInput) Validate() error { + if input.ExpectedLength < 0 { + return fmt.Errorf("PositiveInteger has a minimum of 0 but has the value of %d.", input.ExpectedLength) + } + + return nil +} + +type HkdfOutput struct { + Okm []byte +} + +func (input HkdfOutput) Validate() error { + + return nil +} + +type HkdfExpandInput struct { + DigestAlgorithm DigestAlgorithm + + ExpectedLength int32 + + Info []byte + + Prk []byte +} + +func (input HkdfExpandInput) Validate() error { + if input.ExpectedLength < 0 { + return fmt.Errorf("PositiveInteger has a minimum of 0 but has the value of %d.", input.ExpectedLength) + } + + return nil +} + +type HkdfExpandOutput struct { + Okm []byte +} + +func (input HkdfExpandOutput) Validate() error { + + return nil +} + +type HkdfExtractInput struct { + DigestAlgorithm DigestAlgorithm + + Ikm []byte + + Salt []byte +} + +func (input HkdfExtractInput) Validate() error { + + return nil +} + +type HkdfExtractOutput struct { + Prk []byte +} + +func (input HkdfExtractOutput) Validate() error { + + return nil +} + +type HMacInput struct { + DigestAlgorithm DigestAlgorithm + + Key []byte + + Message []byte +} + +func (input HMacInput) Validate() error { + + return nil +} + +type HMacOutput struct { + Digest []byte +} + +func (input HMacOutput) Validate() error { + + return nil +} + +type KdfCtrInput struct { + DigestAlgorithm DigestAlgorithm + + ExpectedLength int32 + + Ikm []byte + + Nonce []byte + + Purpose []byte +} + +func (input KdfCtrInput) Validate() error { + if input.ExpectedLength < 0 { + return fmt.Errorf("PositiveInteger has a minimum of 0 but has the value of %d.", input.ExpectedLength) + } + + return nil +} + +type KdfCtrOutput struct { + Okm []byte +} + +func (input KdfCtrOutput) Validate() error { + + return nil +} + +type ParsePublicKeyInput struct { + PublicKey []byte +} + +func (input ParsePublicKeyInput) Validate() error { + + return nil +} + +type ParsePublicKeyOutput struct { + PublicKey ECCPublicKey +} + +func (input ParsePublicKeyOutput) Validate() error { + if input.PublicKey.Validate() != nil { + return input.PublicKey.Validate() + } + + return nil +} + +type RSADecryptInput struct { + CipherText []byte + + Padding RSAPaddingMode + + PrivateKey []byte +} + +func (input RSADecryptInput) Validate() error { + + return nil +} + +type RSADecryptOutput struct { + Plaintext []byte +} + +func (input RSADecryptOutput) Validate() error { + + return nil +} + +type RSAEncryptInput struct { + Padding RSAPaddingMode + + Plaintext []byte + + PublicKey []byte +} + +func (input RSAEncryptInput) Validate() error { + + return nil +} + +type RSAEncryptOutput struct { + CipherText []byte +} + +func (input RSAEncryptOutput) Validate() error { + + return nil +} + +type ValidatePublicKeyInput struct { + EccCurve ECDHCurveSpec + + PublicKey []byte +} + +func (input ValidatePublicKeyInput) Validate() error { + + return nil +} + +type ValidatePublicKeyOutput struct { + Success bool +} + +func (input ValidatePublicKeyOutput) Validate() error { + + return nil +} + +type AES_CTR struct { + KeyLength int32 + + NonceLength int32 +} + +func (input AES_CTR) Validate() error { + if input.KeyLength < 1 { + return fmt.Errorf("SymmetricKeyLength has a minimum of 1 but has the value of %d.", input.KeyLength) + } + if input.KeyLength > 32 { + return fmt.Errorf("SymmetricKeyLength has a maximum of 32 but has the value of %d.", input.KeyLength) + } + if input.NonceLength < 0 { + return fmt.Errorf("Uint8Bits has a minimum of 0 but has the value of %d.", input.NonceLength) + } + if input.NonceLength > 255 { + return fmt.Errorf("Uint8Bits has a maximum of 255 but has the value of %d.", input.NonceLength) + } + + return nil +} + +type CryptoConfig struct { +} + +func (input CryptoConfig) Validate() error { + + return nil +} + +type AwsCryptographicPrimitivesBaseException interface { + // This is a dummy method to allow type assertion since Go empty interfaces + // aren't useful for type assertion checks. No concrete class is expected to implement + // this method. This is also not exported. + interfaceBindingMethod() +} diff --git a/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/unmodelled_errors.go b/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/unmodelled_errors.go new file mode 100644 index 000000000..bc6484a09 --- /dev/null +++ b/AwsCryptographyPrimitives/runtimes/go/TestsFromDafny-go/awscryptographyprimitivessmithygeneratedtypes/unmodelled_errors.go @@ -0,0 +1,26 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package awscryptographyprimitivessmithygeneratedtypes + +import ( + "fmt" +) + +type CollectionOfErrors struct { + AwsCryptographicPrimitivesBaseException + ListOfErrors []error + Message string +} + +func (e CollectionOfErrors) Error() string { + return fmt.Sprintf("message: %s\n err %v", e.Message, e.ListOfErrors) +} + +type OpaqueError struct { + AwsCryptographicPrimitivesBaseException + ErrObject interface{} +} + +func (e OpaqueError) Error() string { + return fmt.Sprintf("message: %v", e.ErrObject) +}