From 004b0d3793aff03e681e127ae01f84ede2fb95a9 Mon Sep 17 00:00:00 2001 From: Chris Conlon Date: Thu, 25 Oct 2018 15:45:50 -0600 Subject: [PATCH] PKCS7/CMS build fixes when disabling RSA, ECC, or AES-GCM/CCM --- wolfcrypt/src/pkcs7.c | 11 ++++++-- wolfcrypt/test/test.c | 59 ++++++++++++++++--------------------------- 2 files changed, 31 insertions(+), 39 deletions(-) diff --git a/wolfcrypt/src/pkcs7.c b/wolfcrypt/src/pkcs7.c index 68004353b..a9fc26539 100644 --- a/wolfcrypt/src/pkcs7.c +++ b/wolfcrypt/src/pkcs7.c @@ -8168,10 +8168,13 @@ static int wc_PKCS7_DecryptKari(PKCS7* pkcs7, byte* in, word32 inSz, } return ret; -#else - (void)pkcs7; + (void)pkiMsg; (void)pkiMsgSz; +#else + (void)in; + (void)inSz; + (void)pkcs7; (void)idx; (void)decryptedKey; (void)decryptedKeySz; @@ -8206,8 +8209,12 @@ static int wc_PKCS7_DecryptRecipientInfos(PKCS7* pkcs7, byte* in, case WC_PKCS7_DECRYPT_KTRI: case WC_PKCS7_DECRYPT_KTRI_2: case WC_PKCS7_DECRYPT_KTRI_3: + #ifndef NO_RSA ret = wc_PKCS7_DecryptKtri(pkcs7, in, inSz, idx, decryptedKey, decryptedKeySz, recipFound); + #else + return NOT_COMPILED_IN; + #endif break; case WC_PKCS7_DECRYPT_KARI: diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index b2657bf72..aa2412455 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -329,7 +329,9 @@ int scrypt_test(void); #endif int pkcs7signed_test(void); int pkcs7enveloped_test(void); - int pkcs7authenveloped_test(void); + #if defined(HAVE_AESGCM) || defined(HAVE_AESCCM) + int pkcs7authenveloped_test(void); + #endif #endif #if !defined(NO_ASN_TIME) && !defined(NO_RSA) && defined(WOLFSSL_TEST_CERT) int cert_test(void); @@ -974,10 +976,12 @@ initDefaultName(); else printf( "PKCS7enveloped test passed!\n"); - if ( (ret = pkcs7authenveloped_test()) != 0) - return err_sys("PKCS7authenveloped test failed!\n", ret); - else - printf( "PKCS7authenveloped test passed!\n"); + #if defined(HAVE_AESGCM) || defined(HAVE_AESCCM) + if ( (ret = pkcs7authenveloped_test()) != 0) + return err_sys("PKCS7authenveloped test failed!\n", ret); + else + printf( "PKCS7authenveloped test passed!\n"); + #endif #endif #ifdef HAVE_VALGRIND @@ -19538,6 +19542,8 @@ int pkcs7enveloped_test(void) } +#if defined(HAVE_AESGCM) || defined(HAVE_AESCCM) + typedef struct { const byte* content; word32 contentSz; @@ -20168,6 +20174,8 @@ int pkcs7authenveloped_test(void) return ret; } +#endif /* HAVE_AESGCM || HAVE_AESCCM */ + #ifndef NO_PKCS7_ENCRYPTED_DATA @@ -21011,13 +21019,6 @@ static int pkcs7signed_run_vectors( if (ret > 0) return 0; -#ifndef HAVE_ECC - (void)eccCert; - (void)eccCertSz; - (void)eccPrivKey; - (void)eccPrivKeySz; -#endif -#ifdef NO_RSA (void)rsaClientCertBuf; (void)rsaClientCertBufSz; (void)rsaClientPrivKeyBuf; @@ -21030,16 +21031,11 @@ static int pkcs7signed_run_vectors( (void)rsaCaCertBufSz; (void)rsaCaPrivKeyBuf; (void)rsaCaPrivKeyBufSz; -#endif + (void)eccClientCertBuf; + (void)eccClientCertBufSz; + (void)eccClientPrivKeyBuf; + (void)eccClientPrivKeyBufSz; - (void)rsaServerCertBuf; - (void)rsaServerCertBufSz; - (void)rsaServerPrivKeyBuf; - (void)rsaServerPrivKeyBufSz; - (void)rsaCaCertBuf; - (void)rsaCaCertBufSz; - (void)rsaCaPrivKeyBuf; - (void)rsaCaPrivKeyBufSz; return ret; } @@ -21570,13 +21566,11 @@ static int pkcs7signed_run_SingleShotVectors( if (ret > 0) return 0; -#ifndef HAVE_ECC - (void)eccCert; - (void)eccCertSz; - (void)eccPrivKey; - (void)eccPrivKeySz; -#endif -#ifdef NO_RSA + (void)eccClientCertBuf; + (void)eccClientCertBufSz; + (void)eccClientPrivKeyBuf; + (void)eccClientPrivKeyBufSz; + (void)rsaClientCertBuf; (void)rsaClientCertBufSz; (void)rsaClientPrivKeyBuf; @@ -21589,16 +21583,7 @@ static int pkcs7signed_run_SingleShotVectors( (void)rsaCaCertBufSz; (void)rsaCaPrivKeyBuf; (void)rsaCaPrivKeyBufSz; -#endif - (void)rsaServerCertBuf; - (void)rsaServerCertBufSz; - (void)rsaServerPrivKeyBuf; - (void)rsaServerPrivKeyBufSz; - (void)rsaCaCertBuf; - (void)rsaCaCertBufSz; - (void)rsaCaPrivKeyBuf; - (void)rsaCaPrivKeyBufSz; return ret; }