Skip to content

Commit 53563ac

Browse files
Dimitar Tomovdgarske
authored andcommitted
Update the wolfTPM and examples README.md files
Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>
1 parent f0540d6 commit 53563ac

2 files changed

Lines changed: 99 additions & 15 deletions

File tree

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,23 @@ Portable TPM 2.0 project designed for embedded use.
1212
* wolfTPM can also use the Linux TPM kernel interface (/dev/tpmX) to talk with any physical TPM on SPI, I2C and even LPC bus.
1313
* Platform support for Raspberry Pi, STM32 with CubeMX, Atmel ASF and Barebox.
1414
* The design allows for easy portability to different platforms:
15-
* Native C code designed for embedded use.
16-
* Single IO callback for hardware SPI interface.
17-
* No external dependencies.
18-
* Compact code size and minimal memory use.
15+
* Native C code designed for embedded use.
16+
* Single IO callback for hardware SPI interface.
17+
* No external dependencies.
18+
* Compact code size and minimal memory use.
1919
* Includes example code for:
2020
* Most TPM2 native API’s
2121
* All TPM2 wrapper API's
22-
* PKCS 7
23-
* Certificate Signing Request (CSR)
24-
* TLS Client
25-
* TLS Server
26-
* Benchmarking TPM algorithms and TLS
27-
* Parameter encryption support using AES-CFB or XOR. Supports salted unbound authenticated sessions.
22+
* PKCS 7
23+
* Certificate Signing Request (CSR)
24+
* TLS Client
25+
* TLS Server
26+
* Use of the TPM's Non-volatile memory
27+
* Attestation (TPM2_Quote and TPM2_GetTime)
28+
* Benchmarking TPM algorithms and TLS
29+
* Parameter encryption support using AES-CFB or XOR.
30+
* Support for salted unbound authenticated sessions.
31+
* Support for HMAC Sessions.
2832

2933
Note: See [examples/README.md](examples/README.md) for details on using the examples.
3034

examples/README.md

Lines changed: 85 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,35 @@ TPM2.0 Key load example
236236
Loading SRK: Storage 0x81000200 (282 bytes)
237237
Reading 744 bytes from keyblob.bin
238238
Loaded key to 0x80000001
239+
240+
./examples/keygen/keygen -sym=aescfb128
241+
TPM2.0 Key generation example
242+
Key Blob: keyblob.bin
243+
Algorithm: SYMCIPHER
244+
aescfb mode, 128 keybits
245+
Template: Default
246+
Use Parameter Encryption: NULL
247+
Loading SRK: Storage 0x81000200 (282 bytes)
248+
Symmetric template
249+
Creating new SYMCIPHER key...
250+
Created new key (pub 50, priv 142 bytes)
251+
Wrote 198 bytes to keyblob.bin
252+
253+
$ ./examples/keygen/keyload
254+
TPM2.0 Key load example
255+
Key Blob: keyblob.bin
256+
Use Parameter Encryption: NULL
257+
Loading SRK: Storage 0x81000200 (282 bytes)
258+
Reading 198 bytes from keyblob.bin
259+
Reading the private part of the key
260+
Loaded key to 0x80000001
261+
239262
```
240263

264+
When filename is not supplied, a default filename "keyblob.bin" is used, therefore `keyload` and `keygen` can be used without additional parameters for quick TPM 2.0 key generation demonstration.
265+
266+
To see the complete list of supported cryptographic algorithms and options by the `keygen` example, use one of the `--help` switches.
267+
241268
Example for importing a private key as TPM key blob and storing to disk, then loading from disk and loading into temporary TPM handle.
242269

243270
```
@@ -271,26 +298,79 @@ The `keyload` tool takes only one argument, the filename of the stored key. Beca
271298

272299
## Storing keys into the TPM's NVRAM
273300

274-
These examples demonstrates how to use the TPM as secure vault for keys. There are two programs, one to store a TPM key into the TPM's NVRAM and another to extract the key from the TPM's NVRAM. Both examples can use parameter encryption to protect from MITM attacks. The Non-volatile memory location is protected with a password authorization that is passed in encrypted form, when "-aes" or "-xor" is given on the commmand line.
301+
These examples demonstrates how to use the TPM as a secure vault for keys. There are two programs, one to store a TPM key into the TPM's NVRAM and another to extract the key from the TPM's NVRAM. Both examples can use parameter encryption to protect from MITM attacks. The Non-volatile memory location is protected with a password authorization that is passed in encrypted form, when "-aes" is given on the commmand line.
275302

276303
Before running the examples, make sure there is a keyblob.bin generated using the keygen tool. The key can be of any type, RSA, ECC or symmetric. The example will store the private and public part. In case of a symmetric key the public part is meta data from the TPM. How to generate a key you can see above, in the description of the keygen example.
277304

278-
Typical output for storing and then reading an RSA key using parameter encryption:
305+
Typical output for storing and then reading an RSA key with parameter encryption enabled:
279306

280307
```
308+
281309
$ ./examples/nvram/store -aes
310+
Parameter Encryption: Enabled (AES CFB).
311+
282312
TPM2_StartAuthSession: sessionHandle 0x2000000
283313
Reading 840 bytes from keyblob.bin
284314
Storing key at TPM NV index 0x1800202 with password protection
315+
285316
Public part = 616 bytes
317+
NV write of public part succeeded
318+
286319
Private part = 222 bytes
287-
NV write succeeded
320+
Stored 2-byte size marker before the private part
321+
NV write of private part succeeded
322+
323+
324+
$ ./examples/nvram/read -aes
325+
Parameter Encryption: Enabled (AES CFB).
288326
289-
$ ./examples/nvram/read 616 222 -aes
290327
TPM2_StartAuthSession: sessionHandle 0x2000000
291328
Trying to read 616 bytes of public key part from NV
329+
Successfully read public key part from NV
330+
331+
Trying to read size marker of the private key part from NV
332+
Successfully read size marker from NV
333+
334+
Trying to read 222 bytes of private key part from NV
335+
Successfully read private key part from NV
336+
337+
Extraction of key from NVRAM at index 0x1800202 succeeded
338+
Loading SRK: Storage 0x81000200 (282 bytes)
339+
Trying to load the key extracted from NVRAM
340+
Loaded key to 0x80000001
341+
342+
```
343+
344+
The "read" example will try to load the extracted key, if both the public and private part of the key were stored in NVRAM. The "-aes" swiches triggers the use of parameter encryption.
345+
346+
The examples can work with partial key material - private or public. This is achieved by using the "-priv" and "-pub" options.
347+
348+
Typical output of storing only the private key of RSA asymmetric key pair in NVRAM and without parameter encryption enabled.
349+
350+
```
351+
352+
$ ./examples/nvram/store -priv
353+
Parameter Encryption: Not enabled (try -aes or -xor).
354+
355+
Reading 506 bytes from keyblob.bin
356+
Reading the private part of the key
357+
Storing key at TPM NV index 0x1800202 with password protection
358+
359+
Private part = 222 bytes
360+
Stored 2-byte size marker before the private part
361+
NV write of private part succeeded
362+
363+
$ ./examples/nvram/read -priv
364+
Parameter Encryption: Not enabled (try -aes or -xor).
365+
366+
Trying to read size marker of the private key part from NV
367+
Successfully read size marker from NV
368+
292369
Trying to read 222 bytes of private key part from NV
370+
Successfully read private key part from NV
371+
293372
Extraction of key from NVRAM at index 0x1800202 succeeded
373+
294374
```
295375

296-
The read example takes as first argument the size of the public part and as second argument the private part. This information is given from the store example. The "-aes" swiches triggers the use of parameter encryption.
376+
After successful key extraction using "read", the NV Index is destroyed. Therefore, to use "read" again, the "store" example must be run again as well.

0 commit comments

Comments
 (0)