Skip to content

Commit 3b9297a

Browse files
authored
chore: add C to list of languages checked for interoperability (#773)
1 parent ba242a3 commit 3b9297a

File tree

2 files changed

+250
-5
lines changed

2 files changed

+250
-5
lines changed

.github/workflows/library_interop_keyring_test_vectors.yml

Lines changed: 183 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
# windows-latest,
3131
ubuntu-22.04,
3232
]
33-
language: [java, net, rust, python, go]
33+
language: [java, net, rust, python, go, c]
3434
# https://taskei.amazon.dev/tasks/CrypTool-5284
3535
dotnet-version: ["6.0.x"]
3636
runs-on: ${{ matrix.os }}
@@ -55,7 +55,83 @@ jobs:
5555
with:
5656
submodules: "recursive"
5757

58-
# Set up runtimes
58+
- name: Install OpenSSL
59+
if: matrix.os != 'ubuntu-22.04' && matrix.language == 'c'
60+
run: brew install openssl
61+
62+
- name: Install dependencies
63+
if: matrix.os != 'ubuntu-22.04' && matrix.language == 'c'
64+
run: brew install json-c
65+
66+
- name: Install LibCurl
67+
if: matrix.os == 'ubuntu-22.04' && matrix.language == 'c'
68+
run: sudo apt-get install libcurl4-openssl-dev
69+
70+
- name: Checkout C-ESDK
71+
if: matrix.language == 'c'
72+
uses: actions/checkout@v4
73+
with:
74+
repository: "aws/aws-encryption-sdk-c"
75+
path: ./${{ matrix.library }}/aws-encryption-sdk-c
76+
submodules: recursive
77+
78+
- name: Checkout AWS C++ SDK
79+
if: matrix.language == 'c'
80+
uses: actions/checkout@v4
81+
with:
82+
repository: "aws/aws-sdk-cpp"
83+
path: ./${{ matrix.library }}/aws-encryption-sdk-c/aws-sdk-cpp
84+
submodules: recursive
85+
86+
- name: Build and install aws-sdk-cpp
87+
if: matrix.language == 'c' && matrix.os != 'ubuntu-22.04'
88+
working-directory: ./${{ matrix.library }}/aws-encryption-sdk-c
89+
run: |
90+
# remove the following line once aws-sdk-cpp fixes linux-shared/SimpleUDP.cpp
91+
perl -i -p -e 's/"-Werror"//' aws-sdk-cpp/cmake/compiler_settings.cmake
92+
mkdir -p aws-encryption-sdk-c/build-aws-sdk-cpp || true
93+
mkdir -p install || true
94+
cd build-aws-sdk-cpp
95+
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
96+
xcodebuild -target ALL_BUILD
97+
xcodebuild -target install
98+
99+
- name: Build and install aws-sdk-cpp
100+
if: matrix.os == 'ubuntu-22.04' && matrix.language == 'c'
101+
working-directory: ./${{ matrix.library }}/aws-encryption-sdk-c
102+
run: |
103+
# remove the following line once aws-sdk-cpp fixes linux-shared/SimpleUDP.cpp
104+
perl -i -p -e 's/"-Werror"//' aws-sdk-cpp/cmake/compiler_settings.cmake
105+
mkdir -p build-aws-sdk-cpp || true
106+
mkdir -p install || true
107+
cd build-aws-sdk-cpp
108+
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
109+
make
110+
make install
111+
112+
- name: Build C-ESDK
113+
if: matrix.language == 'c' && matrix.os != 'ubuntu-22.04'
114+
working-directory: ./${{ matrix.library }}/aws-encryption-sdk-c
115+
run: |
116+
mkdir build-aws-encryption-sdk-c || true
117+
cd build-aws-encryption-sdk-c
118+
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/[email protected]" ../
119+
xcodebuild -target ALL_BUILD
120+
xcodebuild -scheme RUN_TESTS
121+
122+
- name: Build C-ESDK
123+
if: matrix.language == 'c' && matrix.os == 'ubuntu-22.04'
124+
working-directory: ./${{ matrix.library }}/aws-encryption-sdk-c
125+
# 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
126+
run: |
127+
mkdir build-aws-encryption-sdk-c || true
128+
cd build-aws-encryption-sdk-c
129+
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 ..
130+
make
131+
make test
132+
make install
133+
134+
# Set up runtimes
59135
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
60136
if: matrix.language == 'net'
61137
uses: actions/setup-dotnet@v3
@@ -191,15 +267,27 @@ jobs:
191267
gradle-version: 7.2
192268

193269
- name: Create Keyring Manifests
270+
if: matrix.language != 'c'
194271
working-directory: ./${{ matrix.library }}
195272
# Only MKP manifests will be written in the legacy format
196273
run: |
197274
make test_generate_vectors_${{ matrix.language }}
198275
199276
- name: Create Keyring Encrypt Manifests
277+
if: matrix.language != 'c'
200278
working-directory: ./${{ matrix.library }}
201279
run: make test_encrypt_vectors_${{ matrix.language }}
202280

281+
- name: Create Encrypt Manifests
282+
if: matrix.language == 'c' && matrix.os != 'ubuntu-22.04'
283+
working-directory: ./${{ matrix.library }}
284+
run: make test_encrypt_vectors_c_mac
285+
286+
- name: Create Encrypt Manifests
287+
if: matrix.language == 'c' && matrix.os == 'ubuntu-22.04'
288+
working-directory: ./${{ matrix.library }}
289+
run: make test_encrypt_vectors_c_unix
290+
203291
- name: Upload Keyring Encrypt Manifest and keys.json files
204292
uses: actions/upload-artifact@v4
205293
with:
@@ -220,8 +308,8 @@ jobs:
220308
# windows-latest,
221309
ubuntu-22.04,
222310
]
223-
encrypting_language: [java, net, rust, python, go]
224-
decrypting_language: [java, net, rust, python, go]
311+
encrypting_language: [java, net, rust, python, go, c]
312+
decrypting_language: [java, net, rust, python, go, c]
225313
# https://taskei.amazon.dev/tasks/CrypTool-5284
226314
dotnet-version: ["6.0.x"]
227315
runs-on: ${{ matrix.os }}
@@ -247,6 +335,86 @@ jobs:
247335
with:
248336
submodules: "recursive"
249337

338+
- name: Install OpenSSL
339+
if: matrix.os != 'ubuntu-22.04' && matrix.decrypting_language == 'c'
340+
run: brew install openssl
341+
342+
- name: Install dependencies
343+
if: matrix.os != 'ubuntu-22.04' && matrix.decrypting_language == 'c'
344+
run: brew install json-c
345+
346+
- name: Install LibCurl
347+
if: matrix.os == 'ubuntu-22.04' && matrix.decrypting_language == 'c'
348+
run: sudo apt-get install libcurl4-openssl-dev
349+
350+
- name: Checkout C-ESDK
351+
if: matrix.decrypting_language == 'c'
352+
uses: actions/checkout@v4
353+
with:
354+
repository: "aws/aws-encryption-sdk-c"
355+
path: ./${{ matrix.library }}/aws-encryption-sdk-c
356+
submodules: recursive
357+
358+
- name: Checkout AWS C++ SDK
359+
if: matrix.decrypting_language == 'c'
360+
uses: actions/checkout@v4
361+
with:
362+
repository: "aws/aws-sdk-cpp"
363+
path: ./${{ matrix.library }}/aws-encryption-sdk-c/aws-sdk-cpp
364+
submodules: recursive
365+
366+
- name: Build and install aws-sdk-cpp
367+
if: matrix.decrypting_language == 'c' && matrix.os != 'ubuntu-22.04'
368+
working-directory: ./${{ matrix.library }}/aws-encryption-sdk-c
369+
run: |
370+
pwd
371+
ls
372+
# remove the following line once aws-sdk-cpp fixes linux-shared/SimpleUDP.cpp
373+
perl -i -p -e 's/"-Werror"//' aws-sdk-cpp/cmake/compiler_settings.cmake
374+
mkdir -p aws-encryption-sdk-c/build-aws-sdk-cpp || true
375+
mkdir -p install || true
376+
cd build-aws-sdk-cpp
377+
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
378+
xcodebuild -target ALL_BUILD
379+
xcodebuild -target install
380+
381+
- name: Build and install aws-sdk-cpp
382+
if: matrix.os == 'ubuntu-22.04' && matrix.decrypting_language == 'c'
383+
working-directory: ./${{ matrix.library }}/aws-encryption-sdk-c
384+
run: |
385+
pwd
386+
ls
387+
# remove the following line once aws-sdk-cpp fixes linux-shared/SimpleUDP.cpp
388+
perl -i -p -e 's/"-Werror"//' aws-sdk-cpp/cmake/compiler_settings.cmake
389+
mkdir -p build-aws-sdk-cpp || true
390+
mkdir -p install || true
391+
cd build-aws-sdk-cpp
392+
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
393+
make
394+
make install
395+
396+
- name: Build C-ESDK
397+
if: matrix.decrypting_language == 'c' && matrix.os != 'ubuntu-22.04'
398+
working-directory: ./${{ matrix.library }}/aws-encryption-sdk-c
399+
run: |
400+
mkdir build-aws-encryption-sdk-c || true
401+
cd build-aws-encryption-sdk-c
402+
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/[email protected]" ../
403+
xcodebuild -target ALL_BUILD
404+
xcodebuild -scheme RUN_TESTS
405+
406+
- name: Build C-ESDK
407+
if: matrix.decrypting_language == 'c' && matrix.os == 'ubuntu-22.04'
408+
working-directory: ./${{ matrix.library }}/aws-encryption-sdk-c
409+
# 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
410+
run: |
411+
mkdir build-aws-encryption-sdk-c || true
412+
cd build-aws-encryption-sdk-c
413+
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 ..
414+
make
415+
make test
416+
make install
417+
250418
# Set up runtimes
251419
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
252420
if: matrix.decrypting_language == 'net'
@@ -382,5 +550,16 @@ jobs:
382550
path: ./${{matrix.library}}/runtimes/${{matrix.decrypting_language}}
383551

384552
- name: Decrypt Encrypt Manifest
553+
if: matrix.decrypting_language != 'c'
385554
working-directory: ./${{ matrix.library }}
386555
run: make test_decrypt_encrypt_vectors_${{matrix.decrypting_language}}
556+
557+
- name: Decrypt Encrypt Manifest
558+
if: matrix.decrypting_language == 'c' && matrix.os == 'ubuntu-22.04'
559+
working-directory: ./${{ matrix.library }}
560+
run: make test_decrypt_encrypt_vectors_c_unix
561+
562+
- name: Decrypt Encrypt Manifest
563+
if: matrix.decrypting_language == 'c' && matrix.os != 'ubuntu-22.04'
564+
working-directory: ./${{ matrix.library }}
565+
run: make test_decrypt_encrypt_vectors_c_mac

TestVectors/Makefile

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,72 @@ _sed_types_file_add_extern:
337337
_sed_index_file_add_extern:
338338
@echo "No extern to process for ESDK TestVectors"
339339

340+
c_test_vectors:
341+
cd aws-encryption-sdk-c/tests/TestVectors; \
342+
g++ -g -ggdb --std=c++17 -o test_vectors -I../../include/ \
343+
base64.cpp do_decrypt.cpp do_encrypt.cpp parse_encrypt.cpp parse_keys.cpp test_vectors.cpp \
344+
-I/opt/homebrew/include/ -L/opt/homebrew/lib/ \
345+
-I../../install/include/ -L../../install/lib/ -I ../../aws-encryption-sdk-cpp/include/ \
346+
../../build-aws-encryption-sdk-c/Debug/libaws-encryption-sdk.dylib \
347+
../../build-aws-encryption-sdk-c/aws-encryption-sdk-cpp/Debug/libaws-encryption-sdk-cpp.dylib \
348+
-laws-cpp-sdk-core -laws-cpp-sdk-kms -laws-c-common -lcrypto; \
349+
install_name_tool -add_rpath ../../build-aws-encryption-sdk-c/Debug/ test_vectors; \
350+
install_name_tool -add_rpath ../../build-aws-encryption-sdk-c/aws-encryption-sdk-cpp/Debug/ test_vectors; \
351+
install_name_tool -add_rpath ../../install/lib/ test_vectors
352+
353+
c_test_vectors_unix:
354+
cd aws-encryption-sdk-c/tests/TestVectors; \
355+
ls ../../install/; \
356+
ls ../../install/include/; \
357+
g++ -g -ggdb --std=c++17 -o test_vectors -I../../include/ \
358+
base64.cpp do_decrypt.cpp do_encrypt.cpp parse_encrypt.cpp parse_keys.cpp test_vectors.cpp \
359+
-I../../install/include/ -L../../install/lib/ -I ../../aws-encryption-sdk-cpp/include/ \
360+
-laws-encryption-sdk -laws-encryption-sdk-cpp \
361+
-laws-cpp-sdk-core -laws-cpp-sdk-kms -laws-c-common -lcrypto
362+
363+
test_encrypt_vectors_c_mac: c_test_vectors
364+
cd aws-encryption-sdk-c/tests/TestVectors; \
365+
rm -rf local; \
366+
mkdir -p local; \
367+
LD_LIBRARY_PATH=../../install/lib/ ./test_vectors encrypt --manifest-path ./from-dafny --decrypt-manifest-path ./local
368+
mkdir -p ./runtimes/c/
369+
cp aws-encryption-sdk-c/tests/TestVectors/local/*.json ./runtimes/c/
370+
mv ./runtimes/c/decrypt-manifest.json ./runtimes/c/manifest.json
371+
cp -r aws-encryption-sdk-c/tests/TestVectors/local/plaintexts/ ./runtimes/c/plaintexts/
372+
cp -r aws-encryption-sdk-c/tests/TestVectors/local/ciphertexts/ ./runtimes/c/ciphertexts/
373+
374+
test_encrypt_vectors_c_unix: c_test_vectors_unix
375+
cd aws-encryption-sdk-c/tests/TestVectors; \
376+
rm -rf local; \
377+
mkdir -p local; \
378+
LD_LIBRARY_PATH=../../install/lib/ ./test_vectors encrypt --manifest-path ./from-dafny --decrypt-manifest-path ./local
379+
mkdir -p ./runtimes/c/
380+
pwd
381+
ls -l aws-encryption-sdk-c/tests/TestVectors/
382+
ls -l aws-encryption-sdk-c/tests/TestVectors/local/
383+
cp aws-encryption-sdk-c/tests/TestVectors/local/*.json ./runtimes/c/
384+
mv ./runtimes/c/decrypt-manifest.json ./runtimes/c/manifest.json
385+
cp -r aws-encryption-sdk-c/tests/TestVectors/local/plaintexts/ ./runtimes/c/plaintexts/
386+
cp -r aws-encryption-sdk-c/tests/TestVectors/local/ciphertexts/ ./runtimes/c/ciphertexts/
387+
388+
test_decrypt_encrypt_vectors_c_mac: c_test_vectors
389+
mkdir -p aws-encryption-sdk-c/tests/TestVectors/local/
390+
cp ./runtimes/c/*.json aws-encryption-sdk-c/tests/TestVectors/local/
391+
cp -r ./runtimes/c/plaintexts/ aws-encryption-sdk-c/tests/TestVectors/local/plaintexts/
392+
cp -r ./runtimes/c/ciphertexts/ aws-encryption-sdk-c/tests/TestVectors/local/ciphertexts/
393+
cd aws-encryption-sdk-c/tests/TestVectors; \
394+
LD_LIBRARY_PATH=../../install/lib/ ./test_vectors decrypt --manifest-path ./local --manifest-name manifest.json
395+
396+
test_decrypt_encrypt_vectors_c_unix: c_test_vectors_unix
397+
mkdir -p aws-encryption-sdk-c/tests/TestVectors/local/
398+
pwd
399+
ls -l ./runtimes/c/
400+
cp ./runtimes/c/*.json aws-encryption-sdk-c/tests/TestVectors/local/
401+
cp -r ./runtimes/c/plaintexts/ aws-encryption-sdk-c/tests/TestVectors/local/plaintexts/
402+
cp -r ./runtimes/c/ciphertexts/ aws-encryption-sdk-c/tests/TestVectors/local/ciphertexts/
403+
cd aws-encryption-sdk-c/tests/TestVectors; \
404+
LD_LIBRARY_PATH=../../install/lib/ ./test_vectors decrypt --manifest-path ./local --manifest-name manifest.json
405+
340406
PYTHON_MODULE_NAME=aws_encryption_sdk_test_vectors
341407

342408
TRANSLATION_RECORD_PYTHON := \
@@ -356,4 +422,4 @@ PYTHON_DEPENDENCY_MODULE_NAMES := \
356422
--dependency-library-name=aws.cryptography.keyStore=aws_cryptographic_material_providers \
357423
--dependency-library-name=smithy.api=aws_cryptographic_material_providers \
358424
--dependency-library-name=aws.cryptography.materialProvidersTestVectorKeys=aws_cryptographic_material_providers_test_vectors \
359-
--dependency-library-name=aws.cryptography.encryptionSdk=aws_encryption_sdk_dafny
425+
--dependency-library-name=aws.cryptography.encryptionSdk=aws_encryption_sdk_dafny

0 commit comments

Comments
 (0)