mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 19:24:42 +02:00
add test cases and set content oid with decode encrypted data
This commit is contained in:
@@ -25991,6 +25991,7 @@ static void test_wc_PKCS7_DecodeCompressedData(void)
|
||||
|
||||
/* test decompression */
|
||||
AssertNotNull((pkcs7 = wc_PKCS7_New(heap, devId)));
|
||||
AssertIntEQ(pkcs7->contentOID, 0);
|
||||
|
||||
/* fail case with out buffer too small */
|
||||
AssertIntLT(wc_PKCS7_DecodeCompressedData(pkcs7, out, outSz,
|
||||
@@ -25999,6 +26000,7 @@ static void test_wc_PKCS7_DecodeCompressedData(void)
|
||||
/* success case */
|
||||
AssertIntEQ(wc_PKCS7_DecodeCompressedData(pkcs7, out, outSz,
|
||||
decompressed, decompressedSz), cert_sz);
|
||||
AssertIntEQ(pkcs7->contentOID, DATA);
|
||||
AssertIntEQ(XMEMCMP(decompressed, cert_buf, cert_sz), 0);
|
||||
XFREE(decompressed, heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
decompressed = NULL;
|
||||
|
@@ -12322,6 +12322,10 @@ int wc_PKCS7_DecodeEncryptedData(PKCS7* pkcs7, byte* in, word32 inSz,
|
||||
pkiMsgSz) < 0)
|
||||
ret = ASN_PARSE_E;
|
||||
|
||||
if (ret == 0) {
|
||||
pkcs7->contentOID = contentType;
|
||||
}
|
||||
|
||||
if (ret == 0 && (ret = GetAlgoId(pkiMsg, &idx, &encOID, oidBlkType,
|
||||
pkiMsgSz)) < 0)
|
||||
ret = ASN_PARSE_E;
|
||||
|
@@ -30558,9 +30558,11 @@ static int pkcs7enveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
||||
}
|
||||
|
||||
/* decode envelopedData */
|
||||
pkcs7->contentOID = 0;
|
||||
decodedSz = wc_PKCS7_DecodeEnvelopedData(pkcs7, enveloped, envelopedSz,
|
||||
decoded, PKCS7_BUF_SIZE);
|
||||
if (decodedSz <= 0) {
|
||||
if (pkcs7->contentOID != testVectors[i].contentOID ||
|
||||
decodedSz <= 0) {
|
||||
wc_PKCS7_Free(pkcs7);
|
||||
ERROR_OUT(-12187, out);
|
||||
}
|
||||
@@ -31510,6 +31512,11 @@ static int getFirmwareKey(PKCS7* pkcs7, byte* key, word32 keySz)
|
||||
envPkcs7->contentOID = FIRMWARE_PKG_DATA;
|
||||
ret = wc_PKCS7_DecodeEnvelopedData(envPkcs7, atr, atrSz,
|
||||
key, keySz);
|
||||
if (envPkcs7->contentOID != FIRMWARE_PKG_DATA) {
|
||||
/* the contentOID should have been set to the inner
|
||||
* FIRMWARE_PKG_DATA content */
|
||||
ret = BAD_STATE_E;
|
||||
}
|
||||
}
|
||||
wc_PKCS7_Free(envPkcs7);
|
||||
}
|
||||
@@ -33245,7 +33252,7 @@ static int pkcs7signed_run_SingleShotVectors(
|
||||
pkcs7->contentSz, encryptedTmp,
|
||||
encryptedTmpSz);
|
||||
|
||||
if (encryptedTmpSz < 0) {
|
||||
if (encryptedTmpSz < 0 || pkcs7->contentOID != COMPRESSED_DATA) {
|
||||
XFREE(encryptedTmp, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
wc_PKCS7_Free(pkcs7);
|
||||
|
Reference in New Issue
Block a user