Merge pull request #1952 from cconlon/cmstestfix

Fix for PKCS7 unit test with AES disabled
This commit is contained in:
toddouska
2018-12-05 10:36:52 -08:00
committed by GitHub
2 changed files with 14 additions and 5 deletions

View File

@@ -15781,21 +15781,26 @@ static void test_wc_PKCS7_EncodeDecodeEnvelopedData (void)
AssertIntEQ(wc_PKCS7_DecodeEnvelopedData(pkcs7, output, 0, decoded, AssertIntEQ(wc_PKCS7_DecodeEnvelopedData(pkcs7, output, 0, decoded,
(word32)sizeof(decoded)), BAD_FUNC_ARG); (word32)sizeof(decoded)), BAD_FUNC_ARG);
/* Should get a return of BAD_FUNC_ARG with structure data. Order matters.*/ /* Should get a return of BAD_FUNC_ARG with structure data. Order matters.*/
#if defined(HAVE_ECC) && !defined(NO_AES)
/* only a failure for KARI test cases */
tempWrd32 = pkcs7->singleCertSz; tempWrd32 = pkcs7->singleCertSz;
pkcs7->singleCertSz = 0; pkcs7->singleCertSz = 0;
AssertIntEQ(wc_PKCS7_DecodeEnvelopedData(pkcs7, output, AssertIntEQ(wc_PKCS7_DecodeEnvelopedData(pkcs7, output,
(word32)sizeof(output), decoded, (word32)sizeof(decoded)), BAD_FUNC_ARG); (word32)sizeof(output), decoded, (word32)sizeof(decoded)), BAD_FUNC_ARG);
pkcs7->singleCertSz = tempWrd32; pkcs7->singleCertSz = tempWrd32;
tempWrd32 = pkcs7->privateKeySz;
pkcs7->privateKeySz = 0;
AssertIntEQ(wc_PKCS7_DecodeEnvelopedData(pkcs7, output,
(word32)sizeof(output), decoded, (word32)sizeof(decoded)), BAD_FUNC_ARG);
pkcs7->privateKeySz = tempWrd32;
tmpBytePtr = pkcs7->singleCert; tmpBytePtr = pkcs7->singleCert;
pkcs7->singleCert = NULL; pkcs7->singleCert = NULL;
AssertIntEQ(wc_PKCS7_DecodeEnvelopedData(pkcs7, output, AssertIntEQ(wc_PKCS7_DecodeEnvelopedData(pkcs7, output,
(word32)sizeof(output), decoded, (word32)sizeof(decoded)), BAD_FUNC_ARG); (word32)sizeof(output), decoded, (word32)sizeof(decoded)), BAD_FUNC_ARG);
pkcs7->singleCert = tmpBytePtr; pkcs7->singleCert = tmpBytePtr;
#endif
tempWrd32 = pkcs7->privateKeySz;
pkcs7->privateKeySz = 0;
AssertIntEQ(wc_PKCS7_DecodeEnvelopedData(pkcs7, output,
(word32)sizeof(output), decoded, (word32)sizeof(decoded)), BAD_FUNC_ARG);
pkcs7->privateKeySz = tempWrd32;
tmpBytePtr = pkcs7->privateKey; tmpBytePtr = pkcs7->privateKey;
pkcs7->privateKey = NULL; pkcs7->privateKey = NULL;
AssertIntEQ(wc_PKCS7_DecodeEnvelopedData(pkcs7, output, AssertIntEQ(wc_PKCS7_DecodeEnvelopedData(pkcs7, output,

View File

@@ -6683,6 +6683,10 @@ int wc_PKCS7_AddRecipient_KEKRI(PKCS7* pkcs7, int keyWrapOID, byte* kek,
return encryptedKeySz; return encryptedKeySz;
} }
if (encryptedKeySz > MAX_ENCRYPTED_KEY_SZ) {
return WC_KEY_SIZE_E;
}
encKeyOctetStrSz = SetOctetString(encryptedKeySz, encKeyOctetStr); encKeyOctetStrSz = SetOctetString(encryptedKeySz, encKeyOctetStr);
totalSz += (encKeyOctetStrSz + encryptedKeySz); totalSz += (encKeyOctetStrSz + encryptedKeySz);