Skip to content

Commit 9de2634

Browse files
hanno-beckermkannwischer
authored andcommitted
aws-lc: Use OPENSSL_memcpy and OPENSSL_memset
This commit adjusts the config file used by AWS-LC to leverage the new customization mechanism for memset/memcpy to point to OpenSSL's OPENSSL_memset/OPENSSL_memcpy versions of those function. A patch is used to update the mlkem-native config used by AWS-LC; this should be removed once AWS-LC has updated the config. Signed-off-by: Hanno Becker <beckphan@amazon.co.uk>
1 parent 7b9fa33 commit 9de2634

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

.github/workflows/integration-awslc.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ jobs:
4444
run: |
4545
cd $AWSLC_DIR/crypto/fipsmodule/ml_kem
4646
GITHUB_REPOSITORY=$GITHUB_REPOSITORY GITHUB_SHA=$GITHUB_SHA ./importer.sh --force
47+
- name: Apply custom stdlib patch
48+
run: |
49+
cd $AWSLC_DIR
50+
patch -p0 < $GITHUB_WORKSPACE/integration/aws-lc/add-custom-stdlib.patch
4751
- name: Build+Test AWS-LC (FIPS=${{ matrix.fips }})
4852
run: |
4953
cd $AWSLC_DIR
@@ -91,6 +95,10 @@ jobs:
9195
run: |
9296
cd $AWSLC_DIR/crypto/fipsmodule/ml_kem
9397
GITHUB_REPOSITORY=$GITHUB_REPOSITORY GITHUB_SHA=$GITHUB_SHA ./importer.sh --force
98+
- name: Apply custom stdlib patch
99+
run: |
100+
cd $AWSLC_DIR
101+
patch -p0 < $GITHUB_WORKSPACE/integration/aws-lc/add-custom-stdlib.patch
94102
- name: Run test
95103
run: |
96104
cd $AWSLC_DIR
@@ -123,6 +131,10 @@ jobs:
123131
run: |
124132
cd $AWSLC_DIR/crypto/fipsmodule/ml_kem
125133
GITHUB_REPOSITORY=$GITHUB_REPOSITORY GITHUB_SHA=$GITHUB_SHA ./importer.sh --force
134+
- name: Apply custom stdlib patch
135+
run: |
136+
cd $AWSLC_DIR
137+
patch -p0 < $GITHUB_WORKSPACE/integration/aws-lc/add-custom-stdlib.patch
126138
- name: Run test
127139
run: |
128140
cd $AWSLC_DIR
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright (c) The mlkem-native project authors
2+
# SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
3+
--- crypto/fipsmodule/ml_kem/mlkem_native_config.h
4+
+++ crypto/fipsmodule/ml_kem/mlkem_native_config.h
5+
@@ -64,6 +64,26 @@
6+
}
7+
#endif // !__ASSEMBLER__
8+
9+
+// Map memcpy function to the one used by AWS-LC
10+
+#define MLK_CONFIG_CUSTOM_MEMCPY
11+
+#if !defined(__ASSEMBLER__)
12+
+#include <stdint.h>
13+
+#include "mlkem/sys.h"
14+
+static MLK_INLINE void *mlk_memcpy(void *dest, const void *src, size_t n) {
15+
+ return OPENSSL_memcpy(dest, src, n);
16+
+}
17+
+#endif // !__ASSEMBLER__
18+
+
19+
+// Map memset function to the one used by AWS-LC
20+
+#define MLK_CONFIG_CUSTOM_MEMSET
21+
+#if !defined(__ASSEMBLER__)
22+
+#include <stdint.h>
23+
+#include "mlkem/sys.h"
24+
+static MLK_INLINE void *mlk_memset(void *s, int c, size_t n) {
25+
+ return OPENSSL_memset(s, c, n);
26+
+}
27+
+#endif // !__ASSEMBLER__
28+
+
29+
#if defined(OPENSSL_NO_ASM)
30+
#define MLK_CONFIG_NO_ASM
31+
#endif

0 commit comments

Comments
 (0)