Minor fixes for keyload usage, examples README and whitespaces

Signed-off-by: Dimitar Tomov <dimi@designfirst.ee>
pull/132/head
Dimitar Tomov 2020-11-12 16:15:14 +02:00
parent 4ce00ecb26
commit 1a24bab50f
4 changed files with 18 additions and 13 deletions

View File

@ -193,7 +193,7 @@ Creating new RSA key...
Created new key (pub 280, priv 222 bytes)
Wrote 840 bytes to keyblob.bin
$ ./examples/keygen/keyload keyblob.bin RSA
$ ./examples/keygen/keyload keyblob.bin
TPM2.0 Key load example
Loading SRK: Storage 0x81000200 (282 bytes)
Reading 840 bytes from keyblob.bin
@ -207,7 +207,7 @@ Creating new ECC key...
Created new key (pub 88, priv 126 bytes)
Wrote 744 bytes to keyblob.bin
$ ./examples/keygen/keyload keyblob.bin ECC
$ ./examples/keygen/keyload keyblob.bin
TPM2.0 Key load example
Loading SRK: Storage 0x81000200 (282 bytes)
Reading 744 bytes from keyblob.bin
@ -223,7 +223,7 @@ Loading SRK: Storage 0x81000200 (282 bytes)
Imported key (pub 278, priv 222 bytes)
Wrote 840 bytes to keyblob.bin
$ ./examples/keygen/keyload keyblob.bin RSA
$ ./examples/keygen/keyload keyblob.bin
TPM2.0 Key load example
Loading SRK: Storage 0x81000200 (282 bytes)
Reading 840 bytes from keyblob.bin
@ -236,9 +236,11 @@ Loading SRK: Storage 0x81000200 (282 bytes)
Imported key (pub 86, priv 126 bytes)
Wrote 744 bytes to keyblob.bin
$ ./examples/keygen/keyload keyblob.bin ECC
$ ./examples/keygen/keyload keyblob.bin
TPM2.0 Key load example
Loading SRK: Storage 0x81000200 (282 bytes)
Reading 744 bytes from keyblob.bin
Loaded key to 0x80000001
```
The `keyload` tool takes only one argument, the filename of the stored key. Because the information what is key scheme (RSA or ECC) is contained within the key blob.

View File

@ -56,6 +56,7 @@ int TPM2_Keygen_Example(void* userCtx, int argc, char *argv[])
if (argc >= 2) {
if (XSTRNCMP(argv[1], "-?", 2) == 0 ||
XSTRNCMP(argv[1], "-h", 2) == 0 ||
XSTRNCMP(argv[1], "--help", 6) == 0) {
usage();
return 0;

View File

@ -57,6 +57,7 @@ int TPM2_Keyimport_Example(void* userCtx, int argc, char *argv[])
if (argc >= 2) {
if (XSTRNCMP(argv[1], "-?", 2) == 0 ||
XSTRNCMP(argv[1], "-h", 2) == 0 ||
XSTRNCMP(argv[1], "--help", 6) == 0) {
usage();
return 0;
@ -122,8 +123,8 @@ int TPM2_Keyimport_Example(void* userCtx, int argc, char *argv[])
}
if (rc != 0) goto exit;
printf("Imported key (pub %d, priv %d bytes)\n",
impKey.pub.size, impKey.priv.size);
printf("Imported %s key (pub %d, priv %d bytes)\n",
TPM2_GetAlgName(alg), impKey.pub.size, impKey.priv.size);
/* Save key as encrypted blob to the disk */
#if !defined(WOLFTPM2_NO_WOLFCRYPT) && !defined(NO_FILESYSTEM)

View File

@ -37,7 +37,7 @@
static void usage(void)
{
printf("Expected usage:\n");
printf("keyload [keyblob.bin] [ECC/RSA]\n");
printf("keyload [keyblob.bin]\n");
}
int TPM2_Keyload_Example(void* userCtx, int argc, char *argv[])
@ -53,6 +53,7 @@ int TPM2_Keyload_Example(void* userCtx, int argc, char *argv[])
if (argc >= 2) {
if (XSTRNCMP(argv[1], "-?", 2) == 0 ||
XSTRNCMP(argv[1], "-h", 2) == 0 ||
XSTRNCMP(argv[1], "--help", 6) == 0) {
usage();
return 0;