mirror of https://github.com/wolfSSL/wolfTPM.git
Minor fixes for keyload usage, examples README and whitespaces
Signed-off-by: Dimitar Tomov <dimi@designfirst.ee>pull/132/head
parent
4ce00ecb26
commit
1a24bab50f
|
@ -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.
|
||||
|
|
|
@ -55,7 +55,8 @@ int TPM2_Keygen_Example(void* userCtx, int argc, char *argv[])
|
|||
size_t fileSz = 0;
|
||||
|
||||
if (argc >= 2) {
|
||||
if (XSTRNCMP(argv[1], "-?", 2) == 0 ||
|
||||
if (XSTRNCMP(argv[1], "-?", 2) == 0 ||
|
||||
XSTRNCMP(argv[1], "-h", 2) == 0 ||
|
||||
XSTRNCMP(argv[1], "--help", 6) == 0) {
|
||||
usage();
|
||||
return 0;
|
||||
|
|
|
@ -56,7 +56,8 @@ int TPM2_Keyimport_Example(void* userCtx, int argc, char *argv[])
|
|||
size_t fileSz = 0;
|
||||
|
||||
if (argc >= 2) {
|
||||
if (XSTRNCMP(argv[1], "-?", 2) == 0 ||
|
||||
if (XSTRNCMP(argv[1], "-?", 2) == 0 ||
|
||||
XSTRNCMP(argv[1], "-h", 2) == 0 ||
|
||||
XSTRNCMP(argv[1], "--help", 6) == 0) {
|
||||
usage();
|
||||
return 0;
|
||||
|
@ -109,12 +110,12 @@ int TPM2_Keyimport_Example(void* userCtx, int argc, char *argv[])
|
|||
rc = wolfTPM2_ImportRsaPrivateKey(&dev, &storage, &impKey,
|
||||
kRsaKeyPubModulus, (word32)sizeof(kRsaKeyPubModulus),
|
||||
kRsaKeyPubExponent,
|
||||
kRsaKeyPrivQ, (word32)sizeof(kRsaKeyPrivQ),
|
||||
kRsaKeyPrivQ, (word32)sizeof(kRsaKeyPrivQ),
|
||||
TPM_ALG_NULL, TPM_ALG_NULL);
|
||||
}
|
||||
else if (alg == TPM_ALG_ECC) {
|
||||
/* Import raw ECC private key into TPM */
|
||||
rc = wolfTPM2_ImportEccPrivateKey(&dev, &storage, &impKey,
|
||||
rc = wolfTPM2_ImportEccPrivateKey(&dev, &storage, &impKey,
|
||||
TPM_ECC_NIST_P256,
|
||||
kEccKeyPubXRaw, (word32)sizeof(kEccKeyPubXRaw),
|
||||
kEccKeyPubYRaw, (word32)sizeof(kEccKeyPubYRaw),
|
||||
|
@ -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)
|
||||
|
|
|
@ -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[])
|
||||
|
@ -52,7 +52,8 @@ int TPM2_Keyload_Example(void* userCtx, int argc, char *argv[])
|
|||
const char* inputFile = "keyblob.bin";
|
||||
|
||||
if (argc >= 2) {
|
||||
if (XSTRNCMP(argv[1], "-?", 2) == 0 ||
|
||||
if (XSTRNCMP(argv[1], "-?", 2) == 0 ||
|
||||
XSTRNCMP(argv[1], "-h", 2) == 0 ||
|
||||
XSTRNCMP(argv[1], "--help", 6) == 0) {
|
||||
usage();
|
||||
return 0;
|
||||
|
@ -108,7 +109,7 @@ int TPM2_Keyload_Example(void* userCtx, int argc, char *argv[])
|
|||
rc = BUFFER_E; goto exit;
|
||||
}
|
||||
printf("Reading %d bytes from %s\n", (int)fileSz, inputFile);
|
||||
|
||||
|
||||
XFREAD(&newKey.pub, 1, sizeof(newKey.pub), f);
|
||||
if (fileSz > sizeof(newKey.pub)) {
|
||||
fileSz -= sizeof(newKey.pub);
|
||||
|
|
Loading…
Reference in New Issue