From b3506c836ca70407535fe6821f496612c5bf2f85 Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Wed, 24 Oct 2018 14:34:08 -0600 Subject: [PATCH] remove content type restriction and fix build with compkey --- wolfcrypt/src/pkcs7.c | 11 ++++++++++- wolfcrypt/test/test.c | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/wolfcrypt/src/pkcs7.c b/wolfcrypt/src/pkcs7.c index 5945ce9fe..f951eb2d3 100644 --- a/wolfcrypt/src/pkcs7.c +++ b/wolfcrypt/src/pkcs7.c @@ -5754,7 +5754,6 @@ int wc_PKCS7_AddRecipient_ORI(PKCS7* pkcs7, CallbackOriEncrypt oriEncryptCb, return idx; } - #ifndef NO_PWDBASED @@ -7511,6 +7510,7 @@ static int wc_PKCS7_DecryptOri(PKCS7* pkcs7, byte* in, word32 inSz, return ret; } +#ifndef NO_PWDBASED /* decode ASN.1 PasswordRecipientInfo (pwri), return 0 on success, * < 0 on error */ @@ -7718,6 +7718,7 @@ static int wc_PKCS7_DecryptPwri(PKCS7* pkcs7, byte* in, word32 inSz, return ret; } +#endif /* NO_PWDBASED */ /* decode ASN.1 KEKRecipientInfo (kekri), return 0 on success, * < 0 on error */ @@ -8062,8 +8063,12 @@ static int wc_PKCS7_DecryptRecipientInfos(PKCS7* pkcs7, byte* in, break; case WC_PKCS7_DECRYPT_PWRI: + #ifndef NO_PWDBASED ret = wc_PKCS7_DecryptPwri(pkcs7, in, inSz, idx, decryptedKey, decryptedKeySz, recipFound); + #else + return NOT_COMPILED_IN; + #endif break; case WC_PKCS7_DECRYPT_ORI: @@ -8174,6 +8179,7 @@ static int wc_PKCS7_DecryptRecipientInfos(PKCS7* pkcs7, byte* in, /* pwri is IMPLICIT[3] */ } else if (pkiMsg[*idx] == (ASN_CONSTRUCTED | ASN_CONTEXT_SPECIFIC | 3)) { + #ifndef NO_PWDBASED (*idx)++; if (GetLength(pkiMsg, idx, &version, pkiMsgSz) < 0) @@ -8199,6 +8205,9 @@ static int wc_PKCS7_DecryptRecipientInfos(PKCS7* pkcs7, byte* in, recipFound); if (ret != 0) return ret; + #else + return NOT_COMPILED_IN; + #endif /* ori is IMPLICIT[4] */ } else if (pkiMsg[*idx] == (ASN_CONSTRUCTED | diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index cad0d9ed1..b2657bf72 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -19263,6 +19263,7 @@ static int pkcs7enveloped_run_vectors(byte* rsaCert, word32 rsaCertSz, } } else if (testVectors[i].password != NULL) { + #ifndef NO_PWDBASED /* PWRI recipient type */ ret = wc_PKCS7_Init(pkcs7, pkcs7->heap, pkcs7->devId); @@ -19297,6 +19298,7 @@ static int pkcs7enveloped_run_vectors(byte* rsaCert, word32 rsaCertSz, wc_PKCS7_Free(pkcs7); return -9317; } + #endif /* NO_PWDBASED */ } else if (testVectors[i].isOri == 1) { /* ORI recipient type */ @@ -19880,6 +19882,7 @@ static int pkcs7authenveloped_run_vectors(byte* rsaCert, word32 rsaCertSz, } } else if (testVectors[i].password != NULL) { + #ifndef NO_PWDBASED /* PWRI recipient type */ ret = wc_PKCS7_Init(pkcs7, pkcs7->heap, pkcs7->devId); @@ -19919,6 +19922,7 @@ static int pkcs7authenveloped_run_vectors(byte* rsaCert, word32 rsaCertSz, return -9378; } + #endif /* NO_PWDBASED */ } else if (testVectors[i].isOri == 1) { /* ORI recipient type */