diff --git a/examples/run_examples.sh b/examples/run_examples.sh index 44262ded..d40f7075 100755 --- a/examples/run_examples.sh +++ b/examples/run_examples.sh @@ -895,8 +895,15 @@ echo -e "PCR Quote tests" ./examples/pcr/reset 16 >> $TPMPWD/run.out 2>&1 RESULT=$? [ $RESULT -ne 0 ] && echo -e "pcr reset failed! $RESULT" && exit 1 -./examples/pcr/extend 16 /usr/bin/zip >> $TPMPWD/run.out 2>&1 +PCR_EXTEND_FILE=/usr/bin/zip +if [ $WOLFCRYPT_ENABLE -eq 0 ]; then + # Without wolfCrypt, extend expects a raw, precomputed SHA-256 digest. + PCR_EXTEND_FILE="$TPMPWD/pcr-extend.digest" + printf '%s' '0123456789abcdef0123456789abcdef' > "$PCR_EXTEND_FILE" +fi +./examples/pcr/extend 16 "$PCR_EXTEND_FILE" >> $TPMPWD/run.out 2>&1 RESULT=$? +[ $WOLFCRYPT_ENABLE -eq 0 ] && rm -f "$PCR_EXTEND_FILE" [ $RESULT -ne 0 ] && echo -e "pcr extend file failed! $RESULT" && exit 1 ./examples/pcr/quote 16 zip.quote >> $TPMPWD/run.out 2>&1 RESULT=$? diff --git a/examples/tls/tls_client.c b/examples/tls/tls_client.c index 415862a4..e3f84399 100644 --- a/examples/tls/tls_client.c +++ b/examples/tls/tls_client.c @@ -102,7 +102,7 @@ static void usage(void) printf("* -h=host: Server hostname (default %s)\n", TLS_HOST); printf("* -p=port: Supply a custom port number (default %d)\n", TLS_PORT); #ifndef NO_FILESYSTEM - printf("* -A=file: Additional CA certificate file to trust\n"); + printf("* -A=file: CA certificate file to trust\n"); #endif #if defined(WOLFTPM_CRYPTOCB) && defined(HAVE_PK_CALLBACKS) printf("* -pk: Use PK callbacks, not crypto callbacks\n"); @@ -490,7 +490,15 @@ tls_setup: } #else /* Load CA Certificates */ - if (!useECC) { + if (caFile != NULL) { + if (wolfSSL_CTX_load_verify_locations(ctx, caFile, + 0) != WOLFSSL_SUCCESS) { + printf("Error loading %s cert\n", caFile); + rc = -1; + goto exit; + } + } + else if (!useECC) { #ifndef NO_RSA if (wolfSSL_CTX_load_verify_locations(ctx, "./certs/ca-rsa-cert.pem", 0) != WOLFSSL_SUCCESS) { @@ -528,14 +536,6 @@ tls_setup: goto exit; #endif /* HAVE_ECC */ } - if (caFile != NULL) { - if (wolfSSL_CTX_load_verify_locations(ctx, caFile, - 0) != WOLFSSL_SUCCESS) { - printf("Error loading %s cert\n", caFile); - rc = -1; - goto exit; - } - } #endif /* !NO_FILESYSTEM */ /* Client Key (Mutual Authentication) */ diff --git a/examples/tls/tls_server.c b/examples/tls/tls_server.c index bb8e4f7d..08d5c10d 100644 --- a/examples/tls/tls_server.c +++ b/examples/tls/tls_server.c @@ -123,7 +123,7 @@ static void usage(void) printf("* -aes/xor: Use Parameter Encryption\n"); printf("* -p=port: Supply a custom port number (default %d)\n", TLS_PORT); #ifndef NO_FILESYSTEM - printf("* -A=file: Additional CA certificate file to trust\n"); + printf("* -A=file: CA certificate file to trust\n"); #endif #if defined(WOLFTPM_CRYPTOCB) && defined(HAVE_PK_CALLBACKS) printf("* -pk: Use PK callbacks, not crypto callbacks\n"); @@ -537,7 +537,15 @@ tls_setup: #endif #else /* Load CA Certificates */ - if (!useECC) { + if (caFile != NULL) { + if (wolfSSL_CTX_load_verify_locations(ctx, caFile, + 0) != WOLFSSL_SUCCESS) { + printf("Error loading %s cert\n", caFile); + rc = -1; + goto exit; + } + } + else if (!useECC) { #ifndef NO_RSA if (wolfSSL_CTX_load_verify_locations(ctx, CA_RSA_CERT_PATH, 0) != WOLFSSL_SUCCESS) { @@ -579,14 +587,6 @@ tls_setup: goto exit; #endif /* HAVE_ECC */ } - if (caFile != NULL) { - if (wolfSSL_CTX_load_verify_locations(ctx, caFile, - 0) != WOLFSSL_SUCCESS) { - printf("Error loading %s cert\n", caFile); - rc = -1; - goto exit; - } - } #endif /* !NO_FILESYSTEM */