mirror of https://github.com/wolfSSL/wolfTPM.git
Fix for building with no PEM to DER. Fix for building with static library and no debug, due to missing stdio in examples. Fix for TLS examples missing WOLFCRYPT_ONLY check. Fix for building with WC_NO_RNG. Fix for RSA salt with RNG using crypto cb.
parent
fb5d43d912
commit
0ceeebeaf7
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef WOLFTPM2_NO_WRAPPER
|
||||
|
||||
#include <examples/attestation/credential.h>
|
||||
|
|
@ -32,8 +34,6 @@
|
|||
#include <examples/tpm_test.h>
|
||||
#include <examples/tpm_test_keys.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* --- BEGIN TPM2.0 Activate Credential example tool -- */
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
#include <wolftpm/tpm2.h>
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if !defined(WOLFTPM2_NO_WRAPPER) && !defined(NO_TPM_BENCH)
|
||||
|
||||
#include <hal/tpm_io.h>
|
||||
|
|
@ -32,8 +34,6 @@
|
|||
#include <examples/tpm_test_keys.h>
|
||||
#include <examples/bench/bench.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Configuration */
|
||||
#define TPM2_BENCH_DURATION_SEC 1
|
||||
#define TPM2_BENCH_DURATION_KEYGEN_SEC 15
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
#include <wolftpm/tpm2.h>
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if !defined(WOLFTPM2_NO_WRAPPER) && defined(WOLFTPM2_CERT_GEN)
|
||||
|
||||
#include <hal/tpm_io.h>
|
||||
|
|
@ -31,8 +33,6 @@
|
|||
#include <examples/csr/csr.h>
|
||||
#include <wolfssl/wolfcrypt/asn_public.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef NO_RSA
|
||||
static const char* gClientCsrRsaFile = "./certs/tpm-rsa-cert.csr";
|
||||
static const char* gClientCertRsaFile = "./certs/tpm-rsa-cert.pem";
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if !defined(WOLFTPM2_NO_WRAPPER) && \
|
||||
(defined(WOLFTPM_ST33) || defined(WOLFTPM_NUVOTON))
|
||||
|
||||
|
|
@ -31,8 +33,6 @@
|
|||
#include <hal/tpm_io.h>
|
||||
#include <examples/tpm_test.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/******************************************************************************/
|
||||
/* --- BEGIN TPM2.0 GPIO Configuration example -- */
|
||||
/******************************************************************************/
|
||||
|
|
|
|||
|
|
@ -27,15 +27,16 @@
|
|||
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <examples/gpio/gpio.h>
|
||||
#include <hal/tpm_io.h>
|
||||
#include <examples/tpm_test.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if !defined(WOLFTPM2_NO_WRAPPER) && \
|
||||
(defined(WOLFTPM_ST33) || defined(WOLFTPM_NUVOTON))
|
||||
|
||||
|
||||
#include <examples/gpio/gpio.h>
|
||||
#include <hal/tpm_io.h>
|
||||
#include <examples/tpm_test.h>
|
||||
|
||||
/******************************************************************************/
|
||||
/* --- BEGIN TPM GPIO Set Example -- */
|
||||
/******************************************************************************/
|
||||
|
|
|
|||
|
|
@ -23,15 +23,15 @@
|
|||
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef WOLFTPM2_NO_WRAPPER
|
||||
|
||||
#include <examples/keygen/keygen.h>
|
||||
#include <hal/tpm_io.h>
|
||||
#include <examples/tpm_test.h>
|
||||
#include <examples/tpm_test_keys.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef WOLFTPM2_NO_WRAPPER
|
||||
|
||||
/******************************************************************************/
|
||||
/* --- BEGIN TPM Create Primary Key Example -- */
|
||||
/******************************************************************************/
|
||||
|
|
|
|||
|
|
@ -23,15 +23,15 @@
|
|||
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef WOLFTPM2_NO_WRAPPER
|
||||
|
||||
#include <examples/keygen/keygen.h>
|
||||
#include <hal/tpm_io.h>
|
||||
#include <examples/tpm_test.h>
|
||||
#include <examples/tpm_test_keys.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef WOLFTPM2_NO_WRAPPER
|
||||
|
||||
#define SYM_EXTRA_OPTS_LEN 14 /* 5 chars for "-sym=" and 9 for extra options */
|
||||
#define SYM_EXTRA_OPTS_POS 4 /* Array pos of the equal sign for extra opts */
|
||||
#define SYM_EXTRA_OPTS_AES_MODE_POS 8
|
||||
|
|
|
|||
|
|
@ -23,16 +23,15 @@
|
|||
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if !defined(WOLFTPM2_NO_WRAPPER) && !defined(WOLFTPM2_NO_WOLFCRYPT)
|
||||
|
||||
#include <examples/keygen/keygen.h>
|
||||
#include <hal/tpm_io.h>
|
||||
#include <examples/tpm_test.h>
|
||||
#include <examples/tpm_test_keys.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#if !defined(WOLFTPM2_NO_WRAPPER) && !defined(WOLFTPM2_NO_WOLFCRYPT)
|
||||
|
||||
/******************************************************************************/
|
||||
/* --- BEGIN TPM Key Import / Blob Example -- */
|
||||
/******************************************************************************/
|
||||
|
|
|
|||
|
|
@ -31,15 +31,15 @@
|
|||
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef WOLFTPM2_NO_WRAPPER
|
||||
|
||||
#include <examples/keygen/keygen.h>
|
||||
#include <hal/tpm_io.h>
|
||||
#include <examples/tpm_test.h>
|
||||
#include <examples/tpm_test_keys.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#ifndef WOLFTPM2_NO_WRAPPER
|
||||
/******************************************************************************/
|
||||
/* --- BEGIN TPM Key Load Example -- */
|
||||
/******************************************************************************/
|
||||
|
|
|
|||
|
|
@ -28,15 +28,15 @@
|
|||
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef WOLFTPM2_NO_WRAPPER
|
||||
|
||||
#include <examples/nvram/nvram.h>
|
||||
#include <hal/tpm_io.h>
|
||||
#include <examples/tpm_test.h>
|
||||
#include <examples/tpm_test_keys.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef WOLFTPM2_NO_WRAPPER
|
||||
|
||||
/******************************************************************************/
|
||||
/* --- BEGIN TPM NV Counter Example -- */
|
||||
/******************************************************************************/
|
||||
|
|
|
|||
|
|
@ -28,15 +28,15 @@
|
|||
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef WOLFTPM2_NO_WRAPPER
|
||||
|
||||
#include <examples/nvram/nvram.h>
|
||||
#include <hal/tpm_io.h>
|
||||
#include <examples/tpm_test.h>
|
||||
#include <examples/tpm_test_keys.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef WOLFTPM2_NO_WRAPPER
|
||||
|
||||
#define PRIVATE_PART_ONLY 0x01
|
||||
#define PUBLIC_PART_ONLY 0x02
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if !defined(WOLFTPM2_NO_WRAPPER) && !defined(WOLFTPM2_NO_WOLFCRYPT) && \
|
||||
defined(WOLFSSL_PUBLIC_MP)
|
||||
|
||||
|
|
@ -36,8 +38,6 @@
|
|||
#include <examples/tpm_test.h>
|
||||
#include <examples/tpm_test_keys.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define ECC_KEY_SIZE 32
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
|||
|
|
@ -28,15 +28,15 @@
|
|||
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef WOLFTPM2_NO_WRAPPER
|
||||
|
||||
#include <examples/nvram/nvram.h>
|
||||
#include <hal/tpm_io.h>
|
||||
#include <examples/tpm_test.h>
|
||||
#include <examples/tpm_test_keys.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef WOLFTPM2_NO_WRAPPER
|
||||
|
||||
#define PRIVATE_PART_ONLY 0x01
|
||||
#define PUBLIC_PART_ONLY 0x02
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef WOLFTPM2_NO_WRAPPER
|
||||
|
||||
#ifndef WOLFTPM2_NO_WOLFCRYPT
|
||||
|
|
@ -33,8 +35,6 @@
|
|||
#include <examples/pcr/pcr.h>
|
||||
#include <examples/tpm_test.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static signed char HexCharToByte(signed char ch)
|
||||
{
|
||||
signed char ret = (signed char)ch;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef WOLFTPM2_NO_WRAPPER
|
||||
|
||||
#ifndef WOLFTPM2_NO_WOLFCRYPT
|
||||
|
|
@ -33,8 +35,6 @@
|
|||
#include <hal/tpm_io.h>
|
||||
#include <examples/tpm_test.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* --- BEGIN TPM2.0 PCR Read example tool -- */
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
#include <wolftpm/tpm2.h>
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if !defined(WOLFTPM2_NO_WRAPPER) && defined(WOLFTPM_CRYPTOCB) && \
|
||||
defined(HAVE_PKCS7)
|
||||
|
||||
|
|
@ -32,8 +34,6 @@
|
|||
#include <examples/pkcs7/pkcs7.h>
|
||||
#include <wolfssl/wolfcrypt/pkcs7.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Sign PKCS7 using TPM based key:
|
||||
* Must Run:
|
||||
* 1. `./examples/csr/csr`
|
||||
|
|
|
|||
|
|
@ -23,12 +23,15 @@
|
|||
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef WOLFTPM2_NO_WRAPPER
|
||||
|
||||
#include <examples/seal/seal.h>
|
||||
#include <hal/tpm_io.h>
|
||||
#include <examples/tpm_test.h>
|
||||
#include <examples/tpm_test_keys.h>
|
||||
|
||||
#ifndef WOLFTPM2_NO_WRAPPER
|
||||
|
||||
/******************************************************************************/
|
||||
/* --- BEGIN TPM2.0 Seal Example -- */
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef WOLFTPM2_NO_WRAPPER
|
||||
|
||||
#ifndef WOLFTPM2_NO_WOLFCRYPT
|
||||
|
|
@ -34,8 +36,6 @@
|
|||
#include <examples/tpm_test.h>
|
||||
#include <examples/tpm_test_keys.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/******************************************************************************/
|
||||
/* --- BEGIN TPM2.0 PCR Policy example tool -- */
|
||||
/******************************************************************************/
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if !defined(WOLFTPM2_NO_WRAPPER) && !defined(NO_FILESYSTEM)
|
||||
|
||||
#include <examples/seal/seal.h>
|
||||
|
|
@ -30,8 +32,6 @@
|
|||
#include <examples/tpm_test.h>
|
||||
#include <examples/tpm_test_keys.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* --- BEGIN TPM2.0 Unseal example --- */
|
||||
|
|
|
|||
|
|
@ -23,14 +23,14 @@
|
|||
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef WOLFTPM2_NO_WRAPPER
|
||||
|
||||
#include <hal/tpm_io.h>
|
||||
#include <examples/tpm_test.h>
|
||||
#include "clock_set.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/******************************************************************************/
|
||||
/* --- BEGIN TPM Clock Set Example -- */
|
||||
/******************************************************************************/
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef WOLFTPM2_NO_WRAPPER
|
||||
|
||||
#include <hal/tpm_io.h>
|
||||
|
|
@ -32,8 +34,6 @@
|
|||
#include <examples/tpm_test_keys.h>
|
||||
#include "signed_timestamp.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* --- BEGIN TPM Timestamp Test -- */
|
||||
|
|
|
|||
|
|
@ -23,8 +23,10 @@
|
|||
#include <wolftpm/tpm2.h>
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if !defined(WOLFTPM2_NO_WRAPPER) && defined(WOLFTPM_CRYPTOCB) && \
|
||||
!defined(NO_WOLFSSL_CLIENT)
|
||||
!defined(NO_WOLFSSL_CLIENT) && !defined(WOLFCRYPT_ONLY)
|
||||
|
||||
#include <hal/tpm_io.h>
|
||||
#include <examples/tpm_test.h>
|
||||
|
|
@ -40,8 +42,6 @@
|
|||
#define USE_CERT_BUFFERS_256
|
||||
#include <wolfssl/certs_test.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef TLS_BENCH_MODE
|
||||
double benchStart;
|
||||
#endif
|
||||
|
|
@ -574,7 +574,8 @@ exit:
|
|||
/* --- END TPM TLS Client Example -- */
|
||||
/******************************************************************************/
|
||||
|
||||
#endif /* !WOLFTPM2_NO_WRAPPER && WOLFTPM_CRYPTOCB && !NO_WOLFSSL_CLIENT */
|
||||
#endif /* !WOLFTPM2_NO_WRAPPER && WOLFTPM_CRYPTOCB && !NO_WOLFSSL_CLIENT && \
|
||||
* !WOLFCRYPT_ONLY */
|
||||
|
||||
#ifndef NO_MAIN_DRIVER
|
||||
int main(int argc, char* argv[])
|
||||
|
|
@ -582,13 +583,13 @@ int main(int argc, char* argv[])
|
|||
int rc = -1;
|
||||
|
||||
#if !defined(WOLFTPM2_NO_WRAPPER) && defined(WOLFTPM_CRYPTOCB) && \
|
||||
!defined(NO_WOLFSSL_CLIENT)
|
||||
!defined(NO_WOLFSSL_CLIENT) && !defined(WOLFCRYPT_ONLY)
|
||||
rc = TPM2_TLS_ClientArgs(NULL, argc, argv);
|
||||
#else
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
printf("Wrapper/Crypto callback code not compiled in\n");
|
||||
printf("Wrapper/Crypto callback code or TLS support not compiled in\n");
|
||||
printf("Build wolfssl with ./configure --enable-cryptocb\n");
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
#include <wolftpm/tpm2.h>
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if !defined(WOLFTPM2_NO_WRAPPER) && !defined(WOLFTPM2_NO_WOLFCRYPT) && \
|
||||
!defined(NO_WOLFSSL_CLIENT) && !defined(WOLFCRYPT_ONLY)
|
||||
|
||||
|
|
@ -40,8 +42,6 @@
|
|||
#define USE_CERT_BUFFERS_256
|
||||
#include <wolfssl/certs_test.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef TLS_BENCH_MODE
|
||||
double benchStart;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@
|
|||
#include <wolftpm/tpm2.h>
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#if !defined(WOLFTPM2_NO_WRAPPER) && !defined(WOLFTPM2_NO_WOLFCRYPT) && !defined(WOLFCRYPT_ONLY)
|
||||
#if !defined(WOLFTPM2_NO_WRAPPER) && !defined(WOLFTPM2_NO_WOLFCRYPT) && \
|
||||
!defined(WOLFCRYPT_ONLY)
|
||||
|
||||
#include <wolftpm/tpm2_socket.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -23,8 +23,10 @@
|
|||
#include <wolftpm/tpm2.h>
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if !defined(WOLFTPM2_NO_WRAPPER) && defined(WOLFTPM_CRYPTOCB) && \
|
||||
!defined(NO_WOLFSSL_SERVER)
|
||||
!defined(NO_WOLFSSL_SERVER) && !defined(WOLFCRYPT_ONLY)
|
||||
|
||||
#include <hal/tpm_io.h>
|
||||
#include <examples/tpm_test.h>
|
||||
|
|
@ -34,8 +36,6 @@
|
|||
|
||||
#include <wolfssl/ssl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef TLS_BENCH_MODE
|
||||
double benchStart;
|
||||
#endif
|
||||
|
|
@ -552,7 +552,8 @@ exit:
|
|||
/* --- END TLS Server Example -- */
|
||||
/******************************************************************************/
|
||||
|
||||
#endif /* !WOLFTPM2_NO_WRAPPER && WOLFTPM_CRYPTOCB && !NO_WOLFSSL_SERVER */
|
||||
#endif /* !WOLFTPM2_NO_WRAPPER && WOLFTPM_CRYPTOCB && !NO_WOLFSSL_SERVER && \
|
||||
* !WOLFCRYPT_ONLY */
|
||||
|
||||
#ifndef NO_MAIN_DRIVER
|
||||
int main(int argc, char* argv[])
|
||||
|
|
@ -560,13 +561,13 @@ int main(int argc, char* argv[])
|
|||
int rc = -1;
|
||||
|
||||
#if !defined(WOLFTPM2_NO_WRAPPER) && defined(WOLFTPM_CRYPTOCB) && \
|
||||
!defined(NO_WOLFSSL_SERVER)
|
||||
!defined(NO_WOLFSSL_SERVER) && !defined(WOLFCRYPT_ONLY)
|
||||
rc = TPM2_TLS_ServerArgs(NULL, argc, argv);
|
||||
#else
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
printf("Wrapper/Crypto callback code not compiled in\n");
|
||||
printf("Wrapper/Crypto callback code or TLS support not compiled in\n");
|
||||
printf("Build wolfssl with ./configure --enable-cryptocb\n");
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@
|
|||
#include "tpm_test_keys.h"
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define RSA_FILENAME "rsa_test_blob.raw"
|
||||
#define ECC_FILENAME "ecc_test_blob.raw"
|
||||
|
||||
|
|
|
|||
|
|
@ -24,14 +24,14 @@
|
|||
#include <wolftpm/tpm2.h>
|
||||
#include <wolftpm/tpm2_wrap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef WOLFTPM2_NO_WRAPPER
|
||||
|
||||
#include <hal/tpm_io.h>
|
||||
#include <examples/tpm_test.h>
|
||||
#include <examples/wrap/wrap_test.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Configuration */
|
||||
#if 0
|
||||
#define ENABLE_LARGE_HASH_TEST /* optional large hash test */
|
||||
|
|
@ -110,8 +110,8 @@ int TPM2_Wrapper_TestArgs(void* userCtx, int argc, char *argv[])
|
|||
"\x88\x1d\xc2\x00\xc9\x83\x3d\xa7\x26\xe9\x37\x6c\x2e\x32\xcf\xf7";
|
||||
|
||||
#ifndef WOLFTPM2_NO_WOLFCRYPT
|
||||
#if defined(HAVE_ECC) || !defined(NO_RSA)
|
||||
int tpmDevId = INVALID_DEVID;
|
||||
#if defined(HAVE_ECC) || !defined(NO_RSA)
|
||||
word32 idx;
|
||||
#endif
|
||||
#ifndef NO_RSA
|
||||
|
|
|
|||
|
|
@ -5894,10 +5894,12 @@ int TPM2_GetWolfRng(WC_RNG** rng)
|
|||
return BAD_FUNC_ARG;
|
||||
|
||||
if (!ctx->rngInit) {
|
||||
rc = wc_InitRng(&ctx->rng);
|
||||
/* Use did_vid for devId (conforms with wolfTPM2_GetTpmDevId) */
|
||||
rc = wc_InitRng_ex(&ctx->rng, NULL, ctx->did_vid);
|
||||
if (rc < 0) {
|
||||
#ifdef DEBUG_WOLFTPM
|
||||
printf("wc_InitRng failed %d: %s\n", (int)rc, wc_GetErrorString(rc));
|
||||
printf("wc_InitRng_ex failed %d: %s\n",
|
||||
(int)rc, wc_GetErrorString(rc));
|
||||
#endif
|
||||
return rc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -556,7 +556,7 @@ int wolfTPM2_GetTpmDevId(WOLFTPM2_DEV* dev)
|
|||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
return dev->ctx.did_vid; /* return something besides INVALID_DEVID */
|
||||
return (int)dev->ctx.did_vid; /* return something besides INVALID_DEVID */
|
||||
}
|
||||
|
||||
int wolfTPM2_SelfTest(WOLFTPM2_DEV* dev)
|
||||
|
|
@ -940,7 +940,7 @@ int wolfTPM2_Cleanup(WOLFTPM2_DEV* dev)
|
|||
#endif
|
||||
}
|
||||
|
||||
#if !defined(WOLFTPM2_NO_WOLFCRYPT) && !defined(NO_RSA)
|
||||
#if !defined(WOLFTPM2_NO_WOLFCRYPT) && !defined(NO_RSA) && !defined(WC_NO_RNG)
|
||||
/* returns both the plaintext and encrypted salt, based on the salt key bPublic. */
|
||||
int wolfTPM2_RSA_Salt(WOLFTPM2_DEV* dev, WOLFTPM2_KEY* tpmKey,
|
||||
TPM2B_DIGEST *salt, TPM2B_ENCRYPTED_SECRET *encSalt,
|
||||
|
|
@ -952,6 +952,7 @@ int wolfTPM2_RSA_Salt(WOLFTPM2_DEV* dev, WOLFTPM2_KEY* tpmKey,
|
|||
const char* label = "SECRET";
|
||||
int mgf;
|
||||
RsaKey rsaKey;
|
||||
int devId;
|
||||
|
||||
if (dev == NULL || salt == NULL || encSalt == NULL || publicArea == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
|
|
@ -969,11 +970,12 @@ int wolfTPM2_RSA_Salt(WOLFTPM2_DEV* dev, WOLFTPM2_KEY* tpmKey,
|
|||
return NOT_COMPILED_IN;
|
||||
}
|
||||
|
||||
rc = wc_InitRng(&rng);
|
||||
devId = wolfTPM2_GetTpmDevId(dev);
|
||||
rc = wc_InitRng_ex(&rng, NULL, devId);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
||||
rc = wc_InitRsaKey_ex(&rsaKey, NULL, INVALID_DEVID);
|
||||
rc = wc_InitRsaKey_ex(&rsaKey, NULL, devId);
|
||||
if (rc != 0) {
|
||||
wc_FreeRng(&rng);
|
||||
return rc;
|
||||
|
|
@ -1013,7 +1015,7 @@ int wolfTPM2_RSA_Salt(WOLFTPM2_DEV* dev, WOLFTPM2_KEY* tpmKey,
|
|||
|
||||
return rc;
|
||||
}
|
||||
#endif /* !WOLFTPM2_NO_WOLFCRYPT && !NO_RSA */
|
||||
#endif /* !WOLFTPM2_NO_WOLFCRYPT && !NO_RSA && !WC_NO_RNG */
|
||||
|
||||
int wolfTPM2_EncryptSalt(WOLFTPM2_DEV* dev, WOLFTPM2_KEY* tpmKey,
|
||||
StartAuthSession_In* in, TPM2B_AUTH* bindAuth, TPM2B_DIGEST* salt)
|
||||
|
|
@ -1048,7 +1050,7 @@ int wolfTPM2_EncryptSalt(WOLFTPM2_DEV* dev, WOLFTPM2_KEY* tpmKey,
|
|||
rc = NOT_COMPILED_IN;
|
||||
break;
|
||||
#endif
|
||||
#ifndef NO_RSA
|
||||
#if !defined(NO_RSA) && !defined(WC_NO_RNG)
|
||||
case TPM_ALG_RSA:
|
||||
rc = wolfTPM2_RSA_Salt(dev, tpmKey, salt, &in->encryptedSalt,
|
||||
&tpmKey->pub.publicArea);
|
||||
|
|
@ -2169,7 +2171,7 @@ int wolfTPM2_RsaPrivateKeyImportDer(WOLFTPM2_DEV* dev,
|
|||
return rc;
|
||||
}
|
||||
|
||||
#ifndef WOLFTPM2_NO_HEAP
|
||||
#if !defined(WOLFTPM2_NO_HEAP) && defined(WOLFSSL_PEM_TO_DER)
|
||||
|
||||
int wolfTPM2_RsaPrivateKeyImportPem(WOLFTPM2_DEV* dev,
|
||||
const WOLFTPM2_KEY* parentKey, WOLFTPM2_KEYBLOB* keyBlob,
|
||||
|
|
@ -2209,7 +2211,7 @@ int wolfTPM2_RsaPrivateKeyImportPem(WOLFTPM2_DEV* dev,
|
|||
return rc;
|
||||
}
|
||||
|
||||
#endif /* WOLFTPM2_NO_HEAP */
|
||||
#endif /* !WOLFTPM2_NO_HEAP && WOLFSSL_PEM_TO_DER */
|
||||
|
||||
int wolfTPM2_RsaKey_TpmToWolf(WOLFTPM2_DEV* dev, WOLFTPM2_KEY* tpmKey,
|
||||
RsaKey* wolfKey)
|
||||
|
|
@ -5694,10 +5696,12 @@ int wolfTPM2_CryptoDevCb(int devId, wc_CryptoInfo* info, void* ctx)
|
|||
#endif /* !WC_NO_RNG */
|
||||
}
|
||||
else if (info->algo_type == WC_ALGO_TYPE_SEED) {
|
||||
#ifndef WC_NO_RNG
|
||||
#ifdef DEBUG_WOLFTPM
|
||||
printf("CryptoDevCb RNG Seed: Sz %d\n", info->seed.sz);
|
||||
#endif
|
||||
rc = wolfTPM2_GetRandom(tlsCtx->dev, info->seed.seed, info->seed.sz);
|
||||
#endif /* !WC_NO_RNG */
|
||||
}
|
||||
#if !defined(NO_RSA) || defined(HAVE_ECC)
|
||||
else if (info->algo_type == WC_ALGO_TYPE_PK) {
|
||||
|
|
|
|||
|
|
@ -3609,7 +3609,6 @@ typedef enum {
|
|||
\endcode
|
||||
|
||||
\sa TPM2_GetCapabilities
|
||||
\sa TPM2_GetTpmDevId
|
||||
\sa TPM2_Init
|
||||
*/
|
||||
WOLFTPM_API UINT16 TPM2_GetVendorID(void);
|
||||
|
|
|
|||
Loading…
Reference in New Issue