Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code to test external import between two TPM's #288

Merged
merged 1 commit into from
Aug 3, 2023

Conversation

dgarske
Copy link
Contributor

@dgarske dgarske commented Aug 1, 2023

ZD16249

@dgarske dgarske self-assigned this Aug 1, 2023
@dgarske
Copy link
Contributor Author

dgarske commented Aug 1, 2023

# Run on Pi4 with ATTPM20
PI4:pi@raspberrypi:~/wolftpm $ ./examples/keygen/external_import
wolfSSL Entering wolfCrypt_Init
Trying TPM @ /dev/spidev0.0 (33 MHz)
Found TPM @ /dev/spidev0.0
TPM2: Caps 0x30000695, Did 0x3205, Vid 0x1114, Rid 0x 1
TPM2_Startup pass
TPM2_SelfTest pass
TPM2_CreatePrimary: 0x80000000 (282 bytes)
Import RSA Seed 32
	00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f | ................
	00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f | ................
wolfSSL Entering wc_KeyPemToDer
wolfSSL Entering PemToDer
wolfSSL Using RSA OAEP padding
TPM2_Load Key Handle 0x80000001
TPM2_Create key: pub 278, priv 190
Public Area (size 278):
  Type: RSA (0x1), name: SHA256 (0xB), objAttr: 0x40460, authPolicy sz: 0
  RSA: sym algorithm: NULL (0x10), sym keyBits: 0, sym mode: Unknown (0x0)
       scheme: NULL (0x10), scheme hash: Unknown (0x0)
       keyBits: 2048, exponent: 0x10001, unique size 256
Key Public Blob 278
	01 00 0b 00 60 04 04 00 00 00 00 00 00 00 00 00 | ....`...........
	00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
	00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
	00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
	00 00 00 00 00 00 00 00 00 00 00 00 10 00 00 00 | ................
	00 00 10 00 00 00 00 08 01 00 01 00 00 00 00 00 | ................
	00 01 88 be 84 09 1d f6 89 7b 2a 85 36 47 5d e5 | .........{*.6G].
	cb 7e 7d 50 d9 62 c3 68 cd 87 23 3f fd 27 20 68 | .~}P.b.h..#?.' h
	4c 65 a6 1e 03 c6 7f 2c d9 1c 62 f3 e9 b1 d8 e5 | Le.....,..b.....
	ab 52 38 40 13 95 ba d2 d0 28 b7 24 43 3a 23 65 | .R8@.....(.$C:#e
	d5 24 8e 65 0a d0 ae 2a cc 8a 2a 6f fb d9 0c 6b | .$.e...*..*o...k
	2c d3 45 df 1c 57 a2 0c 7b 03 c6 43 2f 4e 3d b0 | ,.E..W..{..C/N=.
	33 2b 16 77 6d 40 a1 80 e1 78 6b 67 80 f6 61 60 | 3+.wm@...xkg..a`
	f9 34 c5 fa 97 ab 25 7e 64 96 09 e8 9d 00 55 e9 | .4....%~d.....U.
	0c fb 97 41 0d ff 58 c6 c7 4c bf 90 ac 66 6f 94 | ...A..X..L...fo.
	ca 28 ab e7 45 b6 28 a9 a5 36 dd ef 34 f1 73 3c | .(..E.(..6..4.s<
	23 58 21 51 e7 52 13 b0 31 c2 d9 b1 fe 41 ff 86 | #X!Q.R..1....A..
	cf d1 0b 77 47 2c                               | ...wG,
Key Private Blob 190
	00 20 5a cd 8a 52 0f 31 24 41 4b b7 e1 d1 0a 5e | . Z..R.1$AK....^
	41 59 dd 99 db 76 b8 06 dd 95 96 9d ce af ee c3 | AY...v..........
	94 53 00 10 e2 52 54 26 13 e6 04 d3 38 d6 52 52 | .S...RT&....8.RR
	86 83 da 9a ee 18 bd bc b2 17 2d 7d a5 c5 31 62 | ..........-}..1b
	08 08 0a 15 81 e6 72 2f 16 8d 37 7c d9 26 f3 e6 | ......r/..7|.&..
	5d a4 4f 4d a4 97 43 2f eb 45 67 18 a0 e5 6e e7 | ].OM..C/.Eg...n.
	a8 5d d8 61 23 9d 54 a9 b5 35 ec 17 87 1d 5a ad | .].a#.T..5....Z.
	0b bc d6 7a 4c d8 77 ff 0b 85 73 b6 c4 e6 d4 4f | ...zL.w...s....O
	04 8b 79 65 2e 62 9b f6 cd 08 10 6d 6e 37 c6 58 | ..ye.b.....mn7.X
	c7 2d 0f 6d 52 95 d3 3c e8 80 79 99 f4 c4 2a 44 | .-.mR..<..y...*D
	b9 b6 89 99 a8 97 04 7f 1d 65 7a 70 7b 0f f3 a4 | .........ezp{...
	fb 70 47 7c 1c 05 88 16 20 94 f1 98 69 bd       | .pG|.... ...i.
Wrote 474 bytes to keyblob.bin
TPM2_Load Key Handle 0x80000002
TPM2_FlushContext: Closed handle 0x80000002
TPM2_FlushContext: Closed handle 0x80000001
TPM2_FlushContext: Closed handle 0x80000000

# Run again with -load (same TPM)
PI4:pi@raspberrypi:~/wolftpm $ ./examples/keygen/external_import -load
wolfSSL Entering wolfCrypt_Init
Trying TPM @ /dev/spidev0.0 (33 MHz)
Found TPM @ /dev/spidev0.0
TPM2: Caps 0x30000695, Did 0x3205, Vid 0x1114, Rid 0x 1
TPM2_Startup pass
TPM2_SelfTest pass
TPM2_CreatePrimary: 0x80000000 (282 bytes)
Import RSA Seed 32
	00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f | ................
	00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f | ................
wolfSSL Entering wc_KeyPemToDer
wolfSSL Entering PemToDer
wolfSSL Using RSA OAEP padding
TPM2_Load Key Handle 0x80000001
Reading 474 bytes from keyblob.bin
Public Area (size 278):
  Type: RSA (0x1), name: SHA256 (0xB), objAttr: 0x40460, authPolicy sz: 0
  RSA: sym algorithm: NULL (0x10), sym keyBits: 0, sym mode: Unknown (0x0)
       scheme: NULL (0x10), scheme hash: Unknown (0x0)
       keyBits: 2048, exponent: 0x10001, unique size 256
Reading the private part of the key
TPM2_Load Key Handle 0x80000002
TPM2_FlushContext: Closed handle 0x80000002
TPM2_FlushContext: Closed handle 0x80000001
TPM2_FlushContext: Closed handle 0x80000000
wolfSSL Entering wolfCrypt_Cleanup

# Replace TPM or run on different machine (used Pi4 with ST33TPM20)
$ ./examples/keygen/external_import -load
wolfSSL Entering wolfCrypt_Init
Trying TPM @ /dev/spidev0.0 (33 MHz)
Trying TPM @ /dev/spidev0.1 (33 MHz)
Found TPM @ /dev/spidev0.1
TPM2: Caps 0x30000697, Did 0x001d, Vid 0x15d1, Rid 0x36
TPM2_Startup pass
TPM2_SelfTest pass
TPM2_CreatePrimary: 0x80000000 (282 bytes)
Import RSA Seed 32
	00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f | ................
	00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f | ................
wolfSSL Entering wc_KeyPemToDer
wolfSSL Entering PemToDer
wolfSSL Using RSA OAEP padding
TPM2_Load Key Handle 0x80000001
Reading 474 bytes from keyblob.bin
Public Area (size 278):
  Type: RSA (0x1), name: SHA256 (0xB), objAttr: 0x40460, authPolicy sz: 0
  RSA: sym algorithm: NULL (0x10), sym keyBits: 0, sym mode: Unknown (0x0)
       scheme: NULL (0x10), scheme hash: Unknown (0x0)
       keyBits: 2048, exponent: 0x10001, unique size 256
Reading the private part of the key
TPM2_Load Key Handle 0x80000002
TPM2_FlushContext: Closed handle 0x80000002
TPM2_FlushContext: Closed handle 0x80000001
TPM2_FlushContext: Closed handle 0x80000000
wolfSSL Entering wolfCrypt_Cleanup

@dgarske dgarske assigned jpbland1 and unassigned dgarske Aug 3, 2023
Copy link
Contributor

@jpbland1 jpbland1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, tested and ran with -load

@jpbland1 jpbland1 merged commit bb82dd2 into wolfSSL:master Aug 3, 2023
@dgarske dgarske deleted the ext_imp_test branch December 29, 2023 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants