Skip to content

Commit 50a7394

Browse files
committed
aws-c-cal: add 0.9.10
1 parent d4c1f59 commit 50a7394

File tree

10 files changed

+442
-0
lines changed

10 files changed

+442
-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: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
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+
aws_c_common_dep = dependency('aws-c-common')
20+
libcrypto_dep = dependency(
21+
'libcrypto',
22+
version: '>=1.1',
23+
)
24+
ncrypt = cc.find_library(
25+
'ncrypt',
26+
required: host_machine.system() == 'windows',
27+
)
28+
29+
foundation = dependency(
30+
'appleframeworks',
31+
modules: ['Security', 'CoreFoundation'],
32+
required: host_machine.system() == 'darwin',
33+
)
34+
35+
src = files(
36+
'source/cal.c',
37+
'source/der.c',
38+
'source/ecc.c',
39+
'source/ed25519.c',
40+
'source/hash.c',
41+
'source/hkdf.c',
42+
'source/hmac.c',
43+
'source/rsa.c',
44+
'source/shared/ref_hkdf.c',
45+
'source/symmetric_cipher.c',
46+
)
47+
48+
if ed25519_everywhere or host_machine.system() == 'linux'
49+
src += files('source/shared/ed25519.c', 'source/shared/lccrypto_common.c')
50+
c_args = ['-DAWS_USE_LIBCRYPTO_TO_SUPPORT_ED25519_EVERYWHERE']
51+
else
52+
src += files('source/shared/ed25519_noop.c')
53+
endif
54+
55+
if host_machine.system() in ['cygwin', 'windows']
56+
src += files(
57+
'source/windows/bcrypt_aes.c',
58+
'source/windows/bcrypt_ecc.c',
59+
'source/windows/bcrypt_hash.c',
60+
'source/windows/bcrypt_hmac.c',
61+
'source/windows/bcrypt_platform_init.c',
62+
'source/windows/bcrypt_rsa.c',
63+
)
64+
elif host_machine.system() == 'darwin'
65+
src += files(
66+
'source/darwin/commoncrypto_aes.c',
67+
'source/darwin/commoncrypto_hmac.c',
68+
'source/darwin/commoncrypto_md5.c',
69+
'source/darwin/commoncrypto_platform_init.c',
70+
'source/darwin/commoncrypto_sha1.c',
71+
'source/darwin/commoncrypto_sha256.c',
72+
'source/darwin/commoncrypto_sha512.c',
73+
'source/darwin/securityframework_ecc.c',
74+
'source/darwin/securityframework_rsa.c',
75+
)
76+
elif host_machine.system() == 'linux'
77+
src += files(
78+
'source/unix/openssl_aes.c',
79+
'source/unix/openssl_platform_init.c',
80+
'source/unix/openssl_rsa.c',
81+
'source/unix/opensslcrypto_ecc.c',
82+
'source/unix/opensslcrypto_hash.c',
83+
'source/unix/opensslcrypto_hmac.c',
84+
)
85+
else
86+
error('Unsupported platform: ' + host_machine.system())
87+
endif
88+
89+
inc = include_directories('include')
90+
91+
libaws_c_cal = library(
92+
'aws-c-cal',
93+
src,
94+
c_args: c_args + public_c_args,
95+
dependencies: [aws_c_common_dep, libcrypto_dep, ncrypt, foundation],
96+
include_directories: inc,
97+
version: meson.project_version(),
98+
)
99+
100+
aws_c_cal_dep = declare_dependency(
101+
link_with: libaws_c_cal,
102+
include_directories: inc,
103+
compile_args: public_c_args,
104+
)
105+
106+
meson.override_dependency('aws-c-cal', aws_c_cal_dep)
107+
108+
pkg.generate(
109+
libaws_c_cal,
110+
extra_cflags: public_c_args,
111+
description: 'Aws Crypto Abstraction Layer: Cross-Platform, C99 wrapper for cryptography primitives.',
112+
)
113+
114+
subdir('include')
115+
116+
generate_tests = find_program(
117+
'generate_tests.py',
118+
required: tests_opt,
119+
)
120+
run_test = find_program(
121+
'run_test.py',
122+
required: tests_opt,
123+
)
124+
125+
if generate_tests.found() and run_test.found()
126+
test_src = files(
127+
'tests/aes256_test.c',
128+
'tests/der_test.c',
129+
'tests/ecc_test.c',
130+
'tests/ed25519_test.c',
131+
'tests/hkdf_test.c',
132+
'tests/md5_test.c',
133+
'tests/rsa_test.c',
134+
'tests/sha1_test.c',
135+
'tests/sha256_hmac_test.c',
136+
'tests/sha256_test.c',
137+
'tests/sha512_hmac_test.c',
138+
'tests/sha512_test.c',
139+
)
140+
141+
libtestcases = static_library(
142+
'aws_c_cal_testcases',
143+
test_src,
144+
dependencies: [aws_c_cal_dep, aws_c_common_dep],
145+
c_args: ['-DAWS_UNSTABLE_TESTING_API=1'],
146+
include_directories: inc,
147+
build_by_default: false,
148+
)
149+
150+
# implements an approximation of cmakes create_test_sourcelist
151+
test_harness_src = custom_target(
152+
'generate_test_harness',
153+
input: 'tests.txt',
154+
output: 'test_harness.c',
155+
command: [generate_tests, '@INPUT@', '@OUTPUT@'],
156+
)
157+
158+
test_harness = executable(
159+
'aws-c-cal-tests',
160+
test_harness_src,
161+
dependencies: [aws_c_cal_dep, aws_c_common_dep],
162+
link_with: [libtestcases],
163+
c_args: ['-DAWS_UNSTABLE_TESTING_API=1'],
164+
include_directories: inc,
165+
build_by_default: false,
166+
)
167+
168+
names = fs.read('tests.txt').split('\n')
169+
170+
foreach name : names
171+
test(
172+
name,
173+
run_test,
174+
args: [test_harness, name],
175+
workdir: meson.current_source_dir(),
176+
timeout: 600,
177+
)
178+
endforeach
179+
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)