22# SPDX-License-Identifier: Apache-2.0
33
44CORES =2
5-
5+ ENABLE_EXTERN_PROCESSING =1
66TRANSPILE_TESTS_IN_RUST =1
77
88include ../SharedMakefileV2.mk
@@ -101,6 +101,10 @@ IMPLEMENTATION_FROM_DAFNY_TV_RUST_ESDK_MAIN= \
101101 let dafny_args = dafny_runtime::Sequence::from_array_owned(dafny_strings);\
102102 r\# _WrappedESDKMain_Compile::_default::Main2(\&dafny_args);"
103103
104+ IMPLEMENTATION_FROM_DAFNY_TV_GO_FILE =runtimes/go/ImplementationFromDafny-go/ImplementationFromDafny.go
105+ IMPLEMENTATION_FROM_DAFNY_TV_GO_MPL_MAIN ="m_WrappedMaterialProvidersMain.Companion_Default___.Main(_dafny.FromMainArguments(os.Args))"
106+ IMPLEMENTATION_FROM_DAFNY_TV_GO_ESDK_MAIN ="m_WrappedESDKMain.Companion_Default___.Main2(_dafny.FromMainArguments(os.Args))"
107+
104108# TODO: Remove after wrapped client issue is fixed in Rust
105109REMOVE_WRAPPED_CLIENT_AFTER_POLYMORPH_RUST_PRIMITIVES =runtimes/rust/src/deps/aws_cryptography_primitives.rs
106110REMOVE_WRAPPED_CLIENT_AFTER_POLYMORPH_RUST_KEYSTORE =runtimes/rust/src/deps/aws_cryptography_keyStore.rs
@@ -109,9 +113,54 @@ REMOVE_WRAPPED_CLIENT_AFTER_POLYMORPH_RUST_FROM_2 := 'pub mod wrapped;'
109113REMOVE_WRAPPED_CLIENT_AFTER_POLYMORPH_RUST_TO_1 := '\/\/ removed wrapped-client feature using sed;'
110114REMOVE_WRAPPED_CLIENT_AFTER_POLYMORPH_RUST_TO_2 := '\/\/ removed wrapped module using sed;'
111115
116+ # Go
117+
118+ GO_MODULE_NAME ="github.com/aws/aws-encryption-sdk/testvectors"
119+
120+ GO_DEPENDENCY_MODULE_NAMES := \
121+ --dependency-library-name=aws.cryptography.encryptionSdk=github.com/aws/aws-encryption-sdk \
122+ --dependency-library-name=com.amazonaws.dynamodb=github.com/aws/aws-cryptographic-material-providers-library/dynamodb \
123+ --dependency-library-name=com.amazonaws.kms=github.com/aws/aws-cryptographic-material-providers-library/kms \
124+ --dependency-library-name=aws.cryptography.keyStore=github.com/aws/aws-cryptographic-material-providers-library/mpl \
125+ --dependency-library-name=aws.cryptography.primitives=github.com/aws/aws-cryptographic-material-providers-library/primitives \
126+ --dependency-library-name=aws.cryptography.materialProviders=github.com/aws/aws-cryptographic-material-providers-library/mpl \
127+ --dependency-library-name=sdk.com.amazonaws.dynamodb=github.com/aws/aws-sdk-go-v2/service/dynamodb \
128+ --dependency-library-name=sdk.com.amazonaws.kms=github.com/aws/aws-sdk-go-v2/service/kms
129+
130+ TRANSLATION_RECORD_GO := \
131+ AwsEncryptionSDK/runtimes/go/ImplementationFromDafny-go/ImplementationFromDafny-go.dtr \
132+ mpl/StandardLibrary/runtimes/go/ImplementationFromDafny-go/ImplementationFromDafny-go.dtr \
133+ mpl/ComAmazonawsKms/runtimes/go/ImplementationFromDafny-go/ImplementationFromDafny-go.dtr \
134+ mpl/ComAmazonawsDynamodb/runtimes/go/ImplementationFromDafny-go/ImplementationFromDafny-go.dtr \
135+ mpl/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/ImplementationFromDafny-go.dtr \
136+ mpl/AwsCryptographicMaterialProviders/runtimes/go/ImplementationFromDafny-go/ImplementationFromDafny-go.dtr \
137+ mpl/TestVectorsAwsCryptographicMaterialProviders/runtimes/go/ImplementationFromDafny-go/ImplementationFromDafny-go.dtr
138+
139+ # Constants for languages that drop extern names (Go)
140+
141+ WRAPPED_INDEX_FILE_PATH =dafny/TestVectors/src/LibraryIndex.dfy
142+ WRAPPED_INDEX_FILE_WITH_EXTERN_STRING ="module {:extern \"software.amazon.cryptography.encryptionsdk.internaldafny.wrapped\" } WrappedESDK refines WrappedAbstractAwsCryptographyEncryptionSdkService"
143+ WRAPPED_INDEX_FILE_WITHOUT_EXTERN_STRING ="module WrappedESDK refines WrappedAbstractAwsCryptographyEncryptionSdkService"
144+
112145transpile_implementation_java : _replace_main_method_name_java
113146transpile_implementation_net : _replace_main_method_name_net
114147transpile_implementation_rust : _replace_main_method_name_rust
148+ transpile_implementation_go : _replace_main_method_name_go
149+
150+ _polymorph_go : purge_polymorph_code
151+
152+ # Smithy-dafny generated shim needs a long term fix.
153+ # TODO: Remove this commands once smithy-dafny is fixed
154+ # This commands does not work on windows
155+ # https://taskei.amazon.dev/tasks/CrypTool-5283
156+ purge_polymorph_code :
157+ find .. -name " shim.go" | xargs sed -i $(SED_PARAMETER ) ' s/(_static \*CompanionStruct_Default___)//g'
158+ rm -rf runtimes/go/ImplementationFromDafny-go/awscryptographyencryptionsdksmithygenerated \
159+ runtimes/go/ImplementationFromDafny-go/awscryptographyencryptionsdksmithygeneratedtypes \
160+ runtimes/go/ImplementationFromDafny-go/WrappedAwsCryptographyEncryptionSdkService \
161+ runtimes/go/TestsFromDafny-go/awscryptographyencryptionsdksmithygenerated \
162+ runtimes/go/TestsFromDafny-go/awscryptographyencryptionsdksmithygeneratedtypes \
163+ runtimes/go/TestsFromDafny-go/WrappedAwsCryptographyEncryptionSdkService
115164
116165# TODO: Remove after wrapped client issue is fixed in Rust
117166_polymorph_rust : _remove_wrapped_client_rust
@@ -125,6 +174,9 @@ _replace_main_method_name_net:
125174_replace_main_method_name_rust :
126175 $(MAKE ) _sed_file SED_FILE_PATH=$(IMPLEMENTATION_FROM_DAFNY_TV_RUST_FILE ) SED_BEFORE_STRING=$(IMPLEMENTATION_FROM_DAFNY_TV_RUST_MPL_MAIN ) SED_AFTER_STRING=$(IMPLEMENTATION_FROM_DAFNY_TV_RUST_ESDK_MAIN )
127176
177+ _replace_main_method_name_go :
178+ $(MAKE ) _sed_file SED_FILE_PATH=$(IMPLEMENTATION_FROM_DAFNY_TV_GO_FILE ) SED_BEFORE_STRING=$(IMPLEMENTATION_FROM_DAFNY_TV_GO_MPL_MAIN ) SED_AFTER_STRING=$(IMPLEMENTATION_FROM_DAFNY_TV_GO_ESDK_MAIN )
179+
128180# TODO: Remove after wrapped client issue is fixed in Rust
129181_remove_wrapped_client_rust :
130182 $(MAKE ) _sed_file SED_FILE_PATH=$(REMOVE_WRAPPED_CLIENT_AFTER_POLYMORPH_RUST_PRIMITIVES ) SED_BEFORE_STRING=$(REMOVE_WRAPPED_CLIENT_AFTER_POLYMORPH_RUST_FROM_1 ) SED_AFTER_STRING=$(REMOVE_WRAPPED_CLIENT_AFTER_POLYMORPH_RUST_TO_1 )
@@ -150,6 +202,10 @@ test_generate_vectors_rust:
150202 cd ../../
151203 cp dafny/TestVectors/test/keys.json runtimes/rust/
152204
205+ test_generate_vectors_go :
206+ go -C runtimes/go/ImplementationFromDafny-go run ImplementationFromDafny.go encrypt-manifest --encrypt-manifest-output ../
207+ cp dafny/TestVectors/test/keys.json runtimes/go
208+
153209test_encrypt_vectors_java :
154210 gradle -p runtimes/java run --args=" encrypt --manifest-path . --decrypt-manifest-path ."
155211
@@ -164,6 +220,9 @@ test_encrypt_vectors_rust:
164220 cargo run --bin test-vectors --features=" wrapped-client" --release -- encrypt --manifest-path . --decrypt-manifest-path . && \
165221 cd ../../
166222
223+ test_encrypt_vectors_go :
224+ go -C runtimes/go/ImplementationFromDafny-go run ImplementationFromDafny.go encrypt --manifest-path=.. --decrypt-manifest-path=..
225+
167226test_decrypt_encrypt_vectors_java :
168227 gradle -p runtimes/java run --args=" decrypt --manifest-path . --manifest-name decrypt-manifest.json"
169228
@@ -184,6 +243,20 @@ test_decrypt_encrypt_vectors_rust:
184243 cargo run --bin test-vectors --features=" wrapped-client" --release -- decrypt --manifest-path . --manifest-name decrypt-manifest.json && \
185244 cd ../../
186245
246+ test_decrypt_encrypt_vectors_go :
247+ go -C runtimes/go/ImplementationFromDafny-go run ImplementationFromDafny.go decrypt --manifest-path=.. --manifest-name=decrypt-manifest.json
248+
187249_polymorph_dependencies :
188250 @echo " No polymorphing of dependency"
189251
252+ _sed_types_file_remove_extern :
253+ @echo " No extern to process for ESDK TestVectors"
254+
255+ _sed_index_file_remove_extern :
256+ @echo " No extern to process for ESDK TestVectors"
257+
258+ _sed_types_file_add_extern :
259+ @echo " No extern to process for ESDK TestVectors"
260+
261+ _sed_index_file_add_extern :
262+ @echo " No extern to process for ESDK TestVectors"
0 commit comments