Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 183 additions & 4 deletions .github/workflows/library_interop_keyring_test_vectors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
# windows-latest,
ubuntu-22.04,
]
language: [java, net, rust, python, go]
language: [java, net, rust, python, go, c]
# https://taskei.amazon.dev/tasks/CrypTool-5284
dotnet-version: ["6.0.x"]
runs-on: ${{ matrix.os }}
Expand All @@ -55,7 +55,83 @@ jobs:
with:
submodules: "recursive"

# Set up runtimes
- name: Install OpenSSL
if: matrix.os != 'ubuntu-22.04' && matrix.language == 'c'
run: brew install openssl

- name: Install dependencies
if: matrix.os != 'ubuntu-22.04' && matrix.language == 'c'
run: brew install json-c

- name: Install LibCurl
if: matrix.os == 'ubuntu-22.04' && matrix.language == 'c'
run: sudo apt-get install libcurl4-openssl-dev

- name: Checkout C-ESDK
if: matrix.language == 'c'
uses: actions/checkout@v4
with:
repository: "aws/aws-encryption-sdk-c"
path: ./${{ matrix.library }}/aws-encryption-sdk-c
submodules: recursive

- name: Checkout AWS C++ SDK
if: matrix.language == 'c'
uses: actions/checkout@v4
with:
repository: "aws/aws-sdk-cpp"
path: ./${{ matrix.library }}/aws-encryption-sdk-c/aws-sdk-cpp
submodules: recursive

- name: Build and install aws-sdk-cpp
if: matrix.language == 'c' && matrix.os != 'ubuntu-22.04'
working-directory: ./${{ matrix.library }}/aws-encryption-sdk-c
run: |
# remove the following line once aws-sdk-cpp fixes linux-shared/SimpleUDP.cpp
perl -i -p -e 's/"-Werror"//' aws-sdk-cpp/cmake/compiler_settings.cmake
mkdir -p aws-encryption-sdk-c/build-aws-sdk-cpp || true
mkdir -p install || true
cd build-aws-sdk-cpp
cmake -G Xcode -DTARGET_ARCH="APPLE" -DBUILD_SHARED_LIBS=ON -DBUILD_ONLY="kms" -DENABLE_UNITY_BUILD=ON -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/TestVectors/aws-encryption-sdk-c/install -DCMAKE_PREFIX_PATH=${{github.workspace}}/TestVectors/aws-encryption-sdk-c/install ../aws-sdk-cpp
xcodebuild -target ALL_BUILD
xcodebuild -target install

- name: Build and install aws-sdk-cpp
if: matrix.os == 'ubuntu-22.04' && matrix.language == 'c'
working-directory: ./${{ matrix.library }}/aws-encryption-sdk-c
run: |
# remove the following line once aws-sdk-cpp fixes linux-shared/SimpleUDP.cpp
perl -i -p -e 's/"-Werror"//' aws-sdk-cpp/cmake/compiler_settings.cmake
mkdir -p build-aws-sdk-cpp || true
mkdir -p install || true
cd build-aws-sdk-cpp
cmake -DBUILD_SHARED_LIBS=ON -DBUILD_ONLY="kms" -DENABLE_UNITY_BUILD=ON -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/TestVectors/aws-encryption-sdk-c/install -DCMAKE_PREFIX_PATH=${{github.workspace}}/TestVectors/aws-encryption-sdk-c/install ../aws-sdk-cpp
make
make install

- name: Build C-ESDK
if: matrix.language == 'c' && matrix.os != 'ubuntu-22.04'
working-directory: ./${{ matrix.library }}/aws-encryption-sdk-c
run: |
mkdir build-aws-encryption-sdk-c || true
cd build-aws-encryption-sdk-c
cmake -G Xcode -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/TestVectors/aws-encryption-sdk-c/install -DCMAKE_PREFIX_PATH=${{github.workspace}}/TestVectors/aws-encryption-sdk-c/install -DOPENSSL_ROOT_DIR="/usr/local/opt/openssl@1.1" ../
xcodebuild -target ALL_BUILD
xcodebuild -scheme RUN_TESTS

- name: Build C-ESDK
if: matrix.language == 'c' && matrix.os == 'ubuntu-22.04'
working-directory: ./${{ matrix.library }}/aws-encryption-sdk-c
# TODO-RS: Figure out how to safely add AWS credentials and add -DAWS_ENC_SDK_END_TO_END_TESTS=ON and -DAWS_ENC_SDK_KNOWN_GOOD_TESTS=ON
run: |
mkdir build-aws-encryption-sdk-c || true
cd build-aws-encryption-sdk-c
cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/TestVectors/aws-encryption-sdk-c/install -DCMAKE_PREFIX_PATH=${{github.workspace}}/TestVectors/aws-encryption-sdk-c/install ..
make
make test
make install

# Set up runtimes
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
if: matrix.language == 'net'
uses: actions/setup-dotnet@v3
Expand Down Expand Up @@ -191,15 +267,27 @@ jobs:
gradle-version: 7.2

- name: Create Keyring Manifests
if: matrix.language != 'c'
working-directory: ./${{ matrix.library }}
# Only MKP manifests will be written in the legacy format
run: |
make test_generate_vectors_${{ matrix.language }}

- name: Create Keyring Encrypt Manifests
if: matrix.language != 'c'
working-directory: ./${{ matrix.library }}
run: make test_encrypt_vectors_${{ matrix.language }}

- name: Create Encrypt Manifests
if: matrix.language == 'c' && matrix.os != 'ubuntu-22.04'
working-directory: ./${{ matrix.library }}
run: make test_encrypt_vectors_c_mac

- name: Create Encrypt Manifests
if: matrix.language == 'c' && matrix.os == 'ubuntu-22.04'
working-directory: ./${{ matrix.library }}
run: make test_encrypt_vectors_c_unix

- name: Upload Keyring Encrypt Manifest and keys.json files
uses: actions/upload-artifact@v4
with:
Expand All @@ -220,8 +308,8 @@ jobs:
# windows-latest,
ubuntu-22.04,
]
encrypting_language: [java, net, rust, python, go]
decrypting_language: [java, net, rust, python, go]
encrypting_language: [java, net, rust, python, go, c]
decrypting_language: [java, net, rust, python, go, c]
# https://taskei.amazon.dev/tasks/CrypTool-5284
dotnet-version: ["6.0.x"]
runs-on: ${{ matrix.os }}
Expand All @@ -247,6 +335,86 @@ jobs:
with:
submodules: "recursive"

- name: Install OpenSSL
if: matrix.os != 'ubuntu-22.04' && matrix.decrypting_language == 'c'
run: brew install openssl

- name: Install dependencies
if: matrix.os != 'ubuntu-22.04' && matrix.decrypting_language == 'c'
run: brew install json-c

- name: Install LibCurl
if: matrix.os == 'ubuntu-22.04' && matrix.decrypting_language == 'c'
run: sudo apt-get install libcurl4-openssl-dev

- name: Checkout C-ESDK
if: matrix.decrypting_language == 'c'
uses: actions/checkout@v4
with:
repository: "aws/aws-encryption-sdk-c"
path: ./${{ matrix.library }}/aws-encryption-sdk-c
submodules: recursive

- name: Checkout AWS C++ SDK
if: matrix.decrypting_language == 'c'
uses: actions/checkout@v4
with:
repository: "aws/aws-sdk-cpp"
path: ./${{ matrix.library }}/aws-encryption-sdk-c/aws-sdk-cpp
submodules: recursive

- name: Build and install aws-sdk-cpp
if: matrix.decrypting_language == 'c' && matrix.os != 'ubuntu-22.04'
working-directory: ./${{ matrix.library }}/aws-encryption-sdk-c
run: |
pwd
ls
# remove the following line once aws-sdk-cpp fixes linux-shared/SimpleUDP.cpp
perl -i -p -e 's/"-Werror"//' aws-sdk-cpp/cmake/compiler_settings.cmake
mkdir -p aws-encryption-sdk-c/build-aws-sdk-cpp || true
mkdir -p install || true
cd build-aws-sdk-cpp
cmake -G Xcode -DTARGET_ARCH="APPLE" -DBUILD_SHARED_LIBS=ON -DBUILD_ONLY="kms" -DENABLE_UNITY_BUILD=ON -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/aws-encryption-sdk-c/install -DCMAKE_PREFIX_PATH=${{github.workspace}}/aws-encryption-sdk-c/install ../aws-sdk-cpp
xcodebuild -target ALL_BUILD
xcodebuild -target install

- name: Build and install aws-sdk-cpp
if: matrix.os == 'ubuntu-22.04' && matrix.decrypting_language == 'c'
working-directory: ./${{ matrix.library }}/aws-encryption-sdk-c
run: |
pwd
ls
# remove the following line once aws-sdk-cpp fixes linux-shared/SimpleUDP.cpp
perl -i -p -e 's/"-Werror"//' aws-sdk-cpp/cmake/compiler_settings.cmake
mkdir -p build-aws-sdk-cpp || true
mkdir -p install || true
cd build-aws-sdk-cpp
cmake -DBUILD_SHARED_LIBS=ON -DBUILD_ONLY="kms" -DENABLE_UNITY_BUILD=ON -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/TestVectors/aws-encryption-sdk-c/install -DCMAKE_PREFIX_PATH=${{github.workspace}}/TestVectors/aws-encryption-sdk-c/install ../aws-sdk-cpp
make
make install

- name: Build C-ESDK
if: matrix.decrypting_language == 'c' && matrix.os != 'ubuntu-22.04'
working-directory: ./${{ matrix.library }}/aws-encryption-sdk-c
run: |
mkdir build-aws-encryption-sdk-c || true
cd build-aws-encryption-sdk-c
cmake -G Xcode -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/TestVectors/aws-encryption-sdk-c/install -DCMAKE_PREFIX_PATH=${{github.workspace}}/TestVectors/aws-encryption-sdk-c/install -DOPENSSL_ROOT_DIR="/usr/local/opt/openssl@1.1" ../
xcodebuild -target ALL_BUILD
xcodebuild -scheme RUN_TESTS

- name: Build C-ESDK
if: matrix.decrypting_language == 'c' && matrix.os == 'ubuntu-22.04'
working-directory: ./${{ matrix.library }}/aws-encryption-sdk-c
# TODO-RS: Figure out how to safely add AWS credentials and add -DAWS_ENC_SDK_END_TO_END_TESTS=ON and -DAWS_ENC_SDK_KNOWN_GOOD_TESTS=ON
run: |
mkdir build-aws-encryption-sdk-c || true
cd build-aws-encryption-sdk-c
cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/TestVectors/aws-encryption-sdk-c/install -DCMAKE_PREFIX_PATH=${{github.workspace}}/TestVectors/aws-encryption-sdk-c/install ..
make
make test
make install

# Set up runtimes
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
if: matrix.decrypting_language == 'net'
Expand Down Expand Up @@ -382,5 +550,16 @@ jobs:
path: ./${{matrix.library}}/runtimes/${{matrix.decrypting_language}}

- name: Decrypt Encrypt Manifest
if: matrix.decrypting_language != 'c'
working-directory: ./${{ matrix.library }}
run: make test_decrypt_encrypt_vectors_${{matrix.decrypting_language}}

- name: Decrypt Encrypt Manifest
if: matrix.decrypting_language == 'c' && matrix.os == 'ubuntu-22.04'
working-directory: ./${{ matrix.library }}
run: make test_decrypt_encrypt_vectors_c_unix

- name: Decrypt Encrypt Manifest
if: matrix.decrypting_language == 'c' && matrix.os != 'ubuntu-22.04'
working-directory: ./${{ matrix.library }}
run: make test_decrypt_encrypt_vectors_c_mac
68 changes: 67 additions & 1 deletion TestVectors/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,72 @@ _sed_types_file_add_extern:
_sed_index_file_add_extern:
@echo "No extern to process for ESDK TestVectors"

c_test_vectors:
cd aws-encryption-sdk-c/tests/TestVectors; \
g++ -g -ggdb --std=c++17 -o test_vectors -I../../include/ \
base64.cpp do_decrypt.cpp do_encrypt.cpp parse_encrypt.cpp parse_keys.cpp test_vectors.cpp \
-I/opt/homebrew/include/ -L/opt/homebrew/lib/ \
-I../../install/include/ -L../../install/lib/ -I ../../aws-encryption-sdk-cpp/include/ \
../../build-aws-encryption-sdk-c/Debug/libaws-encryption-sdk.dylib \
../../build-aws-encryption-sdk-c/aws-encryption-sdk-cpp/Debug/libaws-encryption-sdk-cpp.dylib \
-laws-cpp-sdk-core -laws-cpp-sdk-kms -laws-c-common -lcrypto; \
install_name_tool -add_rpath ../../build-aws-encryption-sdk-c/Debug/ test_vectors; \
install_name_tool -add_rpath ../../build-aws-encryption-sdk-c/aws-encryption-sdk-cpp/Debug/ test_vectors; \
install_name_tool -add_rpath ../../install/lib/ test_vectors

c_test_vectors_unix:
cd aws-encryption-sdk-c/tests/TestVectors; \
ls ../../install/; \
ls ../../install/include/; \
g++ -g -ggdb --std=c++17 -o test_vectors -I../../include/ \
base64.cpp do_decrypt.cpp do_encrypt.cpp parse_encrypt.cpp parse_keys.cpp test_vectors.cpp \
-I../../install/include/ -L../../install/lib/ -I ../../aws-encryption-sdk-cpp/include/ \
-laws-encryption-sdk -laws-encryption-sdk-cpp \
-laws-cpp-sdk-core -laws-cpp-sdk-kms -laws-c-common -lcrypto

test_encrypt_vectors_c_mac: c_test_vectors
cd aws-encryption-sdk-c/tests/TestVectors; \
rm -rf local; \
mkdir -p local; \
LD_LIBRARY_PATH=../../install/lib/ ./test_vectors encrypt --manifest-path ./from-dafny --decrypt-manifest-path ./local
mkdir -p ./runtimes/c/
cp aws-encryption-sdk-c/tests/TestVectors/local/*.json ./runtimes/c/
mv ./runtimes/c/decrypt-manifest.json ./runtimes/c/manifest.json
cp -r aws-encryption-sdk-c/tests/TestVectors/local/plaintexts/ ./runtimes/c/plaintexts/
cp -r aws-encryption-sdk-c/tests/TestVectors/local/ciphertexts/ ./runtimes/c/ciphertexts/

test_encrypt_vectors_c_unix: c_test_vectors_unix
cd aws-encryption-sdk-c/tests/TestVectors; \
rm -rf local; \
mkdir -p local; \
LD_LIBRARY_PATH=../../install/lib/ ./test_vectors encrypt --manifest-path ./from-dafny --decrypt-manifest-path ./local
mkdir -p ./runtimes/c/
pwd
ls -l aws-encryption-sdk-c/tests/TestVectors/
ls -l aws-encryption-sdk-c/tests/TestVectors/local/
cp aws-encryption-sdk-c/tests/TestVectors/local/*.json ./runtimes/c/
mv ./runtimes/c/decrypt-manifest.json ./runtimes/c/manifest.json
cp -r aws-encryption-sdk-c/tests/TestVectors/local/plaintexts/ ./runtimes/c/plaintexts/
cp -r aws-encryption-sdk-c/tests/TestVectors/local/ciphertexts/ ./runtimes/c/ciphertexts/

test_decrypt_encrypt_vectors_c_mac: c_test_vectors
mkdir -p aws-encryption-sdk-c/tests/TestVectors/local/
cp ./runtimes/c/*.json aws-encryption-sdk-c/tests/TestVectors/local/
cp -r ./runtimes/c/plaintexts/ aws-encryption-sdk-c/tests/TestVectors/local/plaintexts/
cp -r ./runtimes/c/ciphertexts/ aws-encryption-sdk-c/tests/TestVectors/local/ciphertexts/
cd aws-encryption-sdk-c/tests/TestVectors; \
LD_LIBRARY_PATH=../../install/lib/ ./test_vectors decrypt --manifest-path ./local --manifest-name manifest.json

test_decrypt_encrypt_vectors_c_unix: c_test_vectors_unix
mkdir -p aws-encryption-sdk-c/tests/TestVectors/local/
pwd
ls -l ./runtimes/c/
cp ./runtimes/c/*.json aws-encryption-sdk-c/tests/TestVectors/local/
cp -r ./runtimes/c/plaintexts/ aws-encryption-sdk-c/tests/TestVectors/local/plaintexts/
cp -r ./runtimes/c/ciphertexts/ aws-encryption-sdk-c/tests/TestVectors/local/ciphertexts/
cd aws-encryption-sdk-c/tests/TestVectors; \
LD_LIBRARY_PATH=../../install/lib/ ./test_vectors decrypt --manifest-path ./local --manifest-name manifest.json

PYTHON_MODULE_NAME=aws_encryption_sdk_test_vectors

TRANSLATION_RECORD_PYTHON := \
Expand All @@ -356,4 +422,4 @@ PYTHON_DEPENDENCY_MODULE_NAMES := \
--dependency-library-name=aws.cryptography.keyStore=aws_cryptographic_material_providers \
--dependency-library-name=smithy.api=aws_cryptographic_material_providers \
--dependency-library-name=aws.cryptography.materialProvidersTestVectorKeys=aws_cryptographic_material_providers_test_vectors \
--dependency-library-name=aws.cryptography.encryptionSdk=aws_encryption_sdk_dafny
--dependency-library-name=aws.cryptography.encryptionSdk=aws_encryption_sdk_dafny