From b199c2e44471274e9f4cc4b993dd732cf4770a36 Mon Sep 17 00:00:00 2001 From: Tesfa Mael Date: Mon, 22 Feb 2021 17:11:12 -0800 Subject: [PATCH] Fix PKCS8 test --- wolfcrypt/src/asn.c | 5 ++--- wolfcrypt/test/test.c | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index ae3c5d86c..e4fe97ed1 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -2773,7 +2773,7 @@ int ToTraditional(byte* input, word32 sz) #endif /* HAVE_PKCS8 || HAVE_PKCS12 */ -#ifdef HAVE_PKCS8 +#if defined(HAVE_PKCS8) && !defined(NO_CERTS) /* find beginning of traditional key inside PKCS#8 unencrypted buffer * return traditional length on success, with inOutIdx at beginning of @@ -2867,7 +2867,6 @@ int wc_CreatePKCS8Key(byte* out, word32* outSz, byte* key, word32 keySz, * no header information just INTEGER */ sz = SetMyVersion(PKCS8v0, out + keyIdx, 0); tmpSz += sz; keyIdx += sz; - /* privateKeyAlgorithm PrivateKeyAlgorithmIdentifier */ sz = 0; /* set sz to 0 and get privateKey oid buffer size needed */ if (curveOID != NULL && oidSz > 0) { @@ -2903,7 +2902,7 @@ int wc_CreatePKCS8Key(byte* out, word32* outSz, byte* key, word32 keySz, return tmpSz + sz; } -#endif /* HAVE_PKCS8 */ +#endif /* HAVE_PKCS8 && !NO_CERTS */ #if defined(HAVE_PKCS12) || !defined(NO_CHECK_PRIVATE_KEY) /* check that the private key is a pair for the public key diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 4be5bff6a..f719127b3 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -11825,10 +11825,11 @@ byte GetEntropy(ENTROPY_CMD cmd, byte* out) static const char* eccCaKeyPemFile = CERT_WRITE_TEMP_DIR "ecc-key.pem"; static const char* eccPubKeyDerFile = CERT_WRITE_TEMP_DIR "ecc-public-key.der"; static const char* eccCaKeyTempFile = CERT_WRITE_TEMP_DIR "ecc-key.der"; - #endif + #ifdef HAVE_PKCS8 static const char* eccPkcs8KeyDerFile = CERT_WRITE_TEMP_DIR "ecc-key-pkcs8.der"; #endif + #endif /* HAVE_ECC_KEY_EXPORT */ #if defined(WOLFSSL_CERT_GEN) || \ (defined(WOLFSSL_CERT_EXT) && defined(WOLFSSL_TEST_CERT)) static const char* certEccDerFile = CERT_WRITE_TEMP_DIR "certecc.der";