Juan Lang : crypt32: Add a couple CRL encoding tests, one that shows a problem.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Jun 2 04:55:58 CDT 2006


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

Author: Juan Lang <juan_lang at yahoo.com>
Date:   Thu Jun  1 20:07:52 2006 -0700

crypt32: Add a couple CRL encoding tests, one that shows a problem.

---

 dlls/crypt32/tests/encode.c |  111 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 110 insertions(+), 1 deletions(-)

diff --git a/dlls/crypt32/tests/encode.c b/dlls/crypt32/tests/encode.c
index 78d9052..3be938a 100644
--- a/dlls/crypt32/tests/encode.c
+++ b/dlls/crypt32/tests/encode.c
@@ -2641,6 +2641,15 @@ static const BYTE v1CRLWithExt[] = { 0x3
  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 void test_encodeCRLToBeSigned(DWORD dwEncoding)
 {
@@ -2719,7 +2728,7 @@ static void test_encodeCRLToBeSigned(DWO
          "Got unexpected value\n");
         LocalFree(buf);
     }
-    /* and finally, an entry with an extension */
+    /* an entry with an extension */
     entry.cExtension = 1;
     entry.rgExtension = &criticalExt;
     ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info,
@@ -2732,8 +2741,57 @@ static void test_encodeCRLToBeSigned(DWO
         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;
+    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(v2CRLWithExt), "Expected size %d, got %ld\n",
+         sizeof(v2CRLWithExt), size);
+        ok(!memcmp(buf, v2CRLWithExt, size), "Got unexpected value\n");
+        LocalFree(buf);
+    }
 }
 
+static const BYTE verisignCRL[] = { 0x30, 0x82, 0x01, 0xb1, 0x30, 0x82, 0x01,
+ 0x1a, 0x02, 0x01, 0x01, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7,
+ 0x0d, 0x01, 0x01, 0x02, 0x05, 0x00, 0x30, 0x61, 0x31, 0x11, 0x30, 0x0f, 0x06,
+ 0x03, 0x55, 0x04, 0x07, 0x13, 0x08, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65,
+ 0x74, 0x31, 0x17, 0x30, 0x15, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0e, 0x56,
+ 0x65, 0x72, 0x69, 0x53, 0x69, 0x67, 0x6e, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e,
+ 0x31, 0x33, 0x30, 0x31, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x2a, 0x56, 0x65,
+ 0x72, 0x69, 0x53, 0x69, 0x67, 0x6e, 0x20, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x72,
+ 0x63, 0x69, 0x61, 0x6c, 0x20, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65,
+ 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x73, 0x20, 0x43,
+ 0x41, 0x17, 0x0d, 0x30, 0x31, 0x30, 0x33, 0x32, 0x34, 0x30, 0x30, 0x30, 0x30,
+ 0x30, 0x30, 0x5a, 0x17, 0x0d, 0x30, 0x34, 0x30, 0x31, 0x30, 0x37, 0x32, 0x33,
+ 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, 0x69, 0x30, 0x21, 0x02, 0x10, 0x1b, 0x51,
+ 0x90, 0xf7, 0x37, 0x24, 0x39, 0x9c, 0x92, 0x54, 0xcd, 0x42, 0x46, 0x37, 0x99,
+ 0x6a, 0x17, 0x0d, 0x30, 0x31, 0x30, 0x31, 0x33, 0x30, 0x30, 0x30, 0x30, 0x31,
+ 0x32, 0x34, 0x5a, 0x30, 0x21, 0x02, 0x10, 0x75, 0x0e, 0x40, 0xff, 0x97, 0xf0,
+ 0x47, 0xed, 0xf5, 0x56, 0xc7, 0x08, 0x4e, 0xb1, 0xab, 0xfd, 0x17, 0x0d, 0x30,
+ 0x31, 0x30, 0x31, 0x33, 0x31, 0x30, 0x30, 0x30, 0x30, 0x34, 0x39, 0x5a, 0x30,
+ 0x21, 0x02, 0x10, 0x77, 0xe6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06, 0x4e, 0xb1, 0xc8, 0x92, 0x0c, 0x97, 0xbe, 0x15, 0x07,
+ 0xab, 0x7a, 0xc9, 0xea, 0x08, 0x67, 0x43, 0x4d, 0x51, 0x63, 0x3b, 0x9c, 0x9c,
+ 0xcd };
+
 static void test_decodeCRLToBeSigned(DWORD dwEncoding)
 {
     static const BYTE *corruptCRLs[] = { v1CRL, v2CRL };
@@ -2803,6 +2861,25 @@ static void test_decodeCRLToBeSigned(DWO
         ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData),
          "Unexpected issuer\n");
     }
+    /* a real CRL from verisign that has extensions */
+    ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED,
+     verisignCRL, sizeof(verisignCRL), CRYPT_DECODE_ALLOC_FLAG,
+     NULL, (BYTE *)&buf, &size);
+    todo_wine ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
+    if (buf)
+    {
+        CRL_INFO *info = (CRL_INFO *)buf;
+        CRL_ENTRY *entry;
+
+        ok(size >= sizeof(CRL_INFO), "Expected size at least %d, got %ld\n",
+         sizeof(CRL_INFO), size);
+        ok(info->cCRLEntry == 3, "Expected 3 CRL entries, got %ld\n",
+         info->cCRLEntry);
+        ok(info->rgCRLEntry != NULL, "Expected a valid CRL entry array\n");
+        entry = info->rgCRLEntry;
+        ok(info->cExtension == 2, "Expected 2 extensions, got %ld\n",
+         info->cExtension);
+    }
     /* and finally, with an extension */
     ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED,
      v1CRLWithExt, sizeof(v1CRLWithExt), CRYPT_DECODE_ALLOC_FLAG,
@@ -2836,6 +2913,38 @@ static void test_decodeCRLToBeSigned(DWO
         ok(info->cExtension == 0, "Expected 0 extensions, got %ld\n",
          info->cExtension);
     }
+    ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED,
+     v2CRLWithExt, sizeof(v2CRLWithExt), CRYPT_DECODE_ALLOC_FLAG,
+     NULL, (BYTE *)&buf, &size);
+    if (buf)
+    {
+        CRL_INFO *info = (CRL_INFO *)buf;
+        CRL_ENTRY *entry;
+
+        ok(size >= sizeof(CRL_INFO), "Expected size at least %d, got %ld\n",
+         sizeof(CRL_INFO), 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),
+         "Expected issuer of %d bytes, got %ld\n", sizeof(encodedCommonName),
+         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);
+        LocalFree(buf);
+    }
 }
 
 static const LPCSTR keyUsages[] = { szOID_PKIX_KP_CODE_SIGNING,




More information about the wine-cvs mailing list