forked from wolfSSL/wolfssl
Allow PKCS7_VerifyDecodedData to have an empty set of SignerInfos. Save first certificate.
This commit is contained in:
@ -653,8 +653,9 @@ int PKCS7_VerifySignedData(PKCS7* pkcs7, byte* pkiMsg, word32 pkiMsgSz)
|
|||||||
|
|
||||||
/* Save the inner data as the content. */
|
/* Save the inner data as the content. */
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
content = &pkiMsg[idx];
|
/* Local pointer for calculating hashes later */
|
||||||
contentSz = length;
|
pkcs7->content = content = &pkiMsg[idx];
|
||||||
|
pkcs7->contentSz = contentSz = length;
|
||||||
idx += length;
|
idx += length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -680,6 +681,7 @@ int PKCS7_VerifySignedData(PKCS7* pkcs7, byte* pkiMsg, word32 pkiMsgSz)
|
|||||||
cert = &pkiMsg[idx];
|
cert = &pkiMsg[idx];
|
||||||
certSz += (certIdx - idx);
|
certSz += (certIdx - idx);
|
||||||
}
|
}
|
||||||
|
PKCS7_InitWithCert(pkcs7, cert, certSz);
|
||||||
}
|
}
|
||||||
idx += length;
|
idx += length;
|
||||||
}
|
}
|
||||||
@ -698,6 +700,12 @@ int PKCS7_VerifySignedData(PKCS7* pkcs7, byte* pkiMsg, word32 pkiMsgSz)
|
|||||||
if (GetSet(pkiMsg, &idx, &length, pkiMsgSz) < 0)
|
if (GetSet(pkiMsg, &idx, &length, pkiMsgSz) < 0)
|
||||||
return ASN_PARSE_E;
|
return ASN_PARSE_E;
|
||||||
|
|
||||||
|
if (length > 0) {
|
||||||
|
RsaKey key;
|
||||||
|
word32 scratch = 0;
|
||||||
|
int plainSz = 0;
|
||||||
|
byte digest[MAX_SEQ_SZ+MAX_ALGO_SZ+MAX_OCTET_STR_SZ+SHA_DIGEST_SIZE];
|
||||||
|
|
||||||
/* Get the sequence of the first signerInfo */
|
/* Get the sequence of the first signerInfo */
|
||||||
if (GetSequence(pkiMsg, &idx, &length, pkiMsgSz) < 0)
|
if (GetSequence(pkiMsg, &idx, &length, pkiMsgSz) < 0)
|
||||||
return ASN_PARSE_E;
|
return ASN_PARSE_E;
|
||||||
@ -760,14 +768,7 @@ int PKCS7_VerifySignedData(PKCS7* pkcs7, byte* pkiMsg, word32 pkiMsgSz)
|
|||||||
idx += length;
|
idx += length;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
RsaKey key;
|
|
||||||
word32 scratch = 0;
|
|
||||||
int plainSz = 0;
|
|
||||||
byte digest[MAX_SEQ_SZ+MAX_ALGO_SZ+MAX_OCTET_STR_SZ+SHA_DIGEST_SIZE];
|
|
||||||
|
|
||||||
XMEMSET(digest, 0, sizeof(digest));
|
XMEMSET(digest, 0, sizeof(digest));
|
||||||
PKCS7_InitWithCert(pkcs7, cert, certSz);
|
|
||||||
pkcs7->content = content;
|
pkcs7->content = content;
|
||||||
pkcs7->contentSz = contentSz;
|
pkcs7->contentSz = contentSz;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user