Skip to content

Commit bea8686

Browse files
committed
Add CMake documentation to README
1 parent 397949c commit bea8686

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

README.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,118 @@ NOTE: In the code, we have embedded a test key. This must be changed for
9494
production environments!! Please contact Analog Devices to learn how to
9595
obtain and use a production key.
9696

97+
## Building with CMake
98+
99+
wolfPKCS11 uses out-of-source builds. It also requires CMake 3.16 or later (3.22+ recommended).
100+
101+
### Building wolfSSL with CMake
102+
103+
wolfPKCS11 depends on wolfSSL. Build and install wolfSSL with CMake first:
104+
105+
```sh
106+
git clone https://github.com/wolfSSL/wolfssl.git
107+
cd wolfssl
108+
mkdir build && cd build
109+
cmake -DCMAKE_INSTALL_PREFIX=/usr/local \
110+
-DWOLFSSL_AES=yes -DWOLFSSL_AESCBC=yes -DWOLFSSL_AESCCM=yes \
111+
-DWOLFSSL_AESCFB=yes -DWOLFSSL_AESECB=yes -DWOLFSSL_AESCTR=yes \
112+
-DWOLFSSL_AESGCM=yes -DWOLFSSL_AESKEYWRAP=yes -DWOLFSSL_AESOFB=yes \
113+
-DWOLFSSL_AESCTS=yes -DWOLFSSL_DH=yes -DWOLFSSL_DH_DEFAULT_PARAMS=yes \
114+
-DWOLFSSL_ECC=yes -DWOLFSSL_HKDF=yes -DWOLFSSL_KEYGEN=yes \
115+
-DWOLFSSL_MD5=yes -DWOLFSSL_RSA=yes -DWOLFSSL_RSA_PSS=yes \
116+
-DWOLFSSL_SHA=yes -DWOLFSSL_SHA224=yes -DWOLFSSL_SHA3=yes \
117+
-DWOLFSSL_SHA384=yes -DWOLFSSL_SHA512=yes \
118+
-DWOLFSSL_SP_MATH_ALL=yes -DWOLFSSL_PUBLIC_MP=yes \
119+
-DWOLFSSL_WC_RSA_DIRECT=yes -DCMAKE_BUILD_TYPE=Release \
120+
..
121+
cmake --build .
122+
sudo cmake --install .
123+
```
124+
125+
To install to a non-system directory instead, set
126+
`-DCMAKE_INSTALL_PREFIX=<path>` and pass the same path as
127+
`-DCMAKE_PREFIX_PATH=<path>` when building wolfPKCS11 below.
128+
129+
### Building wolfPKCS11 with CMake
130+
131+
```sh
132+
cd wolfPKCS11
133+
mkdir build && cd build
134+
cmake ..
135+
cmake --build .
136+
ctest
137+
```
138+
139+
To enable additional features, pass options during the configure step:
140+
141+
```sh
142+
cmake -DWOLFPKCS11_DEBUG=yes \
143+
-DWOLFPKCS11_AESKEYWRAP=yes \
144+
-DWOLFPKCS11_AESCTR=yes \
145+
-DWOLFPKCS11_AESCCM=yes \
146+
-DWOLFPKCS11_AESECB=yes \
147+
-DWOLFPKCS11_AESCTS=yes \
148+
-DWOLFPKCS11_AESCMAC=yes \
149+
-DWOLFPKCS11_PBKDF2=yes \
150+
..
151+
cmake --build .
152+
ctest
153+
```
154+
155+
If wolfSSL was installed to a non-system prefix, point CMake to it:
156+
157+
```sh
158+
cmake -DCMAKE_PREFIX_PATH=/path/to/wolfssl/install ..
159+
```
160+
161+
### CMake Build Options
162+
163+
| Option | Default | Description |
164+
|--------|---------|-------------|
165+
| `WOLFPKCS11_DEBUG` | `no` | Enable debug logging |
166+
| `WOLFPKCS11_SINGLE_THREADED` | `no` | Single-threaded mode |
167+
| `WOLFPKCS11_RSA` | `yes` | RSA support |
168+
| `WOLFPKCS11_OAEP` | `yes` | RSA OAEP support |
169+
| `WOLFPKCS11_RSA_PSS` | `yes` | RSA-PSS support |
170+
| `WOLFPKCS11_KEYGEN` | `yes` | Key generation support |
171+
| `WOLFPKCS11_ECC` | `yes` | ECC support |
172+
| `WOLFPKCS11_DH` | `yes` | DH support |
173+
| `WOLFPKCS11_AES` | `yes` | AES support |
174+
| `WOLFPKCS11_AESCBC` | `yes` | AES-CBC support |
175+
| `WOLFPKCS11_AESGCM` | `yes` | AES-GCM support |
176+
| `WOLFPKCS11_AESKEYWRAP` | `no` | AES Key Wrap support |
177+
| `WOLFPKCS11_AESCTR` | `no` | AES-CTR support |
178+
| `WOLFPKCS11_AESCCM` | `no` | AES-CCM support |
179+
| `WOLFPKCS11_AESECB` | `no` | AES-ECB support |
180+
| `WOLFPKCS11_AESCTS` | `no` | AES-CTS support |
181+
| `WOLFPKCS11_AESCMAC` | `no` | AES-CMAC support |
182+
| `WOLFPKCS11_HMAC` | `yes` | HMAC support |
183+
| `WOLFPKCS11_HKDF` | `yes` | HKDF support |
184+
| `WOLFPKCS11_PBKDF2` | `no` | PBKDF2 for PIN hashing |
185+
| `PBKDF2_ITERATIONS` | `600000` | PBKDF2 iteration count (used when `WOLFPKCS11_PBKDF2=yes`) |
186+
| `WOLFPKCS11_MD5` | `yes` | MD5 support |
187+
| `WOLFPKCS11_SHA1` | `yes` | SHA-1 support |
188+
| `WOLFPKCS11_SHA224` | `yes` | SHA-224 support |
189+
| `WOLFPKCS11_SHA256` | `yes` | SHA-256 support |
190+
| `WOLFPKCS11_SHA384` | `yes` | SHA-384 support |
191+
| `WOLFPKCS11_SHA512` | `yes` | SHA-512 support |
192+
| `WOLFPKCS11_SHA3` | `yes` | SHA-3 support |
193+
| `WOLFPKCS11_TPM` | `no` | wolfTPM keystore support |
194+
| `WOLFPKCS11_NSS` | `no` | NSS-specific modifications |
195+
| `WOLFPKCS11_PKCS11_V3_0` | `yes` | PKCS#11 v3.0 support |
196+
| `WOLFPKCS11_PKCS11_V3_2` | `no` | PKCS#11 v3.2 support |
197+
| `WOLFPKCS11_EXAMPLES` | `yes` | Build examples |
198+
| `WOLFPKCS11_TESTS` | `yes` | Build and register tests |
199+
| `WOLFPKCS11_COVERAGE` | `no` | Code coverage support |
200+
| `WOLFPKCS11_INSTALL` | `yes` | Create install targets |
201+
| `WOLFPKCS11_DEFAULT_TOKEN_PATH` | `""` | Default token storage path compiled into library |
202+
| `WOLFPKCS11_BUILD_OUT_OF_TREE` | `yes` | Generate build artifacts outside source tree |
203+
| `BUILD_SHARED_LIBS` | `ON` | Build shared (`ON`) or static (`OFF`) library |
204+
205+
Note: wolfSSL must be built with the corresponding features enabled for the
206+
options above to work (e.g. enabling `WOLFPKCS11_AESCCM` requires wolfSSL built
207+
with `-DWOLFSSL_AESCCM=yes`).
208+
97209
## Environment variables
98210

99211
### WOLFPKCS11_TOKEN_PATH

0 commit comments

Comments
 (0)