From d202f7792c5d7d4d11cffb9e3f82c57a684d1afd Mon Sep 17 00:00:00 2001 From: Shreyes Sridhara Date: Wed, 23 Jul 2025 15:44:35 -0700 Subject: [PATCH 1/4] chore(python): create custom Makefile commands for fuzzing test vectors --- .../Makefile | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/TestVectorsAwsCryptographicMaterialProviders/Makefile b/TestVectorsAwsCryptographicMaterialProviders/Makefile index 54cb9636f8..e2ecb52515 100644 --- a/TestVectorsAwsCryptographicMaterialProviders/Makefile +++ b/TestVectorsAwsCryptographicMaterialProviders/Makefile @@ -254,3 +254,31 @@ test_decrypt_encrypt_vectors_rust: test_decrypt_encrypt_vectors_go: go -C runtimes/go/ImplementationFromDafny-go run ImplementationFromDafny.go decrypt --manifest-path=.. + +# Fuzz Testing Commands + +# Generate fuzzed test vectors in the Python runtime directory (50 vectors) +test_generate_fuzz_vectors: + cp dafny/TestVectorsAwsCryptographicMaterialProviders/test/keys.json runtimes/python/ + cd runtimes/python && python3 fuzz_generator.py --num-vectors 50 + @echo "fuzzed test vectors generated in runtimes/python/" + +# Run fuzz interoperability test from one language to another +# Usage: make test_fuzz_interop ENCRYPT_LANG=go DECRYPT_LANG=python +test_fuzz_interop: + @echo "Testing interoperability from $(ENCRYPT_LANG) to $(DECRYPT_LANG)" + $(MAKE) test_generate_fuzz_vectors + @if [ "$(ENCRYPT_LANG)" != "python" ]; then \ + echo "Copying test vectors to $(ENCRYPT_LANG) runtime"; \ + cp runtimes/python/manifest.json runtimes/$(ENCRYPT_LANG)/; \ + cp runtimes/python/keys.json runtimes/$(ENCRYPT_LANG)/; \ + fi + @echo "Encrypting with $(ENCRYPT_LANG) runtime" + $(MAKE) test_encrypt_vectors_$(ENCRYPT_LANG) + @if [ "$(ENCRYPT_LANG)" != "$(DECRYPT_LANG)" ]; then \ + echo "Copying encrypted manifest and keys to $(DECRYPT_LANG) runtime"; \ + cp runtimes/$(ENCRYPT_LANG)/manifest.json runtimes/$(DECRYPT_LANG)/; \ + cp runtimes/$(ENCRYPT_LANG)/keys.json runtimes/$(DECRYPT_LANG)/; \ + fi + @echo "Decrypting with $(DECRYPT_LANG) runtime" + $(MAKE) test_decrypt_encrypt_vectors_$(DECRYPT_LANG) \ No newline at end of file From 678e6cda01e24e8fe54218b58684a1a62c9bad9f Mon Sep 17 00:00:00 2001 From: Shreyes Sridhara Date: Thu, 24 Jul 2025 11:55:25 -0700 Subject: [PATCH 2/4] Update TestVectorsAwsCryptographicMaterialProviders/Makefile Co-authored-by: Rishav karanjit --- TestVectorsAwsCryptographicMaterialProviders/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestVectorsAwsCryptographicMaterialProviders/Makefile b/TestVectorsAwsCryptographicMaterialProviders/Makefile index e2ecb52515..631ee42152 100644 --- a/TestVectorsAwsCryptographicMaterialProviders/Makefile +++ b/TestVectorsAwsCryptographicMaterialProviders/Makefile @@ -258,7 +258,7 @@ test_decrypt_encrypt_vectors_go: # Fuzz Testing Commands # Generate fuzzed test vectors in the Python runtime directory (50 vectors) -test_generate_fuzz_vectors: +test_generate_fuzz_vectors_python: cp dafny/TestVectorsAwsCryptographicMaterialProviders/test/keys.json runtimes/python/ cd runtimes/python && python3 fuzz_generator.py --num-vectors 50 @echo "fuzzed test vectors generated in runtimes/python/" From 15ee691c7c04ba089d57722bab1e0addf3102c08 Mon Sep 17 00:00:00 2001 From: Shreyes Sridhara Date: Thu, 24 Jul 2025 16:09:25 -0700 Subject: [PATCH 3/4] added TODOs --- TestVectorsAwsCryptographicMaterialProviders/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/TestVectorsAwsCryptographicMaterialProviders/Makefile b/TestVectorsAwsCryptographicMaterialProviders/Makefile index 631ee42152..ba70e5ce7d 100644 --- a/TestVectorsAwsCryptographicMaterialProviders/Makefile +++ b/TestVectorsAwsCryptographicMaterialProviders/Makefile @@ -258,6 +258,8 @@ test_decrypt_encrypt_vectors_go: # Fuzz Testing Commands # Generate fuzzed test vectors in the Python runtime directory (50 vectors) +#TODO-Fuzztesting: remove echo statements to eliminate noise when testing on large test-vector suite +#TODO-Fuzztesting: having fuzz_generator.py in a common directory might simplify workflow test_generate_fuzz_vectors_python: cp dafny/TestVectorsAwsCryptographicMaterialProviders/test/keys.json runtimes/python/ cd runtimes/python && python3 fuzz_generator.py --num-vectors 50 @@ -267,7 +269,7 @@ test_generate_fuzz_vectors_python: # Usage: make test_fuzz_interop ENCRYPT_LANG=go DECRYPT_LANG=python test_fuzz_interop: @echo "Testing interoperability from $(ENCRYPT_LANG) to $(DECRYPT_LANG)" - $(MAKE) test_generate_fuzz_vectors + $(MAKE) test_generate_fuzz_vectors_python @if [ "$(ENCRYPT_LANG)" != "python" ]; then \ echo "Copying test vectors to $(ENCRYPT_LANG) runtime"; \ cp runtimes/python/manifest.json runtimes/$(ENCRYPT_LANG)/; \ From c5108dd801935e3178530c25d51b5b71048170b1 Mon Sep 17 00:00:00 2001 From: Shreyes Sridhara Date: Mon, 28 Jul 2025 19:12:55 -0700 Subject: [PATCH 4/4] centralize generation of test vectors, easy distribution to runtimes --- .../Makefile | 46 ++++++++----------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/TestVectorsAwsCryptographicMaterialProviders/Makefile b/TestVectorsAwsCryptographicMaterialProviders/Makefile index ba70e5ce7d..b87f1cc3ff 100644 --- a/TestVectorsAwsCryptographicMaterialProviders/Makefile +++ b/TestVectorsAwsCryptographicMaterialProviders/Makefile @@ -255,32 +255,22 @@ test_decrypt_encrypt_vectors_rust: test_decrypt_encrypt_vectors_go: go -C runtimes/go/ImplementationFromDafny-go run ImplementationFromDafny.go decrypt --manifest-path=.. -# Fuzz Testing Commands - -# Generate fuzzed test vectors in the Python runtime directory (50 vectors) -#TODO-Fuzztesting: remove echo statements to eliminate noise when testing on large test-vector suite -#TODO-Fuzztesting: having fuzz_generator.py in a common directory might simplify workflow -test_generate_fuzz_vectors_python: - cp dafny/TestVectorsAwsCryptographicMaterialProviders/test/keys.json runtimes/python/ - cd runtimes/python && python3 fuzz_generator.py --num-vectors 50 - @echo "fuzzed test vectors generated in runtimes/python/" - -# Run fuzz interoperability test from one language to another -# Usage: make test_fuzz_interop ENCRYPT_LANG=go DECRYPT_LANG=python +# Fuzz Testing Command + +#TODO-Fuzztesting: remove echo statement to eliminate noise when testing on large test-vector suite +# Usage: make test_fuzz_interop ENCRYPT_LANG= DECRYPT_LANG= test_fuzz_interop: - @echo "Testing interoperability from $(ENCRYPT_LANG) to $(DECRYPT_LANG)" - $(MAKE) test_generate_fuzz_vectors_python - @if [ "$(ENCRYPT_LANG)" != "python" ]; then \ - echo "Copying test vectors to $(ENCRYPT_LANG) runtime"; \ - cp runtimes/python/manifest.json runtimes/$(ENCRYPT_LANG)/; \ - cp runtimes/python/keys.json runtimes/$(ENCRYPT_LANG)/; \ - fi - @echo "Encrypting with $(ENCRYPT_LANG) runtime" - $(MAKE) test_encrypt_vectors_$(ENCRYPT_LANG) - @if [ "$(ENCRYPT_LANG)" != "$(DECRYPT_LANG)" ]; then \ - echo "Copying encrypted manifest and keys to $(DECRYPT_LANG) runtime"; \ - cp runtimes/$(ENCRYPT_LANG)/manifest.json runtimes/$(DECRYPT_LANG)/; \ - cp runtimes/$(ENCRYPT_LANG)/keys.json runtimes/$(DECRYPT_LANG)/; \ - fi - @echo "Decrypting with $(DECRYPT_LANG) runtime" - $(MAKE) test_decrypt_encrypt_vectors_$(DECRYPT_LANG) \ No newline at end of file + @echo "Testing interoperability from $(ENCRYPT_LANG) to $(DECRYPT_LANG)" + + cd dafny/TestVectorsAwsCryptographicMaterialProviders/test && python3 fuzz_generator.py --num-vectors 10000 + + cp dafny/TestVectorsAwsCryptographicMaterialProviders/test/manifest.json runtimes/$(ENCRYPT_LANG)/ + cp dafny/TestVectorsAwsCryptographicMaterialProviders/test/keys.json runtimes/$(ENCRYPT_LANG)/ + $(MAKE) test_encrypt_vectors_$(ENCRYPT_LANG) + + @if [ "$(ENCRYPT_LANG)" != "$(DECRYPT_LANG)" ]; then \ + cp runtimes/$(ENCRYPT_LANG)/manifest.json runtimes/$(DECRYPT_LANG)/; \ + cp runtimes/$(ENCRYPT_LANG)/keys.json runtimes/$(DECRYPT_LANG)/; \ + fi + + $(MAKE) test_decrypt_encrypt_vectors_$(DECRYPT_LANG) \ No newline at end of file