Hans Leidekker : crypt32: Requestor name is optional in OCSP request.

Alexandre Julliard julliard at winehq.org
Thu Mar 10 16:10:16 CST 2022


Module: wine
Branch: master
Commit: 6de79d64fa930cfc2d1497f0519015af5788bb86
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=6de79d64fa930cfc2d1497f0519015af5788bb86

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Thu Mar 10 14:15:48 2022 +0100

crypt32: Requestor name is optional in OCSP request.

Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/crypt32/encode.c       | 21 ++++++++++++---------
 dlls/crypt32/tests/encode.c | 21 +++++++++++++++++++++
 2 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/dlls/crypt32/encode.c b/dlls/crypt32/encode.c
index a506f197be1..3391e61679c 100644
--- a/dlls/crypt32/encode.c
+++ b/dlls/crypt32/encode.c
@@ -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++;
                 }
 
diff --git a/dlls/crypt32/tests/encode.c b/dlls/crypt32/tests/encode.c
index 9d12223c54c..747b4a7d18f 100644
--- a/dlls/crypt32/tests/encode.c
+++ b/dlls/crypt32/tests/encode.c
@@ -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)




More information about the wine-cvs mailing list