Juan Lang : crypt32: Correct CRL tests, and fix CRL encoding/ decoding accordingly.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Jun 16 08:18:00 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: bc2d4a71b4672d05af0be0af0ad4f632d702ae1b
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=bc2d4a71b4672d05af0be0af0ad4f632d702ae1b

Author: Juan Lang <juan_lang at yahoo.com>
Date:   Thu Jun 15 09:48:12 2006 -0700

crypt32: Correct CRL tests, and fix CRL encoding/decoding accordingly.

---

 dlls/crypt32/decode.c       |    7 ++--
 dlls/crypt32/encode.c       |   11 ++++--
 dlls/crypt32/tests/encode.c |   79 ++++++++++++++++++++-----------------------
 3 files changed, 48 insertions(+), 49 deletions(-)

diff --git a/dlls/crypt32/decode.c b/dlls/crypt32/decode.c
index cd0e644..c40583d 100644
--- a/dlls/crypt32/decode.c
+++ b/dlls/crypt32/decode.c
@@ -957,10 +957,9 @@ static BOOL WINAPI CRYPT_AsnDecodeCRLInf
          { ASN_SEQUENCEOF, offsetof(CRL_INFO, cCRLEntry),
            CRYPT_AsnDecodeCRLEntries, sizeof(struct GenericArray), TRUE, TRUE,
            offsetof(CRL_INFO, rgCRLEntry), 0 },
-         /* Note that the extensions are ignored by MS, so I'll ignore them too
-          */
-         { 0, offsetof(CRL_INFO, cExtension), NULL,
-           sizeof(CERT_EXTENSIONS), TRUE, FALSE, 0 },
+         { ASN_CONTEXT | ASN_CONSTRUCTOR | 0, offsetof(CRL_INFO, cExtension),
+           CRYPT_AsnDecodeCertExtensions, sizeof(CERT_EXTENSIONS), TRUE, TRUE,
+           offsetof(CRL_INFO, rgExtension), 0 },
         };
 
         ret = CRYPT_AsnDecodeSequence(dwCertEncodingType, items,
diff --git a/dlls/crypt32/encode.c b/dlls/crypt32/encode.c
index cd8b997..bc00ecf 100644
--- a/dlls/crypt32/encode.c
+++ b/dlls/crypt32/encode.c
@@ -675,7 +675,8 @@ static BOOL WINAPI CRYPT_AsnEncodeCRLInf
          { &info->ThisUpdate,         CRYPT_AsnEncodeChoiceOfTime, 0 },
          { 0 }
         };
-        DWORD cItem = 4;
+        struct AsnConstructedItem constructed[1] = { { 0 } };
+        DWORD cItem = 4, cConstructed = 0;
 
         if (info->NextUpdate.dwLowDateTime || info->NextUpdate.dwHighDateTime)
         {
@@ -691,8 +692,12 @@ static BOOL WINAPI CRYPT_AsnEncodeCRLInf
         }
         if (info->cExtension)
         {
-            items[cItem].pvStructInfo = &info->cExtension;
-            items[cItem].encodeFunc = CRYPT_AsnEncodeExtensions;
+            constructed[cConstructed].tag = 0;
+            constructed[cConstructed].pvStructInfo = &info->cExtension;
+            constructed[cConstructed].encodeFunc = CRYPT_AsnEncodeExtensions;
+            items[cItem].pvStructInfo = &constructed[cConstructed];
+            items[cItem].encodeFunc = CRYPT_AsnEncodeConstructed;
+            cConstructed++;
             cItem++;
         }
 
diff --git a/dlls/crypt32/tests/encode.c b/dlls/crypt32/tests/encode.c
index f587bbd..42d8c0e 100644
--- a/dlls/crypt32/tests/encode.c
+++ b/dlls/crypt32/tests/encode.c
@@ -2590,23 +2590,27 @@ static const BYTE v1CRLWithIssuerAndEntr
  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 };
-static const BYTE v1CRLWithExt[] = { 0x30, 0x5a, 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, 0x18, 0x0f, 0x31, 0x36,
- 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a,
- 0x30, 0x2c, 0x30, 0x2a, 0x02, 0x01, 0x01, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31,
- 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x14,
- 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30,
- 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01 };
-static const BYTE v2CRLWithExt[] = { 0x30, 0x5a, 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, 0x18,
- 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30,
- 0x30, 0x30, 0x5a, 0x30, 0x29, 0x30, 0x27, 0x02, 0x01, 0x01, 0x18, 0x0f, 0x31,
- 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
- 0x5a, 0x30, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x08, 0x30,
- 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01 };
-
+static const BYTE v1CRLWithEntryExt[] = { 0x30,0x5a,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,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,
+ 0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x2c,0x30,0x2a,0x02,0x01,
+ 0x01,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,
+ 0x30,0x30,0x5a,0x30,0x14,0x30,0x12,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,0xff,
+ 0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };
+static const BYTE v1CRLWithExt[] = { 0x30,0x5c,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,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,0x16,0x30,0x14,0x30,0x12,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,
+ 0xff,0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };
+static const BYTE v2CRLWithExt[] = { 0x30,0x5c,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,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)
 {
@@ -2690,13 +2694,26 @@ static void test_encodeCRLToBeSigned(DWO
     ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     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(!memcmp(buf, v1CRLWithExt, size), "Got unexpected value\n");
         LocalFree(buf);
     }
     /* a v2 CRL with an extension, this time non-critical */
     info.dwVersion = CRL_V2;
-    entry.rgExtension = &nonCriticalExt;
+    info.rgExtension = &nonCriticalExt;
     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());
@@ -2852,10 +2869,7 @@ static void test_decodeCRLToBeSigned(DWO
          "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",
+        ok(info->cExtension == 1, "Expected 1 extensions, got %ld\n",
          info->cExtension);
     }
     ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED,
@@ -2864,27 +2878,8 @@ static void test_decodeCRLToBeSigned(DWO
     if (buf)
     {
         CRL_INFO *info = (CRL_INFO *)buf;
-        CRL_ENTRY *entry;
 
-        ok(size >= sizeof(CRL_INFO), "Wrong size %ld\n", size);
-        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",
+        ok(info->cExtension == 1, "Expected 1 extensions, got %ld\n",
          info->cExtension);
         LocalFree(buf);
     }




More information about the wine-cvs mailing list