crypt32(6/6): Implement decoding OID and directory name alt name entries

Juan Lang juan.lang at gmail.com
Thu Aug 2 11:54:39 CDT 2007


--Juan
-------------- next part --------------
From 5e1670bc48210e0088e3cf6515d07284bb38431b Mon Sep 17 00:00:00 2001
From: Juan Lang <juanlang at juan.corp.google.com>
Date: Thu, 2 Aug 2007 09:49:40 -0700
Subject: [PATCH] Implement decoding OID and directory name alt name entries
---
 dlls/crypt32/decode.c       |   23 +++++++++++++++++++++--
 dlls/crypt32/tests/encode.c |    2 --
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/dlls/crypt32/decode.c b/dlls/crypt32/decode.c
index d85f012..5497d1d 100644
--- a/dlls/crypt32/decode.c
+++ b/dlls/crypt32/decode.c
@@ -2143,13 +2143,22 @@ static BOOL WINAPI CRYPT_AsnDecodeAltNam
         case 6: /* uniformResourceIdentifier */
             bytesNeeded += (dataLen + 1) * sizeof(WCHAR);
             break;
+        case 4: /* directoryName */
         case 7: /* iPAddress */
             bytesNeeded += dataLen;
             break;
         case 8: /* registeredID */
-            /* FIXME: decode as OID */
+            ret = CRYPT_AsnDecodeOidIgnoreTag(dwCertEncodingType, NULL,
+             pbEncoded, cbEncoded, 0, NULL, NULL, &dataLen);
+            if (ret)
+            {
+                /* FIXME: ugly, shouldn't need to know internals of OID decode
+                 * function to use it.
+                 */
+                bytesNeeded += dataLen - sizeof(LPSTR);
+            }
+            break;
         case 0: /* otherName */
-        case 4: /* directoryName */
             FIXME("%d: stub\n", pbEncoded[0] & ASN_TYPE_MASK);
             SetLastError(CRYPT_E_ASN1_BADTAG);
             ret = FALSE;
@@ -2196,6 +2205,11 @@ static BOOL WINAPI CRYPT_AsnDecodeAltNam
                      debugstr_w(entry->u.pwszURL));
                     break;
                 }
+                case 4: /* directoryName */
+                    entry->dwAltNameChoice = CERT_ALT_NAME_DIRECTORY_NAME;
+                    /* The data are memory-equivalent with the IPAddress case,
+                     * fall-through
+                     */
                 case 7: /* iPAddress */
                     /* The next data pointer is in the pwszURL spot, that is,
                      * the first 4 bytes.  Need to move it to the next spot.
@@ -2205,6 +2219,11 @@ static BOOL WINAPI CRYPT_AsnDecodeAltNam
                     memcpy(entry->u.IPAddress.pbData, pbEncoded + 1 + lenBytes,
                      dataLen);
                     break;
+                case 8: /* registeredID */
+                    ret = CRYPT_AsnDecodeOidIgnoreTag(dwCertEncodingType, NULL,
+                     pbEncoded, cbEncoded, 0, NULL, &entry->u.pszRegisteredID,
+                     &dataLen);
+                    break;
                 }
             }
         }
diff --git a/dlls/crypt32/tests/encode.c b/dlls/crypt32/tests/encode.c
index 92dca63..75dd321 100644
--- a/dlls/crypt32/tests/encode.c
+++ b/dlls/crypt32/tests/encode.c
@@ -1522,7 +1522,6 @@ static void test_decodeAltName(DWORD dwE
     ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedOidName,
      sizeof(encodedOidName), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf,
      &bufSize);
-    todo_wine
     ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
     if (buf)
     {
@@ -1540,7 +1539,6 @@ static void test_decodeAltName(DWORD dwE
     ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME,
      encodedDirectoryName, sizeof(encodedDirectoryName),
      CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize);
-    todo_wine
     ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
     if (buf)
     {
-- 
1.4.1


More information about the wine-patches mailing list