Skip to content

Commit ffb7f06

Browse files
authored
Merge pull request #23 from dgarske/pkcs11_tpm
PKCS11 TPM support
2 parents d6f8c0c + a7782fc commit ffb7f06

File tree

12 files changed

+573
-149
lines changed

12 files changed

+573
-149
lines changed

.github/workflows/build-workflow.yml

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
config:
88
required: false
99
type: string
10+
check:
11+
required: false
12+
type: string
13+
default: 'make check'
1014

1115
jobs:
1216
build:
@@ -30,7 +34,7 @@ jobs:
3034
- name: wolfssl configure
3135
working-directory: ./wolfssl
3236
run: |
33-
./configure --enable-cryptonly --enable-aescfb --enable-rsapss --enable-keygen --enable-pwdbased --enable-scrypt \
37+
./configure --enable-cryptocb --enable-aescfb --enable-rsapss --enable-keygen --enable-pwdbased --enable-scrypt \
3438
C_EXTRA_FLAGS="-DWOLFSSL_PUBLIC_MP -DWC_RSA_DIRECT"
3539
- name: wolfssl make install
3640
working-directory: ./wolfssl
@@ -41,6 +45,38 @@ jobs:
4145
sudo make install
4246
sudo ldconfig
4347
48+
#setup ibmswtpm2
49+
- uses: actions/checkout@v3
50+
with:
51+
repository: kgoldman/ibmswtpm2
52+
path: ibmswtpm2
53+
- name: ibmswtpm2 make
54+
working-directory: ./ibmswtpm2/src
55+
run: |
56+
make
57+
./tpm_server &
58+
59+
#setup wolftpm
60+
- uses: actions/checkout@v3
61+
with:
62+
repository: wolfssl/wolftpm
63+
path: wolftpm
64+
- name: wolftpm autogen
65+
working-directory: ./wolftpm
66+
run: ./autogen.sh
67+
- name: wolftpm configure
68+
working-directory: ./wolftpm
69+
run: |
70+
./configure --enable-swtpm
71+
- name: wolftpm make install
72+
working-directory: ./wolftpm
73+
run: make
74+
- name: wolftpm make install
75+
working-directory: ./wolftpm
76+
run: |
77+
sudo make install
78+
sudo ldconfig
79+
4480
#setup wolfPKCS11
4581
- name: wolfpkcs11 autogen
4682
run: ./autogen.sh
@@ -49,7 +85,7 @@ jobs:
4985
- name: wolfpkcs11 make
5086
run: make
5187
- name: wolfpkcs11 make check
52-
run: make check
88+
run: ${{inputs.check}}
5389
- name: wolfpkcs11 make install
5490
run: sudo make install
5591
- name: wolfpkcs11 make dist

.github/workflows/unit-test.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: wolfPKCS11 Build Tests
22

33
on:
44
push:
5-
branches: [ '*' ]
5+
branches: [ 'master', 'main', 'release/**' ]
66
pull_request:
77
branches: [ '*' ]
88

@@ -11,6 +11,17 @@ jobs:
1111
defaults_all:
1212
uses: ./.github/workflows/build-workflow.yml
1313

14+
single_theaded:
15+
uses: ./.github/workflows/build-workflow.yml
16+
with:
17+
config: --enable-singlethreaded
18+
19+
tpm:
20+
uses: ./.github/workflows/build-workflow.yml
21+
with:
22+
config: --enable-singlethreaded --enable-wolftpm --disable-dh CFLAGS="-DWOLFPKCS11_TPM_STORE"
23+
check: ./tests/pkcs11str && ./tests/pkcs11test
24+
1425
no_rsa:
1526
uses: ./.github/workflows/build-workflow.yml
1627
with:

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Build wolfSSL:
1313
git clone https://github.com/wolfSSL/wolfssl.git
1414
cd wolfssl
1515
./autogen.sh
16-
./configure --enable-rsapss --enable-keygen --enable-pwdbased --enable-scrypt C_EXTRA_FLAGS="-DWOLFSSL_PUBLIC_MP -DWC_RSA_DIRECT"
16+
./configure --enable-aescfb --enable-cryptocb --enable-rsapss --enable-keygen --enable-pwdbased --enable-scrypt C_EXTRA_FLAGS="-DWOLFSSL_PUBLIC_MP -DWC_RSA_DIRECT"
1717
make
1818
make check
1919
sudo make install
@@ -33,12 +33,29 @@ make
3333
make check
3434
```
3535

36+
37+
### TPM support with wolfTPM
38+
39+
Enables using a TPM for cryptography and keystore.
40+
Tested using `./configure --enable-singlethreaded --enable-wolftpm --disable-dh CFLAGS="-DWOLFPKCS11_TPM_STORE" && make`.
41+
42+
Note: The TPM does not support DH, so only RSA and ECC are supported.
43+
44+
3645
### Build options and defines
3746

47+
#### Define WOLFPKCS11_TPM_STORE
48+
49+
Use `WOLFPKCS11_TPM_STORE` storing objects in TPM NV.
50+
3851
#### Define WOLFPKCS11_NO_STORE
3952

4053
Disables storage of tokens.
4154

55+
#### Define WOLFPKCS11_DEBUG_STORE
56+
57+
Enables debugging printf's for store.
58+
4259
#### Define WOLFPKCS11_CUSTOM_STORE
4360

4461
Removes default implementation of storage functions.
@@ -48,6 +65,7 @@ See wolfpkcs11/store.h for prototypes of functions to implement.
4865

4966
Sets the private key's label against the public key when generating key pairs.
5067

68+
5169
## Environment variables
5270

5371
### WOLFPKCS11_TOKEN_PATH

configure.ac

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,24 @@ fi
322322

323323
if test "$enable_shared" = "no"; then
324324
AM_CFLAGS="$AM_CFLAGS -DHAVE_PKCS11_STATIC"
325+
else
326+
LIBS="$LIBS -ldl"
327+
fi
328+
329+
330+
AC_ARG_ENABLE([wolftpm],
331+
[AS_HELP_STRING([--enable-wolftpm],[Enable wolfTPM keystore support (default: disabled)])],
332+
[ ENABLED_TPM=$enableval ],
333+
[ ENABLED_TPM=no ]
334+
)
335+
if test "$ENABLED_TPM" = "yes"
336+
then
337+
LIBS="$LIBS -lwolftpm"
338+
AM_CFLAGS="$AM_CFLAGS -DWOLFPKCS11_TPM"
325339
fi
326340

341+
342+
327343
AM_CONDITIONAL([BUILD_STATIC],[test "x$enable_shared" = "xno"])
328344

329345

@@ -333,7 +349,7 @@ AX_HARDEN_CC_COMPILER_FLAGS
333349

334350
OPTION_FLAGS="$CFLAGS $CPPFLAGS $AM_CFLAGS"
335351

336-
LIBS="$LIBS -lwolfssl -ldl -lm"
352+
LIBS="$LIBS -lwolfssl -lm"
337353

338354
CREATE_HEX_VERSION
339355
AC_SUBST([AM_CPPFLAGS])

include.am

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)