mirror of https://github.com/wolfSSL/wolfTPM.git
Fix for building with wolfTPM without wolfCrypt `--disable-wolfcrypt`. Added test.
parent
ee2f766554
commit
af0668eafd
|
@ -44,4 +44,11 @@ jobs:
|
||||||
- name: make test
|
- name: make test
|
||||||
run: |
|
run: |
|
||||||
./ibmswtpm2/src/tpm_server &
|
./ibmswtpm2/src/tpm_server &
|
||||||
sleep 10 && make test && ./examples/native/native_test && ./examples/wrap/wrap_test
|
sleep 2 && make check && ./examples/native/native_test && ./examples/wrap/wrap_test
|
||||||
|
|
||||||
|
#test wolfTPM without wolfCrypt
|
||||||
|
- name: configure no wolfCrypt
|
||||||
|
run: ./configure --enable-swtpm --disable-wolfcrypt
|
||||||
|
- name: make test no wolfCrypt
|
||||||
|
run: |
|
||||||
|
make check && ./examples/native/native_test && ./examples/wrap/wrap_test
|
||||||
|
|
|
@ -61,9 +61,11 @@ int TPM2_Keyimport_Example(void* userCtx, int argc, char *argv[])
|
||||||
|
|
||||||
#if !defined(NO_FILESYSTEM) && !defined(NO_WRITE_TEMP_FILES)
|
#if !defined(NO_FILESYSTEM) && !defined(NO_WRITE_TEMP_FILES)
|
||||||
byte pemEncode = 0;
|
byte pemEncode = 0;
|
||||||
FILE* pemFile = NULL;
|
|
||||||
const char* pemName = "./certs/example-rsa-key.pem";
|
const char* pemName = "./certs/example-rsa-key.pem";
|
||||||
|
#if !defined(WOLFTPM2_NO_WOLFCRYPT) && !defined(NO_RSA)
|
||||||
|
FILE* pemFile = NULL;
|
||||||
char pemBuf[WOLFTPM2_MAX_BUFFER];
|
char pemBuf[WOLFTPM2_MAX_BUFFER];
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (argc >= 2) {
|
if (argc >= 2) {
|
||||||
|
@ -158,28 +160,35 @@ int TPM2_Keyimport_Example(void* userCtx, int argc, char *argv[])
|
||||||
|
|
||||||
if (alg == TPM_ALG_RSA) {
|
if (alg == TPM_ALG_RSA) {
|
||||||
if (derEncode == 1) {
|
if (derEncode == 1) {
|
||||||
|
#if !defined(WOLFTPM2_NO_WOLFCRYPT) && !defined(NO_RSA)
|
||||||
rc = wolfTPM2_RsaPrivateKeyImportDer(&dev, &storage, &impKey,
|
rc = wolfTPM2_RsaPrivateKeyImportDer(&dev, &storage, &impKey,
|
||||||
kRsaKeyPrivDer, sizeof(kRsaKeyPrivDer), TPM_ALG_NULL,
|
kRsaKeyPrivDer, sizeof(kRsaKeyPrivDer), TPM_ALG_NULL,
|
||||||
TPM_ALG_NULL);
|
TPM_ALG_NULL);
|
||||||
|
#else
|
||||||
|
rc = NOT_COMPILED_IN;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#if !defined(NO_FILESYSTEM) && !defined(NO_WRITE_TEMP_FILES)
|
#if !defined(NO_FILESYSTEM) && !defined(NO_WRITE_TEMP_FILES)
|
||||||
else if (pemEncode == 1) {
|
else if (pemEncode == 1) {
|
||||||
|
#if !defined(WOLFTPM2_NO_WOLFCRYPT) && !defined(NO_RSA)
|
||||||
pemFile = XFOPEN(pemName, "r");
|
pemFile = XFOPEN(pemName, "r");
|
||||||
|
if (pemFile != XBADFILE) {
|
||||||
if (pemFile == NULL)
|
|
||||||
printf("Failed to read pem file %s\n", pemName);
|
|
||||||
|
|
||||||
if (rc == 0)
|
|
||||||
rc = (int)XFREAD(pemBuf, 1, sizeof(pemBuf), pemFile);
|
rc = (int)XFREAD(pemBuf, 1, sizeof(pemBuf), pemFile);
|
||||||
|
|
||||||
if (rc > 0) {
|
if (rc > 0) {
|
||||||
rc = wolfTPM2_RsaPrivateKeyImportPem(&dev, &storage, &impKey,
|
rc = wolfTPM2_RsaPrivateKeyImportPem(&dev, &storage, &impKey,
|
||||||
pemBuf, rc, NULL, TPM_ALG_NULL, TPM_ALG_NULL);
|
pemBuf, rc, NULL, TPM_ALG_NULL, TPM_ALG_NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
XFCLOSE(pemFile);
|
XFCLOSE(pemFile);
|
||||||
}
|
}
|
||||||
#endif
|
else {
|
||||||
|
printf("Failed to read pem file %s\n", pemName);
|
||||||
|
rc = BUFFER_E;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
rc = NOT_COMPILED_IN;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
else {
|
else {
|
||||||
/* Import raw RSA private key into TPM */
|
/* Import raw RSA private key into TPM */
|
||||||
rc = wolfTPM2_ImportRsaPrivateKey(&dev, &storage, &impKey,
|
rc = wolfTPM2_ImportRsaPrivateKey(&dev, &storage, &impKey,
|
||||||
|
|
|
@ -115,6 +115,9 @@ typedef int64_t INT64;
|
||||||
#ifndef XFEOF
|
#ifndef XFEOF
|
||||||
#define XFEOF feof
|
#define XFEOF feof
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef XREWIND
|
||||||
|
#define XREWIND rewind
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -148,6 +151,7 @@ typedef int64_t INT64;
|
||||||
#define XSTRLEN(s1) strlen((s1))
|
#define XSTRLEN(s1) strlen((s1))
|
||||||
#define XSTRCMP(s1,s2) strcmp((s1),(s2))
|
#define XSTRCMP(s1,s2) strcmp((s1),(s2))
|
||||||
#define XSTRSTR(s1,s2) strstr((s1),(s2))
|
#define XSTRSTR(s1,s2) strstr((s1),(s2))
|
||||||
|
#define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n))
|
||||||
#endif /* !WOLFTPM_CUSTOM_TYPES */
|
#endif /* !WOLFTPM_CUSTOM_TYPES */
|
||||||
|
|
||||||
/* Endianess */
|
/* Endianess */
|
||||||
|
|
Loading…
Reference in New Issue