crypt32: Requestor name is optional in OCSP request.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2022-03-10 14:15:48 +01:00 committed by Alexandre Julliard
parent 7de22a7438
commit 6de79d64fa
2 changed files with 33 additions and 9 deletions

View File

@ -4632,18 +4632,21 @@ static BOOL WINAPI CRYPT_AsnEncodeOCSPRequest(DWORD dwCertEncodingType,
{
struct AsnConstructedItem name;
struct AsnEncodeSequenceItem items[2];
DWORD count = 1;
name.tag = 1;
name.pvStructInfo = info->pRequestorName;
name.encodeFunc = CRYPT_AsnEncodeAltNameEntry;
items[0].pvStructInfo = &name;
items[0].encodeFunc = CRYPT_AsnEncodeConstructed;
DWORD count = 0;
if (info->pRequestorName)
{
name.tag = 1;
name.pvStructInfo = info->pRequestorName;
name.encodeFunc = CRYPT_AsnEncodeAltNameEntry;
items[count].pvStructInfo = &name;
items[count].encodeFunc = CRYPT_AsnEncodeConstructed;
count++;
}
if (info->cRequestEntry)
{
items[1].pvStructInfo = &info->cRequestEntry;
items[1].encodeFunc = CRYPT_AsnEncodeOCSPRequestEntries;
items[count].pvStructInfo = &info->cRequestEntry;
items[count].encodeFunc = CRYPT_AsnEncodeOCSPRequestEntries;
count++;
}

View File

@ -8656,6 +8656,17 @@ static void test_encodeOCSPRequestInfo(DWORD dwEncoding)
0xd8, 0x04, 0x14, 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f,
0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9, 0xf4, 0x02, 0x10, 0xb1, 0xc1, 0x87, 0x54, 0x54, 0xac, 0x1e,
0x55, 0x40, 0xfb, 0xef, 0xd9, 0x6d, 0x8f, 0x49, 0x08};
static const BYTE expected3[] =
{0x30, 0x81, 0x9d, 0x30, 0x81, 0x9a, 0x30, 0x4b, 0x30, 0x49, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e,
0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, 0xe4, 0xe3, 0x95, 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3,
0x1f, 0xf0, 0x98, 0x0c, 0x0b, 0x4e, 0xc0, 0x09, 0x8a, 0xab, 0xd8, 0x04, 0x14, 0xb7, 0x6b, 0xa2,
0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9,
0xf4, 0x02, 0x10, 0xb1, 0xc1, 0x87, 0x54, 0x54, 0xac, 0x1e, 0x55, 0x40, 0xfb, 0xef, 0xd9, 0x6d,
0x8f, 0x49, 0x08, 0x30, 0x4b, 0x30, 0x49, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a,
0x05, 0x00, 0x04, 0x14, 0xe4, 0xe3, 0x95, 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3, 0x1f, 0xf0, 0x98,
0x0c, 0x0b, 0x4e, 0xc0, 0x09, 0x8a, 0xab, 0xd8, 0x04, 0x14, 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa,
0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9, 0xf4, 0x02, 0x10,
0xb1, 0xc1, 0x87, 0x54, 0x54, 0xac, 0x1e, 0x55, 0x40, 0xfb, 0xef, 0xd9, 0x6d, 0x8f, 0x49, 0x08};
static const BYTE issuer_name[] =
{0xe4, 0xe3 ,0x95, 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3, 0x1f, 0xf0, 0x98, 0x0c, 0x0b, 0x4e, 0xc0,
0x09, 0x8a, 0xab, 0xd8};
@ -8715,6 +8726,16 @@ static void test_encodeOCSPRequestInfo(DWORD dwEncoding)
ok(size == sizeof(expected2), "got %lu\n", size);
ok(!memcmp(buf, expected2, sizeof(expected2)), "unexpected value\n");
LocalFree(buf);
/* requestor name not set */
info.pRequestorName = NULL;
size = 0;
SetLastError(0xdeadbeef);
ret = pCryptEncodeObjectEx(dwEncoding, OCSP_REQUEST, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "got %08lx\n", GetLastError());
ok(size == sizeof(expected3), "got %lu\n", size);
ok(!memcmp(buf, expected3, sizeof(expected3)), "unexpected value\n");
LocalFree(buf);
}
START_TEST(encode)