Repository navigation
Expand file tree
/
Copy pathDockerfile.wolfcrypt
More file actions
125 lines (110 loc) · 4.64 KB
/
Copy pathDockerfile.wolfcrypt
File metadata and controls
125 lines (110 loc) · 4.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Dockerfile.wolfcrypt
#
# Copyright (C) 2026 wolfSSL Inc.
#
# This file is part of STSAFEA120Sim.
#
# STSAFEA120Sim is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# Stage 1: build the Rust simulator TCP server
FROM rust:1.85-bookworm AS sim-builder
WORKDIR /app
COPY stsafe-a120-sim/ /app/stsafe-a120-sim/
RUN cd /app/stsafe-a120-sim && cargo build --release --bin tcp_server 2>&1
# =============================================================================
# Stage 2: build STSELib + wolfSSL + integration test
# =============================================================================
FROM debian:bookworm
RUN apt-get update && apt-get install -y \
build-essential autoconf automake libtool git pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
COPY --from=sim-builder /app/stsafe-a120-sim/target/release/tcp_server /app/tcp_server
# ---- STSELib v1.1.7 (open-source A120 middleware) ----
ARG STSELIB_TAG=v1.1.7
RUN git clone --branch ${STSELIB_TAG} --depth 1 \
https://github.com/STMicroelectronics/STSELib.git /app/STSELib
# ---- PAL + STSELib feature config (reused from sdk-test) ----
COPY sdk-test/ /app/sdk-test/
# ---- Build STSELib + PAL into a shared library so wolfSSL's link step
# can resolve stse_* symbols when stsafe.c is compiled into libwolfssl. ----
WORKDIR /app/build
RUN set -eux; \
SOURCES=$(find /app/STSELib -name '*.c'); \
for src in $SOURCES; do \
gcc -c -O2 -fPIC \
-include /app/sdk-test/stse_platform_generic.h \
-I/app/STSELib \
-I/app/sdk-test \
-Wno-unused-parameter \
-Wno-misleading-indentation \
-Wno-unused-but-set-variable \
-o "$(basename ${src} .c).o" "${src}"; \
done; \
gcc -c -O2 -fPIC \
-include /app/sdk-test/stse_platform_generic.h \
-I/app/STSELib \
-I/app/sdk-test \
-Wno-unused-parameter \
-o pal_tcp.o /app/sdk-test/pal_tcp.c; \
gcc -shared -fPIC -o /usr/local/lib/libstse.so *.o; \
ldconfig
# ---- wolfSSL with STSAFE-A120 support ----
ARG WOLFSSL_REF=master
RUN git clone --branch ${WOLFSSL_REF} --depth 1 \
https://github.com/wolfSSL/wolfssl.git /app/wolfssl
# wolfSSL's stsafe.c does `#include "stselib.h"`, which is the master
# header that drags in stse_platform_generic.h itself, so we only need
# the include path -- not a -include directive (the latter trips
# autoconf's `cannot make gcc report undeclared builtins` check during
# AC_CHECK_DECLS).
RUN cd /app/wolfssl && ./autogen.sh && \
./configure \
--enable-stsafe=a120 \
--enable-pkcallbacks \
--enable-cryptocb \
--enable-ecc \
--enable-sha256 \
--enable-sha384 \
--enable-keygen \
--disable-examples \
CFLAGS="-DHAVE_PK_CALLBACKS -DWOLF_CRYPTO_CB \
-I/app/STSELib -I/app/sdk-test \
-Wno-unused-parameter -Wno-error \
-Wno-error=strict-prototypes -Wno-error=nested-externs \
-Wno-error=missing-prototypes -Wno-error=missing-field-initializers \
-Wno-error=unused-but-set-variable -Wno-error=shadow \
-Wno-error=missing-noreturn -Wno-error=overflow \
-Wno-error=cast-function-type -Wno-error=switch-enum \
-Wno-error=pedantic -Wno-error=array-bounds \
-Wno-error=undef -Wno-error=incompatible-pointer-types" \
LIBS="-lstse" \
2>&1 && \
make -j$(nproc) 2>&1 && \
make install 2>&1 && \
ldconfig
# ---- Build integration test program ----
COPY wolfcrypt-test/ /app/wolfcrypt-test/
# `-include stse_platform_generic.h` is needed here because main.c
# includes stselib.h directly, and STSELib's master include orders
# stse_platform_generic.h *after* core/stse_platform.h -- types like
# `stse_perso_info_t` referenced inside stsafea_commands.h end up
# undefined without the pre-include. (No autoconf step downstream of
# this command, so the AC_CHECK_DECLS quirk that bit us during wolfSSL
# configure does not apply.)
RUN gcc -O2 -o /app/wolfcrypt_stsafe_test \
/app/wolfcrypt-test/main.c \
-DWOLFSSL_STSAFEA120 -DHAVE_PK_CALLBACKS -DWOLF_CRYPTO_CB \
-include /app/sdk-test/stse_platform_generic.h \
-I/app/STSELib \
-I/app/sdk-test \
-I/usr/local/include \
-L/usr/local/lib \
-lwolfssl -lstse -lpthread -lm
COPY wolfcrypt-test/run_test.sh /app/run_test.sh
RUN chmod +x /app/run_test.sh
ENV STSAFE_SIM_HOST=127.0.0.1
ENV STSAFE_SIM_PORT=8120
CMD ["/app/run_test.sh"]