Skip to content

Commit 5b13434

Browse files
committed
Improvements to PKCS7 crypto callback example and support for PSA (ECC only).
1 parent a944dfb commit 5b13434

3 files changed

Lines changed: 389 additions & 366 deletions

File tree

pkcs7/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ LIB_PATH = /usr/local
44
CFLAGS = -Wall -I$(LIB_PATH)/include
55
ZLIB =
66
#ZLIB += -lz
7+
PSA_LIB = -lmbedcrypto
78
LIBS = -L$(LIB_PATH)/lib -lm ${ZLIB}
89

910
# option variables
@@ -19,6 +20,11 @@ CFLAGS+=$(OPTIMIZE)
1920
#LIBS+=$(STATIC_LIB)
2021
LIBS+=$(DYN_LIB)
2122

23+
ifneq ($(PSA),)
24+
LIBS+=$(PSA_LIB)
25+
CFLAGS+=-DUSE_PSA
26+
endif
27+
2228
# build targets
2329
SRC=$(wildcard *.c)
2430
TARGETS=$(patsubst %.c, %, $(SRC))

pkcs7/README.md

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $ make
1616
$ sudo make install
1717
```
1818

19-
Note, some examples require additional features, such as "--with-libz" and
19+
Note, some examples require additional features, such as "--with-libz" and
2020
"--enable-pwdbased". To build wolfSSL with support for all examples, use:
2121

2222
```
@@ -96,18 +96,18 @@ Debugging with `openssl cms`
9696

9797
```
9898
$ openssl cms -inform der -in envelopedData.der -cmsout -print -noout
99-
CMS_ContentInfo:
99+
CMS_ContentInfo:
100100
contentType: pkcs7-encryptedData (1.2.840.113549.1.7.6)
101-
d.encryptedData:
101+
d.encryptedData:
102102
version: <ABSENT>
103-
encryptedContentInfo:
103+
encryptedContentInfo:
104104
contentType: pkcs7-data (1.2.840.113549.1.7.1)
105-
contentEncryptionAlgorithm:
105+
contentEncryptionAlgorithm:
106106
algorithm: aes-256-cbc (2.16.840.1.101.3.4.1.42)
107107
parameter: OCTET STRING:
108108
0000 - 08 83 47 90 5d 9f d6 aa-dc 25 ce b2 87 9a 10 ..G.]....%.....
109109
000f - cf .
110-
encryptedContent:
110+
encryptedContent:
111111
0000 - 3c 22 ea 61 64 fb 21 30-77 8a ce b0 5a a7 35 <".ad.!0w...Z.5
112112
000f - de .
113113
unprotectedAttrs:
@@ -119,7 +119,7 @@ CMS_ContentInfo:
119119
### pkcs7-verify
120120

121121
```
122-
./pkcs7-verify
122+
./pkcs7-verify
123123
Der 1633
124124
PKCS7 Verify Success
125125
```
@@ -518,6 +518,27 @@ Successfully encoded SignedData bundle (signedData_cryptocb_attrs.der)
518518
Successfully verified SignedData bundle.
519519
```
520520

521+
#### Enabling PSA with the PKCS7 crypto callback example
522+
523+
For wolfSSL PSA support see: https://github.com/wolfSSL/wolfssl/tree/master/wolfcrypt/src/port/psa
524+
See https://github.com/wolfSSL/wolfssl/pull/4739 for details on building a PSA crypto library to test against.
525+
526+
Build wolfSSL with PSA enabled:
527+
528+
```sh
529+
./configure --enable-psa --with-psa-lib-name=mbedcrypto --enable-cryptocb --enable-pkcallbacks CFLAGS="-DWOLFSSL_PSA_GLOBAL_LOCK"
530+
make
531+
sudo make install
532+
```
533+
534+
Build example with PSA=1 set:
535+
536+
```sh
537+
make clean
538+
make PSA=1
539+
```
540+
541+
521542
### SignedData with Detached Signature
522543

523544
Example file: `signedData-DetachedSignature.c`

0 commit comments

Comments
 (0)