-
Notifications
You must be signed in to change notification settings - Fork 61
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
jpbland1
approved these changes
Aug 3, 2023
There was a problem hiding this 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ZD16249