Skip to content
Open
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
9 changes: 9 additions & 0 deletions ci_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@
"boost"
]
},
"aws-c-cal": {
"build_options": [
"aws-c-cal:tests=enabled"
],
"alpine_packages": [
"openssl-dev",
"openssl"
]
},
"aws-c-common": {
"build_options": [
"aws-c-common:tests=enabled"
Expand Down
8 changes: 8 additions & 0 deletions releases.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,14 @@
"0.4.1-1"
]
},
"aws-c-cal": {
"dependency_names": [
"aws-c-cal"
],
"versions": [
"0.9.10-1"
]
},
"aws-c-common": {
"dependency_names": [
"aws-c-common"
Expand Down
9 changes: 9 additions & 0 deletions subprojects/aws-c-cal.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[wrap-file]
directory = aws-c-cal-0.9.10
source_url = https://github.com/awslabs/aws-c-cal/archive/refs/tags/v0.9.10.tar.gz
source_filename = aws-c-cal-0.9.10.tar.gz
source_hash = a41b389e942fadd599a6a0f692b75480d663f1e702c0301177f00f365e0c9b94
patch_directory = aws-c-cal

[provide]
dependency_names = aws-c-cal
18 changes: 18 additions & 0 deletions subprojects/packagefiles/aws-c-cal/generate_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env python3

import sys

# Usage: generate_tests.py <input test names file> <output C file>
if __name__ == '__main__':
with open(sys.argv[1], 'r') as test_names:
tests = [line.strip() for line in test_names if line.strip()]
with open(sys.argv[2], 'w') as out:
out.write('/* Auto-generated file, do not edit */\n\n#include <string.h>\n\n')
for name in tests:
out.write(f'extern int {name}(int argc, char **argv);\n')
out.write('\n')
out.write('int main(int argc, char **argv) {\n')
for name in tests:
out.write(f' if (strcmp(argv[1], "{name}") == 0) return {name}(argc, argv);\n')
out.write(' return 0;\n')
out.write('}\n')
17 changes: 17 additions & 0 deletions subprojects/packagefiles/aws-c-cal/include/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
install_headers(
'aws/cal/cal.h',
'aws/cal/ecc.h',
'aws/cal/ed25519.h',
'aws/cal/exports.h',
'aws/cal/hash.h',
'aws/cal/hkdf.h',
'aws/cal/hmac.h',
'aws/cal/rsa.h',
'aws/cal/symmetric_cipher.h',
'aws/cal/private/der.h',
'aws/cal/private/ecc.h',
'aws/cal/private/opensslcrypto_common.h',
'aws/cal/private/rsa.h',
'aws/cal/private/symmetric_cipher_priv.h',
preserve_path: true,
)
187 changes: 187 additions & 0 deletions subprojects/packagefiles/aws-c-cal/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
project(
'aws-c-cal',
'c',
version: '0.9.10',
meson_version: '>=0.63.0',

Check notice on line 5 in subprojects/packagefiles/aws-c-cal/meson.build

View workflow job for this annotation

GitHub Actions / Ubuntu (x86_64)

Minimum Meson version is 0.63.0

0.38.0: build_by_default arg in executable, build_by_default arg in static_library 0.42.0: extra_cflags arg in pkgconfig.generate 0.46.0: pkgconfig.generate optional positional argument 0.47.0: User option "feature" 0.53.0: module fs 0.54.0: meson.override_dependency 0.57.0: fs.read 0.59.0: feature_option.disable_auto_if() 0.63.0: preserve_path arg in install_headers
license: 'Apache-2.0',
)

cc = meson.get_compiler('c')
fs = import('fs')
pkg = import('pkgconfig')

tests_opt = get_option('tests').disable_auto_if(meson.is_subproject())
ed25519_everywhere = get_option('ed25519_everywhere')

public_c_args = ['-DAWS_CAL_USE_IMPORT_EXPORT=1']
c_args = ['-DAWS_CAL_EXPORTS=1']

if host_machine.system() == 'windows' and host_machine.cpu_family() in [
'x86',
'aarch64',
]
error('unsupported architecture: only x86_64 Windows is supported')
endif

aws_c_common_dep = dependency('aws-c-common')
libcrypto_dep = dependency(
'libcrypto',
version: '>=1.1',
)
ncrypt = cc.find_library(
'ncrypt',
required: host_machine.system() == 'windows',
)

foundation = dependency(
'appleframeworks',
modules: ['Security', 'CoreFoundation'],
required: host_machine.system() == 'darwin',
)

src = files(
'source/cal.c',
'source/der.c',
'source/ecc.c',
'source/ed25519.c',
'source/hash.c',
'source/hkdf.c',
'source/hmac.c',
'source/rsa.c',
'source/shared/ref_hkdf.c',
'source/symmetric_cipher.c',
)

if ed25519_everywhere or host_machine.system() == 'linux'
src += files('source/shared/ed25519.c', 'source/shared/lccrypto_common.c')
c_args = ['-DAWS_USE_LIBCRYPTO_TO_SUPPORT_ED25519_EVERYWHERE']
else
src += files('source/shared/ed25519_noop.c')
endif

if host_machine.system() in ['cygwin', 'windows']
src += files(
'source/windows/bcrypt_aes.c',
'source/windows/bcrypt_ecc.c',
'source/windows/bcrypt_hash.c',
'source/windows/bcrypt_hmac.c',
'source/windows/bcrypt_platform_init.c',
'source/windows/bcrypt_rsa.c',
)
elif host_machine.system() == 'darwin'
src += files(
'source/darwin/commoncrypto_aes.c',
'source/darwin/commoncrypto_hmac.c',
'source/darwin/commoncrypto_md5.c',
'source/darwin/commoncrypto_platform_init.c',
'source/darwin/commoncrypto_sha1.c',
'source/darwin/commoncrypto_sha256.c',
'source/darwin/commoncrypto_sha512.c',
'source/darwin/securityframework_ecc.c',
'source/darwin/securityframework_rsa.c',
)
elif host_machine.system() == 'linux'
src += files(
'source/unix/openssl_aes.c',
'source/unix/openssl_platform_init.c',
'source/unix/openssl_rsa.c',
'source/unix/opensslcrypto_ecc.c',
'source/unix/opensslcrypto_hash.c',
'source/unix/opensslcrypto_hmac.c',
)
else
error('Unsupported platform: ' + host_machine.system())
endif

inc = include_directories('include')

libaws_c_cal = library(
'aws-c-cal',
src,
c_args: c_args + public_c_args,
dependencies: [aws_c_common_dep, libcrypto_dep, ncrypt, foundation],
include_directories: inc,
version: meson.project_version(),
)

aws_c_cal_dep = declare_dependency(
link_with: libaws_c_cal,
include_directories: inc,
dependencies: aws_c_common_dep,
compile_args: public_c_args,
)

meson.override_dependency('aws-c-cal', aws_c_cal_dep)

pkg.generate(
libaws_c_cal,
extra_cflags: public_c_args,
description: 'Aws Crypto Abstraction Layer: Cross-Platform, C99 wrapper for cryptography primitives.',
)

subdir('include')

generate_tests = find_program(
'generate_tests.py',
required: tests_opt,
)
run_test = find_program(
'run_test.py',
required: tests_opt,
)

if generate_tests.found() and run_test.found()
test_src = files(
'tests/aes256_test.c',
'tests/der_test.c',
'tests/ecc_test.c',
'tests/ed25519_test.c',
'tests/hkdf_test.c',
'tests/md5_test.c',
'tests/rsa_test.c',
'tests/sha1_test.c',
'tests/sha256_hmac_test.c',
'tests/sha256_test.c',
'tests/sha512_hmac_test.c',
'tests/sha512_test.c',
)

libtestcases = static_library(
'aws_c_cal_testcases',
test_src,
dependencies: [aws_c_cal_dep],
c_args: ['-DAWS_UNSTABLE_TESTING_API=1'],
include_directories: inc,
build_by_default: false,
)

# implements an approximation of cmakes create_test_sourcelist
test_harness_src = custom_target(
'generate_test_harness',
input: 'tests.txt',
output: 'test_harness.c',
command: [generate_tests, '@INPUT@', '@OUTPUT@'],
)

test_harness = executable(
'aws-c-cal-tests',
test_harness_src,
dependencies: [aws_c_cal_dep],
link_with: [libtestcases],
c_args: ['-DAWS_UNSTABLE_TESTING_API=1'],
include_directories: inc,
build_by_default: false,
)

names = fs.read('tests.txt').split('\n')

foreach name : names
test(
name,
run_test,
args: [test_harness, name],
workdir: meson.current_source_dir(),
timeout: 600,
)
endforeach
endif
12 changes: 12 additions & 0 deletions subprojects/packagefiles/aws-c-cal/meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
option(
'tests',
type: 'feature',
description: 'Build aws-c-cal unit tests',
)

option(
'ed25519_everywhere',
type: 'boolean',
value: false,
description: 'Experimental feature to support ED25519 keygen on platforms that do not support it in os libs (i.e. win/mac)',
)
14 changes: 14 additions & 0 deletions subprojects/packagefiles/aws-c-cal/run_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env python3

import sys

# Usage: run_test.py <test exe> [args...]
if __name__ == '__main__':
test_exe = sys.argv[1]
test_args = sys.argv[2:]
import subprocess
result = subprocess.run([test_exe] + test_args)
exitcode = result.returncode
if exitcode == 103:
exitcode = 77 # Skip code for meson
sys.exit(exitcode)
Loading
Loading