crypt32: Fixed decoded size calculation in CRYPT_AsnDecodeSequence when indefinite length is used.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ced1b9ba60
commit
2a2ecdd564
|
@ -479,6 +479,7 @@ static BOOL CRYPT_AsnDecodeSequence(struct AsnDecodeSequenceItem items[],
|
|||
{
|
||||
dataLen = cbEncoded;
|
||||
indefinite = TRUE;
|
||||
lenBytes += 2;
|
||||
}
|
||||
else if (cbEncoded < dataLen)
|
||||
{
|
||||
|
|
|
@ -3368,18 +3368,76 @@ static const BYTE hash[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd,
|
|||
0xe, 0xf };
|
||||
|
||||
static const BYTE signedBigCert[] = {
|
||||
0x30, 0x81, 0x93, 0x30, 0x7a, 0x02, 0x01, 0x01, 0x30, 0x02, 0x06, 0x00, 0x30,
|
||||
0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a,
|
||||
0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x22, 0x18, 0x0f,
|
||||
0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30,
|
||||
0x30, 0x5a, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30,
|
||||
0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06,
|
||||
0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61,
|
||||
0x6e, 0x67, 0x00, 0x30, 0x07, 0x30, 0x02, 0x06, 0x00, 0x03, 0x01, 0x00, 0xa3,
|
||||
0x16, 0x30, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff,
|
||||
0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01, 0x30, 0x02, 0x06,
|
||||
0x00, 0x03, 0x11, 0x00, 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07,
|
||||
0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 };
|
||||
ASN_SEQUENCE,0x81,147,
|
||||
ASN_SEQUENCE,122,
|
||||
ASN_INTEGER,1, 0x01,
|
||||
ASN_SEQUENCE,2,
|
||||
ASN_OBJECTIDENTIFIER,0,
|
||||
ASN_SEQUENCE,21,
|
||||
0x31,19,
|
||||
ASN_SEQUENCE,17,
|
||||
ASN_OBJECTIDENTIFIER,3, 0x55,0x04,0x03,
|
||||
0x13,10, 0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,
|
||||
ASN_SEQUENCE,34,
|
||||
0x18,15, 0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,
|
||||
0x18,15, 0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,
|
||||
ASN_SEQUENCE,21,
|
||||
0x31,19,
|
||||
ASN_SEQUENCE,17,
|
||||
ASN_OBJECTIDENTIFIER,3, 0x55,0x04,0x03,
|
||||
0x13,10, 0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,
|
||||
ASN_SEQUENCE,7,
|
||||
ASN_SEQUENCE,2,
|
||||
ASN_OBJECTIDENTIFIER,0,
|
||||
ASN_BITS,1, 0x00,
|
||||
0xa3,22,
|
||||
ASN_SEQUENCE,20,
|
||||
ASN_SEQUENCE,18,
|
||||
ASN_OBJECTIDENTIFIER,3, 0x55,0x1d,0x13,
|
||||
0x01,1, 0xff,
|
||||
ASN_OCTETSTRING,8, 0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01,
|
||||
ASN_SEQUENCE,2,
|
||||
ASN_OBJECTIDENTIFIER,0,
|
||||
ASN_BITS,17, 0x00,0x0f,0x0e,0x0d,0x0c,0x0b,0x0a,0x09,0x08,
|
||||
0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00
|
||||
};
|
||||
|
||||
static const BYTE signedBigCertWithIndefiniteSeq[] = {
|
||||
ASN_SEQUENCE,0x81,151,
|
||||
ASN_SEQUENCE,126,
|
||||
ASN_INTEGER,1, 0x01,
|
||||
ASN_SEQUENCE,2,
|
||||
ASN_OBJECTIDENTIFIER,0,
|
||||
ASN_SEQUENCE,21,
|
||||
0x31,19,
|
||||
ASN_SEQUENCE,17,
|
||||
ASN_OBJECTIDENTIFIER,3, 0x55,0x04,0x03,
|
||||
0x13,10, 0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,
|
||||
ASN_SEQUENCE,0x80,
|
||||
0x18,15, 0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,
|
||||
0x18,15, 0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,
|
||||
0,0,
|
||||
ASN_SEQUENCE,21,
|
||||
0x31,19,
|
||||
ASN_SEQUENCE,17,
|
||||
ASN_OBJECTIDENTIFIER,3, 0x55,0x04,0x03,
|
||||
0x13,10, 0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,
|
||||
ASN_SEQUENCE,0x80,
|
||||
ASN_SEQUENCE,2,
|
||||
ASN_OBJECTIDENTIFIER,0,
|
||||
ASN_BITS,1, 0x00,
|
||||
0,0,
|
||||
0xa3,22,
|
||||
ASN_SEQUENCE,20,
|
||||
ASN_SEQUENCE,18,
|
||||
ASN_OBJECTIDENTIFIER,3, 0x55,0x1d,0x13,
|
||||
0x01,1, 0xff,
|
||||
ASN_OCTETSTRING,8, 0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01,
|
||||
ASN_SEQUENCE,2,
|
||||
ASN_OBJECTIDENTIFIER,0,
|
||||
ASN_BITS,17, 0x00,0x0f,0x0e,0x0d,0x0c,0x0b,0x0a,0x09,0x08,
|
||||
0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00
|
||||
};
|
||||
|
||||
static void test_encodeCert(DWORD dwEncoding)
|
||||
{
|
||||
|
@ -3435,6 +3493,29 @@ static void test_decodeCert(DWORD dwEncoding)
|
|||
{
|
||||
CERT_INFO *info = (CERT_INFO *)buf;
|
||||
|
||||
ok(size >= sizeof(CERT_INFO), "Wrong size %d\n", size);
|
||||
ok(info->SerialNumber.cbData == 1,
|
||||
"Expected serial number size 1, got %d\n", info->SerialNumber.cbData);
|
||||
ok(*info->SerialNumber.pbData == *serialNum,
|
||||
"Expected serial number %d, got %d\n", *serialNum,
|
||||
*info->SerialNumber.pbData);
|
||||
ok(info->Issuer.cbData == sizeof(encodedCommonName),
|
||||
"Wrong size %d\n", info->Issuer.cbData);
|
||||
ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData),
|
||||
"Unexpected issuer\n");
|
||||
ok(info->Subject.cbData == sizeof(encodedCommonName),
|
||||
"Wrong size %d\n", info->Subject.cbData);
|
||||
ok(!memcmp(info->Subject.pbData, encodedCommonName,
|
||||
info->Subject.cbData), "Unexpected subject\n");
|
||||
LocalFree(buf);
|
||||
}
|
||||
ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, signedBigCertWithIndefiniteSeq,
|
||||
sizeof(signedBigCertWithIndefiniteSeq), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
|
||||
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
|
||||
if (ret)
|
||||
{
|
||||
CERT_INFO *info = (CERT_INFO *)buf;
|
||||
|
||||
ok(size >= sizeof(CERT_INFO), "Wrong size %d\n", size);
|
||||
ok(info->SerialNumber.cbData == 1,
|
||||
"Expected serial number size 1, got %d\n", info->SerialNumber.cbData);
|
||||
|
|
Loading…
Reference in New Issue