crypt32: Correct CRL tests, and fix CRL encoding/decoding accordingly.
This commit is contained in:
parent
62e41ad1fd
commit
bc2d4a71b4
|
@ -957,10 +957,9 @@ static BOOL WINAPI CRYPT_AsnDecodeCRLInfo(DWORD dwCertEncodingType,
|
||||||
{ ASN_SEQUENCEOF, offsetof(CRL_INFO, cCRLEntry),
|
{ ASN_SEQUENCEOF, offsetof(CRL_INFO, cCRLEntry),
|
||||||
CRYPT_AsnDecodeCRLEntries, sizeof(struct GenericArray), TRUE, TRUE,
|
CRYPT_AsnDecodeCRLEntries, sizeof(struct GenericArray), TRUE, TRUE,
|
||||||
offsetof(CRL_INFO, rgCRLEntry), 0 },
|
offsetof(CRL_INFO, rgCRLEntry), 0 },
|
||||||
/* Note that the extensions are ignored by MS, so I'll ignore them too
|
{ ASN_CONTEXT | ASN_CONSTRUCTOR | 0, offsetof(CRL_INFO, cExtension),
|
||||||
*/
|
CRYPT_AsnDecodeCertExtensions, sizeof(CERT_EXTENSIONS), TRUE, TRUE,
|
||||||
{ 0, offsetof(CRL_INFO, cExtension), NULL,
|
offsetof(CRL_INFO, rgExtension), 0 },
|
||||||
sizeof(CERT_EXTENSIONS), TRUE, FALSE, 0 },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ret = CRYPT_AsnDecodeSequence(dwCertEncodingType, items,
|
ret = CRYPT_AsnDecodeSequence(dwCertEncodingType, items,
|
||||||
|
|
|
@ -675,7 +675,8 @@ static BOOL WINAPI CRYPT_AsnEncodeCRLInfo(DWORD dwCertEncodingType,
|
||||||
{ &info->ThisUpdate, CRYPT_AsnEncodeChoiceOfTime, 0 },
|
{ &info->ThisUpdate, CRYPT_AsnEncodeChoiceOfTime, 0 },
|
||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
DWORD cItem = 4;
|
struct AsnConstructedItem constructed[1] = { { 0 } };
|
||||||
|
DWORD cItem = 4, cConstructed = 0;
|
||||||
|
|
||||||
if (info->NextUpdate.dwLowDateTime || info->NextUpdate.dwHighDateTime)
|
if (info->NextUpdate.dwLowDateTime || info->NextUpdate.dwHighDateTime)
|
||||||
{
|
{
|
||||||
|
@ -691,8 +692,12 @@ static BOOL WINAPI CRYPT_AsnEncodeCRLInfo(DWORD dwCertEncodingType,
|
||||||
}
|
}
|
||||||
if (info->cExtension)
|
if (info->cExtension)
|
||||||
{
|
{
|
||||||
items[cItem].pvStructInfo = &info->cExtension;
|
constructed[cConstructed].tag = 0;
|
||||||
items[cItem].encodeFunc = CRYPT_AsnEncodeExtensions;
|
constructed[cConstructed].pvStructInfo = &info->cExtension;
|
||||||
|
constructed[cConstructed].encodeFunc = CRYPT_AsnEncodeExtensions;
|
||||||
|
items[cItem].pvStructInfo = &constructed[cConstructed];
|
||||||
|
items[cItem].encodeFunc = CRYPT_AsnEncodeConstructed;
|
||||||
|
cConstructed++;
|
||||||
cItem++;
|
cItem++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2590,23 +2590,27 @@ static const BYTE v1CRLWithIssuerAndEntry[] = { 0x30, 0x44, 0x30, 0x02, 0x06,
|
||||||
0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30,
|
0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30,
|
||||||
0x30, 0x5a, 0x30, 0x16, 0x30, 0x14, 0x02, 0x01, 0x01, 0x18, 0x0f, 0x31, 0x36,
|
0x30, 0x5a, 0x30, 0x16, 0x30, 0x14, 0x02, 0x01, 0x01, 0x18, 0x0f, 0x31, 0x36,
|
||||||
0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a };
|
0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a };
|
||||||
static const BYTE v1CRLWithExt[] = { 0x30, 0x5a, 0x30, 0x02, 0x06, 0x00, 0x30,
|
static const BYTE v1CRLWithEntryExt[] = { 0x30,0x5a,0x30,0x02,0x06,0x00,0x30,
|
||||||
0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a,
|
0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,
|
||||||
0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x18, 0x0f, 0x31, 0x36,
|
0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,
|
||||||
0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a,
|
0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x2c,0x30,0x2a,0x02,0x01,
|
||||||
0x30, 0x2c, 0x30, 0x2a, 0x02, 0x01, 0x01, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31,
|
0x01,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,
|
||||||
0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x14,
|
0x30,0x30,0x5a,0x30,0x14,0x30,0x12,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,0xff,
|
||||||
0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30,
|
0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };
|
||||||
0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01 };
|
static const BYTE v1CRLWithExt[] = { 0x30,0x5c,0x30,0x02,0x06,0x00,0x30,0x15,
|
||||||
static const BYTE v2CRLWithExt[] = { 0x30, 0x5a, 0x02, 0x01, 0x01, 0x30, 0x02,
|
0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,
|
||||||
0x06, 0x00, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03,
|
0x20,0x4c,0x61,0x6e,0x67,0x00,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,
|
||||||
0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x18,
|
0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x16,0x30,0x14,0x02,0x01,0x01,
|
||||||
0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30,
|
0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,
|
||||||
0x30, 0x30, 0x5a, 0x30, 0x29, 0x30, 0x27, 0x02, 0x01, 0x01, 0x18, 0x0f, 0x31,
|
0x30,0x5a,0xa0,0x16,0x30,0x14,0x30,0x12,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,
|
||||||
0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
|
0xff,0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };
|
||||||
0x5a, 0x30, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x08, 0x30,
|
static const BYTE v2CRLWithExt[] = { 0x30,0x5c,0x02,0x01,0x01,0x30,0x02,0x06,
|
||||||
0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01 };
|
0x00,0x30,0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,
|
||||||
|
0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,0x18,0x0f,0x31,0x36,0x30,0x31,
|
||||||
|
0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x16,0x30,0x14,
|
||||||
|
0x02,0x01,0x01,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,
|
||||||
|
0x30,0x30,0x30,0x30,0x5a,0xa0,0x13,0x30,0x11,0x30,0x0f,0x06,0x03,0x55,0x1d,
|
||||||
|
0x13,0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };
|
||||||
|
|
||||||
static void test_encodeCRLToBeSigned(DWORD dwEncoding)
|
static void test_encodeCRLToBeSigned(DWORD dwEncoding)
|
||||||
{
|
{
|
||||||
|
@ -2689,6 +2693,19 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding)
|
||||||
CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size);
|
CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size);
|
||||||
ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
|
ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
|
||||||
if (buf)
|
if (buf)
|
||||||
|
{
|
||||||
|
ok(size == sizeof(v1CRLWithEntryExt), "Wrong size %ld\n", size);
|
||||||
|
ok(!memcmp(buf, v1CRLWithEntryExt, size), "Got unexpected value\n");
|
||||||
|
LocalFree(buf);
|
||||||
|
}
|
||||||
|
/* a CRL with an extension */
|
||||||
|
entry.cExtension = 0;
|
||||||
|
info.cExtension = 1;
|
||||||
|
info.rgExtension = &criticalExt;
|
||||||
|
ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info,
|
||||||
|
CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size);
|
||||||
|
ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
|
||||||
|
if (buf)
|
||||||
{
|
{
|
||||||
ok(size == sizeof(v1CRLWithExt), "Wrong size %ld\n", size);
|
ok(size == sizeof(v1CRLWithExt), "Wrong size %ld\n", size);
|
||||||
ok(!memcmp(buf, v1CRLWithExt, size), "Got unexpected value\n");
|
ok(!memcmp(buf, v1CRLWithExt, size), "Got unexpected value\n");
|
||||||
|
@ -2696,7 +2713,7 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding)
|
||||||
}
|
}
|
||||||
/* a v2 CRL with an extension, this time non-critical */
|
/* a v2 CRL with an extension, this time non-critical */
|
||||||
info.dwVersion = CRL_V2;
|
info.dwVersion = CRL_V2;
|
||||||
entry.rgExtension = &nonCriticalExt;
|
info.rgExtension = &nonCriticalExt;
|
||||||
ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info,
|
ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info,
|
||||||
CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size);
|
CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size);
|
||||||
ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
|
ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
|
||||||
|
@ -2852,10 +2869,7 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding)
|
||||||
"Wrong issuer size %ld\n", info->Issuer.cbData);
|
"Wrong issuer size %ld\n", info->Issuer.cbData);
|
||||||
ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData),
|
ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData),
|
||||||
"Unexpected issuer\n");
|
"Unexpected issuer\n");
|
||||||
/* Oddly, the extensions don't seem to be decoded. Is this just an MS
|
ok(info->cExtension == 1, "Expected 1 extensions, got %ld\n",
|
||||||
* bug, or am I missing something?
|
|
||||||
*/
|
|
||||||
ok(info->cExtension == 0, "Expected 0 extensions, got %ld\n",
|
|
||||||
info->cExtension);
|
info->cExtension);
|
||||||
}
|
}
|
||||||
ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED,
|
ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED,
|
||||||
|
@ -2864,27 +2878,8 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding)
|
||||||
if (buf)
|
if (buf)
|
||||||
{
|
{
|
||||||
CRL_INFO *info = (CRL_INFO *)buf;
|
CRL_INFO *info = (CRL_INFO *)buf;
|
||||||
CRL_ENTRY *entry;
|
|
||||||
|
|
||||||
ok(size >= sizeof(CRL_INFO), "Wrong size %ld\n", size);
|
ok(info->cExtension == 1, "Expected 1 extensions, got %ld\n",
|
||||||
ok(info->cCRLEntry == 1, "Expected 1 CRL entries, got %ld\n",
|
|
||||||
info->cCRLEntry);
|
|
||||||
ok(info->rgCRLEntry != NULL, "Expected a valid CRL entry array\n");
|
|
||||||
entry = info->rgCRLEntry;
|
|
||||||
ok(entry->SerialNumber.cbData == 1,
|
|
||||||
"Expected serial number size 1, got %ld\n",
|
|
||||||
entry->SerialNumber.cbData);
|
|
||||||
ok(*entry->SerialNumber.pbData == *serialNum,
|
|
||||||
"Expected serial number %d, got %d\n", *serialNum,
|
|
||||||
*entry->SerialNumber.pbData);
|
|
||||||
ok(info->Issuer.cbData == sizeof(encodedCommonName),
|
|
||||||
"Wrong issuer size %ld\n", info->Issuer.cbData);
|
|
||||||
ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData),
|
|
||||||
"Unexpected issuer\n");
|
|
||||||
/* Oddly, the extensions don't seem to be decoded. Is this just an MS
|
|
||||||
* bug, or am I missing something?
|
|
||||||
*/
|
|
||||||
ok(info->cExtension == 0, "Expected 0 extensions, got %ld\n",
|
|
||||||
info->cExtension);
|
info->cExtension);
|
||||||
LocalFree(buf);
|
LocalFree(buf);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue