Skip to content

Commit d44b7e1

Browse files
authored
Merge pull request #338 from dgarske/no_filesystem
Fixes for building wolfTPM examples with `NO_FILESYSTEM`
2 parents 462c1fe + eed7803 commit d44b7e1

7 files changed

Lines changed: 23 additions & 9 deletions

File tree

examples/boot/secret_seal.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ int TPM2_Boot_SecretSeal_Example(void* userCtx, int argc, char *argv[])
282282
printHexString((const byte*)&sealBlob.pub.publicArea, sealBlob.pub.size, 32);
283283
printf("Sealed keyed hash priv %d\n", sealBlob.priv.size);
284284
printHexString(sealBlob.priv.buffer, sealBlob.priv.size, 32);
285+
(void)outFile;
285286
#endif
286287

287288
exit:

examples/boot/secret_unseal.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ int TPM2_Boot_SecretUnseal_Example(void* userCtx, int argc, char *argv[])
281281
}
282282
#else
283283
printf("File system support not compiled in!\n");
284+
(void)publicKeyFile;
285+
(void)pcrSigFile;
284286
rc = NOT_COMPILED_IN;
285287
#endif
286288
if (rc != TPM_RC_SUCCESS) {
@@ -314,6 +316,7 @@ int TPM2_Boot_SecretUnseal_Example(void* userCtx, int argc, char *argv[])
314316
#ifndef NO_FILESYSTEM
315317
rc = readKeyBlob(sealFile, &sealBlob);
316318
#else
319+
(void)sealFile;
317320
rc = NOT_COMPILED_IN;
318321
#endif
319322
if (rc != TPM_RC_SUCCESS) {

examples/keygen/keyimport.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,11 @@ int TPM2_Keyimport_Example(void* userCtx, int argc, char *argv[])
221221
}
222222
}
223223
else
224+
#else
225+
(void)encType;
226+
(void)attributes;
227+
(void)bufSz;
228+
(void)isPublicKey;
224229
#endif
225230
if (alg == TPM_ALG_RSA) {
226231
printf("Loading example RSA key (see kRsaKeyPrivQ)\n");

examples/pcr/policy_sign.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131

3232
#include <stdio.h>
3333

34-
#if !defined(WOLFTPM2_NO_WRAPPER) && !defined(WOLFTPM2_NO_WOLFCRYPT)
34+
#if !defined(WOLFTPM2_NO_WRAPPER) && !defined(WOLFTPM2_NO_WOLFCRYPT) && \
35+
!defined(NO_FILESYSTEM)
3536

3637
#include <hal/tpm_io.h>
3738
#include <examples/tpm_test.h>
@@ -66,7 +67,6 @@ static void usage(void)
6667
printf("./examples/pcr/policy_sign -pcr=16 -pcr=15 -pcrdigest=ba8ac02be16d9d33080d98611d70bb869aa8ac3fc684ab732b91f75f164b36bc\n");
6768
}
6869

69-
#ifndef NO_FILESYSTEM
7070
#ifndef WC_MAX_ENCODED_DIG_ASN_SZ
7171
#define WC_MAX_ENCODED_DIG_ASN_SZ 9 /* enum(bit or octet) + length(4) */
7272
#endif
@@ -217,7 +217,6 @@ static int PolicySign(TPM_ALG_ID alg, const char* keyFile, const char* password,
217217
}
218218
return rc;
219219
}
220-
#endif /* !NO_FILESYSTEM */
221220

222221
int TPM2_PCR_PolicySign_Example(void* userCtx, int argc, char *argv[])
223222
{
@@ -361,9 +360,7 @@ int TPM2_PCR_PolicySign_Example(void* userCtx, int argc, char *argv[])
361360
if (rc == 0) {
362361
printf("PCR Policy Signature (%d bytes):\n", sigSz);
363362
printHexString(sig, sigSz, 32);
364-
#if !defined(NO_FILESYSTEM)
365363
rc = writeBin(outFile, sig, sigSz);
366-
#endif
367364
}
368365
if (rc == 0) {
369366
/* Create Signing Authority Policy */
@@ -377,9 +374,7 @@ int TPM2_PCR_PolicySign_Example(void* userCtx, int argc, char *argv[])
377374
if (rc == 0) {
378375
printf("Policy Authorize Digest (%d bytes):\n", digestSz);
379376
printHexString(digest, digestSz, digestSz);
380-
#if !defined(NO_FILESYSTEM)
381377
rc = writeBin(outPolicyFile, digest, digestSz);
382-
#endif
383378
}
384379
}
385380
}
@@ -398,7 +393,7 @@ int TPM2_PCR_PolicySign_Example(void* userCtx, int argc, char *argv[])
398393

399394
return rc;
400395
}
401-
#endif /* !WOLFTPM2_NO_WRAPPER && !WOLFTPM2_NO_WOLFCRYPT */
396+
#endif /* !WOLFTPM2_NO_WRAPPER && !WOLFTPM2_NO_WOLFCRYPT && !NO_FILESYSTEM */
402397

403398
/******************************************************************************/
404399
/* --- END TPM Secure Boot Sign Policy Example -- */
@@ -409,7 +404,8 @@ int main(int argc, char *argv[])
409404
{
410405
int rc = NOT_COMPILED_IN;
411406

412-
#if !defined(WOLFTPM2_NO_WRAPPER) && !defined(WOLFTPM2_NO_WOLFCRYPT)
407+
#if !defined(WOLFTPM2_NO_WRAPPER) && !defined(WOLFTPM2_NO_WOLFCRYPT) && \
408+
!defined(NO_FILESYSTEM)
413409
rc = TPM2_PCR_PolicySign_Example(NULL, argc, argv);
414410
#else
415411
printf("Example not compiled in! Requires Wrapper and wolfCrypt\n");

examples/pkcs7/pkcs7.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ static int PKCS7_SignVerifyEx(WOLFTPM2_DEV* dev, int tpmDevId, WOLFTPM2_BUFFER*
204204

205205
XFCLOSE(pemFile);
206206
}
207+
#else
208+
(void)outFile;
207209
#endif
208210

209211
/* Test verify with TPM */
@@ -363,10 +365,12 @@ int TPM2_PKCS7_ExampleArgs(void* userCtx, int argc, char *argv[])
363365
else if (XSTRCMP(argv[argc-1], "-rsa") == 0) {
364366
alg = TPM_ALG_RSA;
365367
}
368+
#if !defined(NO_FILESYSTEM) && !defined(NO_WRITE_TEMP_FILES)
366369
else if (XSTRNCMP(argv[argc-1], "-incert=",
367370
XSTRLEN("-incert=")) == 0) {
368371
inCert = argv[argc-1] + XSTRLEN("-incert=");
369372
}
373+
#endif
370374
else if (XSTRNCMP(argv[argc-1], "-out=",
371375
XSTRLEN("-out=")) == 0) {
372376
outFile = argv[argc-1] + XSTRLEN("-out=");

examples/tls/tls_client.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,10 @@ int TPM2_TLS_ClientArgs(void* userCtx, int argc, char *argv[])
404404
printf("Loading RSA certificate\n");
405405
#ifdef NO_FILESYSTEM
406406
/* Load "cert" buffer with ASN.1/DER certificate */
407+
#if 0
407408
rc = wolfSSL_CTX_use_certificate_buffer(ctx, cert.buffer, (long)cert.size,
408409
WOLFSSL_FILETYPE_ASN1);
410+
#endif
409411
#else
410412
rc = wolfSSL_CTX_use_certificate_file(ctx, "./certs/client-rsa-cert.pem",
411413
WOLFSSL_FILETYPE_PEM);
@@ -425,8 +427,10 @@ int TPM2_TLS_ClientArgs(void* userCtx, int argc, char *argv[])
425427
printf("Loading ECC certificate\n");
426428
#ifdef NO_FILESYSTEM
427429
/* Load "cert" buffer with ASN.1/DER certificate */
430+
#if 0
428431
rc = wolfSSL_CTX_use_certificate_buffer(ctx, cert.buffer, (long)cert.size,
429432
WOLFSSL_FILETYPE_ASN1);
433+
#endif
430434
#else
431435
rc = wolfSSL_CTX_use_certificate_file(ctx, "./certs/client-ecc-cert.pem",
432436
WOLFSSL_FILETYPE_PEM);

examples/tls/tls_server.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ int TPM2_TLS_ServerArgs(void* userCtx, int argc, char *argv[])
383383
goto exit;
384384
}
385385
#endif
386+
(void)useSelfSign;
386387
#else
387388
{
388389
/* Export TPM public key as DER */

0 commit comments

Comments
 (0)