-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile.wolfcrypt
More file actions
100 lines (87 loc) · 3.58 KB
/
Copy pathDockerfile.wolfcrypt
File metadata and controls
100 lines (87 loc) · 3.58 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
# Stage 1: build the Rust simulator TCP server
FROM rust:1.85-bookworm AS sim-builder
WORKDIR /app
COPY atecc608-sim/ /app/atecc608-sim/
RUN cd /app/atecc608-sim && cargo build --release --bin tcp_server 2>&1
# =============================================================================
# Stage 2: build cryptoauthlib + wolfSSL + test binary
# =============================================================================
FROM debian:bookworm
RUN apt-get update && apt-get install -y \
build-essential autoconf automake libtool cmake git pkg-config \
libssl-dev python3 \
&& rm -rf /var/lib/apt/lists/*
COPY --from=sim-builder /app/atecc608-sim/target/release/tcp_server /app/atecc608-sim-server
# ---- Build cryptoauthlib (custom HAL; no OpenSSL/I2C backends) ----
WORKDIR /app
RUN git clone --branch v3.7.8 --depth 1 \
https://github.com/MicrochipTech/cryptoauthlib.git /app/cryptoauthlib
RUN mkdir -p /app/cryptoauthlib/build && cd /app/cryptoauthlib/build && \
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS="-fPIC" \
-DATCA_HAL_CUSTOM=ON \
-DATCA_HAL_I2C=OFF \
-DATCA_HAL_SPI=OFF \
-DATCA_HAL_KIT_UART=OFF \
-DATCA_HAL_KIT_HID=OFF \
-DATCA_HAL_KIT_BRIDGE=OFF \
-DATCA_BUILD_SHARED_LIBS=OFF \
-DATCA_OPENSSL=OFF \
-DATCA_ATECC608_SUPPORT=ON \
-DATCA_PRINTF=ON \
2>&1 && \
cmake --build . -j$(nproc) 2>&1 && \
cmake --install . 2>&1
# cryptoauthlib installs its headers under /usr/include/cryptoauthlib/ (not
# /usr/local/include), and wolfSSL's atmel.h uses `#include <cryptoauthlib.h>`
# — without a subdirectory prefix — so expose the headers directly on a
# default search path.
RUN cp -r /usr/include/cryptoauthlib/* /usr/include/ && \
cp /app/cryptoauthlib/build/lib/atca_config.h /usr/include/atca_config.h
# ---- Build wolfSSL with --enable-cryptauthlib / WOLFSSL_ATECC608A ----
# No circular dependency: cryptoauthlib doesn't depend on wolfSSL, so a
# single-pass wolfSSL build against the installed cryptoauthlib is enough.
RUN git clone --depth 1 https://github.com/wolfSSL/wolfssl.git /app/wolfssl
# Build wolfSSL as a library only; the test binary has its own curated
# wolfCrypt-API exercise in main.c.
RUN cd /app/wolfssl && ./autogen.sh && \
./configure \
--enable-microchip=608 \
--with-cryptoauthlib=/usr \
--enable-ecc \
--enable-sha384 \
--enable-sha512 \
--enable-keygen \
--enable-fastmath \
--disable-examples \
CFLAGS="-DWOLFSSL_ATECC_NO_ECDH_ENC \
-DECC_USER_CURVES -DHAVE_ECC256 \
-DNO_ECC_VECTOR_TEST \
-Wno-unused-parameter -Wno-implicit-function-declaration \
-Wno-nested-externs -Wno-error" \
2>&1 && \
make -j$(nproc) 2>&1 && \
make install 2>&1 && \
ldconfig
# ---- Build test binary ----
COPY wolfcrypt-test/ /app/wolfcrypt-test/
# Reuse hal_tcp.{c,h} from sdk-test so there's only one HAL source of truth.
COPY sdk-test/hal_tcp.c /app/wolfcrypt-test/hal_tcp.c
COPY sdk-test/hal_tcp.h /app/wolfcrypt-test/hal_tcp.h
RUN gcc -o /app/wolfcrypt_atecc_test \
/app/wolfcrypt-test/main.c \
/app/wolfcrypt-test/hal_tcp.c \
/app/wolfssl/wolfcrypt/test/test.c \
-DNO_MAIN_DRIVER \
-DWOLFSSL_ATECC608A \
-DECC_USER_CURVES -DHAVE_ECC256 \
-DNO_ECC_VECTOR_TEST \
-I/app/wolfcrypt-test \
-I/app/wolfssl \
-L/usr/local/lib \
-lwolfssl -lcryptoauth -lm -lpthread \
2>&1
COPY wolfcrypt-test/run_test.sh /app/run_test.sh
RUN chmod +x /app/run_test.sh
CMD ["/app/run_test.sh"]