Skip to content

Commit 59515a8

Browse files
committed
aws-c-cal: add 0.9.10
1 parent d4c1f59 commit 59515a8

File tree

10 files changed

+449
-0
lines changed

10 files changed

+449
-0
lines changed

ci_config.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@
7676
"boost"
7777
]
7878
},
79+
"aws-c-cal": {
80+
"build_options": [
81+
"aws-c-cal:tests=enabled"
82+
],
83+
"alpine_packages": [
84+
"openssl-dev",
85+
"openssl"
86+
]
87+
},
7988
"aws-c-common": {
8089
"build_options": [
8190
"aws-c-common:tests=enabled"

releases.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,14 @@
244244
"0.4.1-1"
245245
]
246246
},
247+
"aws-c-cal": {
248+
"dependency_names": [
249+
"aws-c-cal"
250+
],
251+
"versions": [
252+
"0.9.10-1"
253+
]
254+
},
247255
"aws-c-common": {
248256
"dependency_names": [
249257
"aws-c-common"

subprojects/aws-c-cal.wrap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[wrap-file]
2+
directory = aws-c-cal-0.9.10
3+
source_url = https://github.com/awslabs/aws-c-cal/archive/refs/tags/v0.9.10.tar.gz
4+
source_filename = aws-c-cal-0.9.10.tar.gz
5+
source_hash = a41b389e942fadd599a6a0f692b75480d663f1e702c0301177f00f365e0c9b94
6+
patch_directory = aws-c-cal
7+
8+
[provide]
9+
dependency_names = aws-c-cal
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env python3
2+
3+
import sys
4+
5+
# Usage: generate_tests.py <input test names file> <output C file>
6+
if __name__ == '__main__':
7+
with open(sys.argv[1], 'r') as test_names:
8+
tests = [line.strip() for line in test_names if line.strip()]
9+
with open(sys.argv[2], 'w') as out:
10+
out.write('/* Auto-generated file, do not edit */\n\n#include <string.h>\n\n')
11+
for name in tests:
12+
out.write(f'extern int {name}(int argc, char **argv);\n')
13+
out.write('\n')
14+
out.write('int main(int argc, char **argv) {\n')
15+
for name in tests:
16+
out.write(f' if (strcmp(argv[1], "{name}") == 0) return {name}(argc, argv);\n')
17+
out.write(' return 0;\n')
18+
out.write('}\n')
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
install_headers(
2+
'aws/cal/cal.h',
3+
'aws/cal/ecc.h',
4+
'aws/cal/ed25519.h',
5+
'aws/cal/exports.h',
6+
'aws/cal/hash.h',
7+
'aws/cal/hkdf.h',
8+
'aws/cal/hmac.h',
9+
'aws/cal/rsa.h',
10+
'aws/cal/symmetric_cipher.h',
11+
'aws/cal/private/der.h',
12+
'aws/cal/private/ecc.h',
13+
'aws/cal/private/opensslcrypto_common.h',
14+
'aws/cal/private/rsa.h',
15+
'aws/cal/private/symmetric_cipher_priv.h',
16+
preserve_path: true,
17+
)
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
project(
2+
'aws-c-cal',
3+
'c',
4+
version: '0.9.10',
5+
meson_version: '>=0.63.0',
6+
license: 'Apache-2.0',
7+
)
8+
9+
cc = meson.get_compiler('c')
10+
fs = import('fs')
11+
pkg = import('pkgconfig')
12+
13+
tests_opt = get_option('tests').disable_auto_if(meson.is_subproject())
14+
ed25519_everywhere = get_option('ed25519_everywhere')
15+
16+
public_c_args = ['-DAWS_CAL_USE_IMPORT_EXPORT=1']
17+
c_args = ['-DAWS_CAL_EXPORTS=1']
18+
19+
if host_machine.system() == 'windows' and host_machine.cpu_family() in [
20+
'x86',
21+
'aarch64',
22+
]
23+
error('unsupported architecture: only x86_64 Windows is supported')
24+
endif
25+
26+
aws_c_common_dep = dependency('aws-c-common')
27+
libcrypto_dep = dependency(
28+
'libcrypto',
29+
version: '>=1.1',
30+
)
31+
ncrypt = cc.find_library(
32+
'ncrypt',
33+
required: host_machine.system() == 'windows',
34+
)
35+
36+
foundation = dependency(
37+
'appleframeworks',
38+
modules: ['Security', 'CoreFoundation'],
39+
required: host_machine.system() == 'darwin',
40+
)
41+
42+
src = files(
43+
'source/cal.c',
44+
'source/der.c',
45+
'source/ecc.c',
46+
'source/ed25519.c',
47+
'source/hash.c',
48+
'source/hkdf.c',
49+
'source/hmac.c',
50+
'source/rsa.c',
51+
'source/shared/ref_hkdf.c',
52+
'source/symmetric_cipher.c',
53+
)
54+
55+
if ed25519_everywhere or host_machine.system() == 'linux'
56+
src += files('source/shared/ed25519.c', 'source/shared/lccrypto_common.c')
57+
c_args = ['-DAWS_USE_LIBCRYPTO_TO_SUPPORT_ED25519_EVERYWHERE']
58+
else
59+
src += files('source/shared/ed25519_noop.c')
60+
endif
61+
62+
if host_machine.system() in ['cygwin', 'windows']
63+
src += files(
64+
'source/windows/bcrypt_aes.c',
65+
'source/windows/bcrypt_ecc.c',
66+
'source/windows/bcrypt_hash.c',
67+
'source/windows/bcrypt_hmac.c',
68+
'source/windows/bcrypt_platform_init.c',
69+
'source/windows/bcrypt_rsa.c',
70+
)
71+
elif host_machine.system() == 'darwin'
72+
src += files(
73+
'source/darwin/commoncrypto_aes.c',
74+
'source/darwin/commoncrypto_hmac.c',
75+
'source/darwin/commoncrypto_md5.c',
76+
'source/darwin/commoncrypto_platform_init.c',
77+
'source/darwin/commoncrypto_sha1.c',
78+
'source/darwin/commoncrypto_sha256.c',
79+
'source/darwin/commoncrypto_sha512.c',
80+
'source/darwin/securityframework_ecc.c',
81+
'source/darwin/securityframework_rsa.c',
82+
)
83+
elif host_machine.system() == 'linux'
84+
src += files(
85+
'source/unix/openssl_aes.c',
86+
'source/unix/openssl_platform_init.c',
87+
'source/unix/openssl_rsa.c',
88+
'source/unix/opensslcrypto_ecc.c',
89+
'source/unix/opensslcrypto_hash.c',
90+
'source/unix/opensslcrypto_hmac.c',
91+
)
92+
else
93+
error('Unsupported platform: ' + host_machine.system())
94+
endif
95+
96+
inc = include_directories('include')
97+
98+
libaws_c_cal = library(
99+
'aws-c-cal',
100+
src,
101+
c_args: c_args + public_c_args,
102+
dependencies: [aws_c_common_dep, libcrypto_dep, ncrypt, foundation],
103+
include_directories: inc,
104+
version: meson.project_version(),
105+
)
106+
107+
aws_c_cal_dep = declare_dependency(
108+
link_with: libaws_c_cal,
109+
include_directories: inc,
110+
compile_args: public_c_args,
111+
)
112+
113+
meson.override_dependency('aws-c-cal', aws_c_cal_dep)
114+
115+
pkg.generate(
116+
libaws_c_cal,
117+
extra_cflags: public_c_args,
118+
description: 'Aws Crypto Abstraction Layer: Cross-Platform, C99 wrapper for cryptography primitives.',
119+
)
120+
121+
subdir('include')
122+
123+
generate_tests = find_program(
124+
'generate_tests.py',
125+
required: tests_opt,
126+
)
127+
run_test = find_program(
128+
'run_test.py',
129+
required: tests_opt,
130+
)
131+
132+
if generate_tests.found() and run_test.found()
133+
test_src = files(
134+
'tests/aes256_test.c',
135+
'tests/der_test.c',
136+
'tests/ecc_test.c',
137+
'tests/ed25519_test.c',
138+
'tests/hkdf_test.c',
139+
'tests/md5_test.c',
140+
'tests/rsa_test.c',
141+
'tests/sha1_test.c',
142+
'tests/sha256_hmac_test.c',
143+
'tests/sha256_test.c',
144+
'tests/sha512_hmac_test.c',
145+
'tests/sha512_test.c',
146+
)
147+
148+
libtestcases = static_library(
149+
'aws_c_cal_testcases',
150+
test_src,
151+
dependencies: [aws_c_cal_dep, aws_c_common_dep],
152+
c_args: ['-DAWS_UNSTABLE_TESTING_API=1'],
153+
include_directories: inc,
154+
build_by_default: false,
155+
)
156+
157+
# implements an approximation of cmakes create_test_sourcelist
158+
test_harness_src = custom_target(
159+
'generate_test_harness',
160+
input: 'tests.txt',
161+
output: 'test_harness.c',
162+
command: [generate_tests, '@INPUT@', '@OUTPUT@'],
163+
)
164+
165+
test_harness = executable(
166+
'aws-c-cal-tests',
167+
test_harness_src,
168+
dependencies: [aws_c_cal_dep, aws_c_common_dep],
169+
link_with: [libtestcases],
170+
c_args: ['-DAWS_UNSTABLE_TESTING_API=1'],
171+
include_directories: inc,
172+
build_by_default: false,
173+
)
174+
175+
names = fs.read('tests.txt').split('\n')
176+
177+
foreach name : names
178+
test(
179+
name,
180+
run_test,
181+
args: [test_harness, name],
182+
workdir: meson.current_source_dir(),
183+
timeout: 600,
184+
)
185+
endforeach
186+
endif
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
option(
2+
'tests',
3+
type: 'feature',
4+
description: 'Build aws-c-cal unit tests',
5+
)
6+
7+
option(
8+
'ed25519_everywhere',
9+
type: 'boolean',
10+
value: false,
11+
description: 'Experimental feature to support ED25519 keygen on platforms that do not support it in os libs (i.e. win/mac)',
12+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env python3
2+
3+
import sys
4+
5+
# Usage: run_test.py <test exe> [args...]
6+
if __name__ == '__main__':
7+
test_exe = sys.argv[1]
8+
test_args = sys.argv[2:]
9+
import subprocess
10+
result = subprocess.run([test_exe] + test_args)
11+
exitcode = result.returncode
12+
if exitcode == 103:
13+
exitcode = 77 # Skip code for meson
14+
sys.exit(exitcode)

0 commit comments

Comments
 (0)