2 * Copyright 2006 Juan Lang for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/debug.h"
25 #include "wine/unicode.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(crypt);
29 DWORD WINAPI CertRDNValueToStrA(DWORD dwValueType, PCERT_RDN_VALUE_BLOB pValue,
34 TRACE("(%ld, %p, %p, %ld)\n", dwValueType, pValue, psz, csz);
38 case CERT_RDN_ANY_TYPE:
40 case CERT_RDN_PRINTABLE_STRING:
41 case CERT_RDN_IA5_STRING:
46 DWORD chars = min(pValue->cbData, csz - 1);
50 memcpy(psz, pValue->pbData, chars);
57 FIXME("string type %ld unimplemented\n", dwValueType);
67 TRACE("returning %ld (%s)\n", ret, debugstr_a(psz));
71 DWORD WINAPI CertRDNValueToStrW(DWORD dwValueType, PCERT_RDN_VALUE_BLOB pValue,
72 LPWSTR psz, DWORD csz)
76 TRACE("(%ld, %p, %p, %ld)\n", dwValueType, pValue, psz, csz);
80 case CERT_RDN_ANY_TYPE:
82 case CERT_RDN_PRINTABLE_STRING:
83 case CERT_RDN_IA5_STRING:
88 DWORD chars = min(pValue->cbData, csz - 1);
94 for (i = 0; i < chars; i++)
95 psz[i] = pValue->pbData[i];
102 FIXME("string type %ld unimplemented\n", dwValueType);
112 TRACE("returning %ld (%s)\n", ret, debugstr_w(psz));
116 /* Adds the prefix prefix to the string pointed to by psz, followed by the
117 * character '='. Copies no more than csz characters. Returns the number of
118 * characters copied. If psz is NULL, returns the number of characters that
121 static DWORD CRYPT_AddPrefixA(LPCSTR prefix, LPSTR psz, DWORD csz)
125 TRACE("(%s, %p, %ld)\n", debugstr_a(prefix), psz, csz);
129 chars = min(lstrlenA(prefix), csz);
130 memcpy(psz, prefix, chars);
132 *(psz + chars) = '=';
137 chars = lstrlenA(prefix) + 1;
141 DWORD WINAPI CertNameToStrA(DWORD dwCertEncodingType, PCERT_NAME_BLOB pName,
142 DWORD dwStrType, LPSTR psz, DWORD csz)
144 static const DWORD unsupportedFlags = CERT_NAME_STR_NO_QUOTING_FLAG |
145 CERT_NAME_STR_REVERSE_FLAG | CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG;
146 static const char commaSep[] = ", ";
147 static const char semiSep[] = "; ";
148 static const char crlfSep[] = "\r\n";
149 static const char plusSep[] = " + ";
150 static const char spaceSep[] = " ";
151 DWORD ret = 0, bytes = 0;
153 CERT_NAME_INFO *info;
155 TRACE("(%ld, %p, %08lx, %p, %ld)\n", dwCertEncodingType, pName, dwStrType,
157 if (dwStrType & unsupportedFlags)
158 FIXME("unsupported flags: %08lx\n", dwStrType & unsupportedFlags);
160 bRet = CryptDecodeObjectEx(dwCertEncodingType, X509_NAME, pName->pbData,
161 pName->cbData, CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &bytes);
164 DWORD i, j, sepLen, rdnSepLen;
167 if (dwStrType & CERT_NAME_STR_SEMICOLON_FLAG)
169 else if (dwStrType & CERT_NAME_STR_CRLF_FLAG)
173 sepLen = strlen(sep);
174 if (dwStrType & CERT_NAME_STR_NO_PLUS_FLAG)
178 rdnSepLen = strlen(rdnSep);
179 for (i = 0; (!psz || ret < csz) && i < info->cRDN; i++)
181 for (j = 0; (!psz || ret < csz) && j < info->rgRDN[i].cRDNAttr; j++)
184 char prefixBuf[10]; /* big enough for GivenName */
185 LPCSTR prefix = NULL;
187 if ((dwStrType & 0x000000ff) == CERT_OID_NAME_STR)
188 prefix = info->rgRDN[i].rgRDNAttr[j].pszObjId;
189 else if ((dwStrType & 0x000000ff) == CERT_X500_NAME_STR)
191 PCCRYPT_OID_INFO oidInfo = CryptFindOIDInfo(
192 CRYPT_OID_INFO_OID_KEY,
193 info->rgRDN[i].rgRDNAttr[j].pszObjId,
194 CRYPT_RDN_ATTR_OID_GROUP_ID);
198 WideCharToMultiByte(CP_ACP, 0, oidInfo->pwszName, -1,
199 prefixBuf, sizeof(prefixBuf), NULL, NULL);
203 prefix = info->rgRDN[i].rgRDNAttr[j].pszObjId;
207 /* - 1 is needed to account for the NULL terminator. */
208 chars = CRYPT_AddPrefixA(prefix,
209 psz ? psz + ret : NULL, psz ? csz - ret - 1 : 0);
213 /* FIXME: handle quoting */
214 chars = CertRDNValueToStrA(
215 info->rgRDN[i].rgRDNAttr[j].dwValueType,
216 &info->rgRDN[i].rgRDNAttr[j].Value, psz ? psz + ret : NULL,
217 psz ? csz - ret : 0);
220 if (j < info->rgRDN[i].cRDNAttr - 1)
222 if (psz && ret < csz - rdnSepLen - 1)
223 memcpy(psz + ret, rdnSep, rdnSepLen);
227 if (i < info->cRDN - 1)
229 if (psz && ret < csz - sepLen - 1)
230 memcpy(psz + ret, sep, sepLen);
244 TRACE("Returning %s\n", debugstr_a(psz));
248 /* Adds the prefix prefix to the wide-character string pointed to by psz,
249 * followed by the character '='. Copies no more than csz characters. Returns
250 * the number of characters copied. If psz is NULL, returns the number of
251 * characters that would be copied.
252 * Assumes the characters in prefix are ASCII (not multibyte characters.)
254 static DWORD CRYPT_AddPrefixAToW(LPCSTR prefix, LPWSTR psz, DWORD csz)
258 TRACE("(%s, %p, %ld)\n", debugstr_a(prefix), psz, csz);
264 chars = min(lstrlenA(prefix), csz);
265 for (i = 0; i < chars; i++)
266 *(psz + i) = prefix[i];
268 *(psz + chars) = '=';
273 chars = lstrlenA(prefix) + 1;
277 /* Adds the prefix prefix to the string pointed to by psz, followed by the
278 * character '='. Copies no more than csz characters. Returns the number of
279 * characters copied. If psz is NULL, returns the number of characters that
282 static DWORD CRYPT_AddPrefixW(LPCWSTR prefix, LPWSTR psz, DWORD csz)
286 TRACE("(%s, %p, %ld)\n", debugstr_w(prefix), psz, csz);
290 chars = min(lstrlenW(prefix), csz);
291 memcpy(psz, prefix, chars * sizeof(WCHAR));
293 *(psz + chars) = '=';
298 chars = lstrlenW(prefix) + 1;
302 DWORD WINAPI CertNameToStrW(DWORD dwCertEncodingType, PCERT_NAME_BLOB pName,
303 DWORD dwStrType, LPWSTR psz, DWORD csz)
305 static const DWORD unsupportedFlags = CERT_NAME_STR_NO_QUOTING_FLAG |
306 CERT_NAME_STR_REVERSE_FLAG | CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG;
307 static const WCHAR commaSep[] = { ',',' ',0 };
308 static const WCHAR semiSep[] = { ';',' ',0 };
309 static const WCHAR crlfSep[] = { '\r','\n',0 };
310 static const WCHAR plusSep[] = { ' ','+',' ',0 };
311 static const WCHAR spaceSep[] = { ' ',0 };
312 DWORD ret = 0, bytes = 0;
314 CERT_NAME_INFO *info;
316 TRACE("(%ld, %p, %08lx, %p, %ld)\n", dwCertEncodingType, pName, dwStrType,
318 if (dwStrType & unsupportedFlags)
319 FIXME("unsupported flags: %08lx\n", dwStrType & unsupportedFlags);
321 bRet = CryptDecodeObjectEx(dwCertEncodingType, X509_NAME, pName->pbData,
322 pName->cbData, CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &bytes);
325 DWORD i, j, sepLen, rdnSepLen;
328 if (dwStrType & CERT_NAME_STR_SEMICOLON_FLAG)
330 else if (dwStrType & CERT_NAME_STR_CRLF_FLAG)
334 sepLen = lstrlenW(sep);
335 if (dwStrType & CERT_NAME_STR_NO_PLUS_FLAG)
339 rdnSepLen = lstrlenW(rdnSep);
340 for (i = 0; (!psz || ret < csz) && i < info->cRDN; i++)
342 for (j = 0; (!psz || ret < csz) && j < info->rgRDN[i].cRDNAttr; j++)
345 LPCSTR prefixA = NULL;
346 LPCWSTR prefixW = NULL;
348 if ((dwStrType & 0x000000ff) == CERT_OID_NAME_STR)
349 prefixA = info->rgRDN[i].rgRDNAttr[j].pszObjId;
350 else if ((dwStrType & 0x000000ff) == CERT_X500_NAME_STR)
352 PCCRYPT_OID_INFO oidInfo = CryptFindOIDInfo(
353 CRYPT_OID_INFO_OID_KEY,
354 info->rgRDN[i].rgRDNAttr[j].pszObjId,
355 CRYPT_RDN_ATTR_OID_GROUP_ID);
358 prefixW = oidInfo->pwszName;
360 prefixA = info->rgRDN[i].rgRDNAttr[j].pszObjId;
364 /* - 1 is needed to account for the NULL terminator. */
365 chars = CRYPT_AddPrefixW(prefixW,
366 psz ? psz + ret : NULL, psz ? csz - ret - 1 : 0);
372 /* - 1 is needed to account for the NULL terminator. */
373 chars = CRYPT_AddPrefixAToW(prefixA,
374 psz ? psz + ret : NULL, psz ? csz - ret - 1 : 0);
378 /* FIXME: handle quoting */
379 chars = CertRDNValueToStrW(
380 info->rgRDN[i].rgRDNAttr[j].dwValueType,
381 &info->rgRDN[i].rgRDNAttr[j].Value, psz ? psz + ret : NULL,
382 psz ? csz - ret : 0);
385 if (j < info->rgRDN[i].cRDNAttr - 1)
387 if (psz && ret < csz - rdnSepLen - 1)
388 memcpy(psz + ret, rdnSep, rdnSepLen * sizeof(WCHAR));
392 if (i < info->cRDN - 1)
394 if (psz && ret < csz - sepLen - 1)
395 memcpy(psz + ret, sep, sepLen * sizeof(WCHAR));
409 TRACE("Returning %s\n", debugstr_w(psz));
413 BOOL WINAPI CertStrToNameA(DWORD dwCertEncodingType, LPCSTR pszX500,
414 DWORD dwStrType, void *pvReserved, BYTE *pbEncoded, DWORD *pcbEncoded,
417 LPWSTR x500, errorStr;
421 TRACE("(%08lx, %s, %08lx, %p, %p, %p, %p)\n", dwCertEncodingType,
422 debugstr_a(pszX500), dwStrType, pvReserved, pbEncoded, pcbEncoded,
425 len = MultiByteToWideChar(CP_ACP, 0, pszX500, -1, NULL, 0);
426 x500 = CryptMemAlloc(len * sizeof(WCHAR));
429 MultiByteToWideChar(CP_ACP, 0, pszX500, -1, x500, len);
430 ret = CertStrToNameW(dwCertEncodingType, x500, dwStrType, pvReserved,
431 pbEncoded, pcbEncoded, ppszError ? (LPCWSTR *)&errorStr : NULL);
436 *ppszError = pszX500;
437 for (i = 0; i < errorStr - x500; i++)
438 CharNextA(*ppszError);
449 WCHAR buf[10]; /* big enough for L"GivenName" */
450 LPWSTR keyName; /* usually = buf, but may be allocated */
454 static void CRYPT_InitializeKeynameKeeper(struct KeynameKeeper *keeper)
456 keeper->keyName = keeper->buf;
457 keeper->keyLen = sizeof(keeper->buf) / sizeof(keeper->buf[0]);
460 static void CRYPT_FreeKeynameKeeper(struct KeynameKeeper *keeper)
462 if (keeper->keyName != keeper->buf)
463 CryptMemFree(keeper->keyName);
472 static void CRYPT_KeynameKeeperFromTokenW(struct KeynameKeeper *keeper,
473 struct X500TokenW *key)
475 DWORD len = key->end - key->start;
477 if (len > keeper->keyLen)
479 if (keeper->keyName == keeper->buf)
480 keeper->keyName = CryptMemAlloc(len * sizeof(WCHAR));
482 keeper->keyName = CryptMemRealloc(keeper->keyName,
483 len * sizeof(WCHAR));
484 keeper->keyLen = len;
486 memcpy(keeper->keyName, key->start, (key->end - key->start) *
488 keeper->keyName[len] = '\0';
489 TRACE("Keyname is %s\n", debugstr_w(keeper->keyName));
492 static DWORD CRYPT_GetNextKeyW(LPCWSTR str, struct X500TokenW *token,
495 DWORD ret = ERROR_SUCCESS;
497 while (*str && isspaceW(*str))
502 while (*str && *str != '=' && !isspaceW(*str))
504 if (*str && (*str == '=' || isspaceW(*str)))
508 TRACE("missing equals char at %s\n", debugstr_w(token->start));
510 *ppszError = token->start;
511 ret = CRYPT_E_INVALID_X500_STRING;
519 /* Assumes separators are characters in the 0-255 range */
520 static DWORD CRYPT_GetNextValueW(LPCWSTR str, DWORD dwFlags, LPCWSTR separators,
521 struct X500TokenW *token, LPCWSTR *ppszError)
523 DWORD ret = ERROR_SUCCESS;
525 TRACE("(%s, %s, %p, %p)\n", debugstr_w(str), debugstr_w(separators), token,
528 while (*str && isspaceW(*str))
533 if (!(dwFlags & CERT_NAME_STR_NO_QUOTING_FLAG) && *str == '"')
537 while (!token->end && !ret)
539 while (*str && *str != '"')
543 if (*(str + 1) != '"')
544 token->end = str + 1;
550 TRACE("unterminated quote at %s\n", debugstr_w(str));
553 ret = CRYPT_E_INVALID_X500_STRING;
559 WCHAR map[256] = { 0 };
562 map[*separators++] = 1;
563 while (*str && (*str >= 0xff || !map[*(unsigned short *)str]))
570 TRACE("missing value at %s\n", debugstr_w(str));
573 ret = CRYPT_E_INVALID_X500_STRING;
578 /* Encodes the string represented by value as the string type type into the
579 * CERT_NAME_BLOB output. If there is an error and ppszError is not NULL,
580 * *ppszError is set to the first failing character. If there is no error,
581 * output's pbData must be freed with LocalFree.
583 static BOOL CRYPT_EncodeValueWithType(DWORD dwCertEncodingType,
584 struct X500TokenW *value, PCERT_NAME_BLOB output, DWORD type,
587 CERT_NAME_VALUE nameValue = { type, { 0, NULL } };
590 nameValue.Value.pbData = CryptMemAlloc((value->end - value->start) *
592 if (nameValue.Value.pbData)
595 LPWSTR ptr = (LPWSTR)nameValue.Value.pbData;
597 for (i = 0; i < value->end - value->start; i++)
599 *ptr++ = value->start[i];
600 if (value->start[i] == '"')
603 nameValue.Value.cbData = (LPBYTE)ptr - nameValue.Value.pbData;
604 ret = CryptEncodeObjectEx(dwCertEncodingType, X509_UNICODE_NAME_VALUE,
605 &nameValue, CRYPT_ENCODE_ALLOC_FLAG, NULL, &output->pbData,
607 if (!ret && ppszError)
609 if (type == CERT_RDN_NUMERIC_STRING &&
610 GetLastError() == CRYPT_E_INVALID_NUMERIC_STRING)
611 *ppszError = value->start + output->cbData;
612 else if (type == CERT_RDN_PRINTABLE_STRING &&
613 GetLastError() == CRYPT_E_INVALID_PRINTABLE_STRING)
614 *ppszError = value->start + output->cbData;
615 else if (type == CERT_RDN_IA5_STRING &&
616 GetLastError() == CRYPT_E_INVALID_IA5_STRING)
617 *ppszError = value->start + output->cbData;
619 CryptMemFree(nameValue.Value.pbData);
624 static BOOL CRYPT_EncodeValue(DWORD dwCertEncodingType,
625 struct X500TokenW *value, PCERT_NAME_BLOB output, const DWORD *types,
632 for (i = 0; !ret && types[i]; i++)
633 ret = CRYPT_EncodeValueWithType(dwCertEncodingType, value, output,
634 types[i], ppszError);
638 static BOOL CRYPT_ValueToRDN(DWORD dwCertEncodingType, PCERT_NAME_INFO info,
639 PCCRYPT_OID_INFO keyOID, struct X500TokenW *value, LPCWSTR *ppszError)
643 TRACE("OID %s, value %s\n", debugstr_a(keyOID->pszOID),
644 debugstr_wn(value->start, value->end - value->start));
647 info->rgRDN = CryptMemAlloc(sizeof(CERT_RDN));
649 info->rgRDN = CryptMemRealloc(info->rgRDN,
650 (info->cRDN + 1) * sizeof(CERT_RDN));
653 /* FIXME: support multiple RDN attrs */
654 info->rgRDN[info->cRDN].rgRDNAttr =
655 CryptMemAlloc(sizeof(CERT_RDN_ATTR));
656 if (info->rgRDN[info->cRDN].rgRDNAttr)
658 static const DWORD defaultTypes[] = { CERT_RDN_PRINTABLE_STRING,
659 CERT_RDN_BMP_STRING, 0 };
662 info->rgRDN[info->cRDN].cRDNAttr = 1;
663 info->rgRDN[info->cRDN].rgRDNAttr[0].pszObjId =
664 (LPSTR)keyOID->pszOID;
665 info->rgRDN[info->cRDN].rgRDNAttr[0].dwValueType =
666 CERT_RDN_ENCODED_BLOB;
667 if (keyOID->ExtraInfo.cbData)
668 types = (const DWORD *)keyOID->ExtraInfo.pbData;
670 types = defaultTypes;
672 /* Remove surrounding quotes */
673 if (value->start[0] == '"')
678 ret = CRYPT_EncodeValue(dwCertEncodingType, value,
679 &info->rgRDN[info->cRDN].rgRDNAttr[0].Value, types, ppszError);
687 BOOL WINAPI CertStrToNameW(DWORD dwCertEncodingType, LPCWSTR pszX500,
688 DWORD dwStrType, void *pvReserved, BYTE *pbEncoded, DWORD *pcbEncoded,
691 CERT_NAME_INFO info = { 0, NULL };
693 struct KeynameKeeper keeper;
694 DWORD i, error = ERROR_SUCCESS;
697 TRACE("(%08lx, %s, %08lx, %p, %p, %p, %p)\n", dwCertEncodingType,
698 debugstr_w(pszX500), dwStrType, pvReserved, pbEncoded, pcbEncoded,
701 CRYPT_InitializeKeynameKeeper(&keeper);
703 while (str && *str && !error && ret)
705 struct X500TokenW token;
707 error = CRYPT_GetNextKeyW(str, &token, ppszError);
708 if (!error && token.start)
710 PCCRYPT_OID_INFO keyOID;
712 CRYPT_KeynameKeeperFromTokenW(&keeper, &token);
713 keyOID = CryptFindOIDInfo(CRYPT_OID_INFO_NAME_KEY, keeper.keyName,
714 CRYPT_RDN_ATTR_OID_GROUP_ID);
718 *ppszError = token.start;
719 error = CRYPT_E_INVALID_X500_STRING;
724 while (isspace(*str))
730 error = CRYPT_E_INVALID_X500_STRING;
734 static const WCHAR commaSep[] = { ',',0 };
735 static const WCHAR semiSep[] = { ';',0 };
736 static const WCHAR crlfSep[] = { '\r','\n',0 };
737 static const WCHAR allSeps[] = { ',',';','\r','\n',0 };
741 if (dwStrType & CERT_NAME_STR_COMMA_FLAG)
743 else if (dwStrType & CERT_NAME_STR_SEMICOLON_FLAG)
745 else if (dwStrType & CERT_NAME_STR_CRLF_FLAG)
749 error = CRYPT_GetNextValueW(str, dwStrType, sep, &token,
754 ret = CRYPT_ValueToRDN(dwCertEncodingType, &info,
755 keyOID, &token, ppszError);
761 CRYPT_FreeKeynameKeeper(&keeper);
764 ret = CryptEncodeObjectEx(dwCertEncodingType, X509_NAME, &info,
765 0, NULL, pbEncoded, pcbEncoded);
766 for (i = 0; i < info.cRDN; i++)
770 for (j = 0; j < info.rgRDN[i].cRDNAttr; j++)
771 LocalFree(info.rgRDN[i].rgRDNAttr[j].Value.pbData);
772 CryptMemFree(info.rgRDN[i].rgRDNAttr);
774 CryptMemFree(info.rgRDN);
784 DWORD WINAPI CertGetNameStringA(PCCERT_CONTEXT pCertContext, DWORD dwType,
785 DWORD dwFlags, void *pvTypePara, LPSTR pszNameString, DWORD cchNameString)
789 TRACE("(%p, %ld, %08lx, %p, %p, %ld)\n", pCertContext, dwType, dwFlags,
790 pvTypePara, pszNameString, cchNameString);
797 nameLen = CertGetNameStringW(pCertContext, dwType, dwFlags, pvTypePara,
799 wideName = CryptMemAlloc(nameLen * sizeof(WCHAR));
802 CertGetNameStringW(pCertContext, dwType, dwFlags, pvTypePara,
804 nameLen = WideCharToMultiByte(CP_ACP, 0, wideName, nameLen,
805 pszNameString, cchNameString, NULL, NULL);
806 if (nameLen <= cchNameString)
810 pszNameString[cchNameString - 1] = '\0';
813 CryptMemFree(wideName);
817 *pszNameString = '\0';
822 ret = CertGetNameStringW(pCertContext, dwType, dwFlags, pvTypePara,
827 DWORD WINAPI CertGetNameStringW(PCCERT_CONTEXT pCertContext, DWORD dwType,
828 DWORD dwFlags, void *pvTypePara, LPWSTR pszNameString, DWORD cchNameString)
831 PCERT_NAME_BLOB name;
834 TRACE("(%p, %ld, %08lx, %p, %p, %ld)\n", pCertContext, dwType,
835 dwFlags, pvTypePara, pszNameString, cchNameString);
837 if (dwFlags & CERT_NAME_ISSUER_FLAG)
839 name = &pCertContext->pCertInfo->Issuer;
840 altNameOID = szOID_ISSUER_ALT_NAME;
844 name = &pCertContext->pCertInfo->Subject;
845 altNameOID = szOID_SUBJECT_ALT_NAME;
850 case CERT_NAME_SIMPLE_DISPLAY_TYPE:
852 static const LPCSTR simpleAttributeOIDs[] = { szOID_COMMON_NAME,
853 szOID_ORGANIZATIONAL_UNIT_NAME, szOID_ORGANIZATION_NAME,
854 szOID_RSA_emailAddr };
855 CERT_NAME_INFO *info = NULL;
856 PCERT_RDN_ATTR nameAttr = NULL;
859 if (CryptDecodeObjectEx(pCertContext->dwCertEncodingType, X509_NAME,
860 name->pbData, name->cbData, CRYPT_DECODE_ALLOC_FLAG, NULL, &info,
863 for (i = 0; !nameAttr && i < sizeof(simpleAttributeOIDs) /
864 sizeof(simpleAttributeOIDs[0]); i++)
865 nameAttr = CertFindRDNAttr(simpleAttributeOIDs[i], info);
871 PCERT_EXTENSION ext = CertFindExtension(altNameOID,
872 pCertContext->pCertInfo->cExtension,
873 pCertContext->pCertInfo->rgExtension);
877 for (i = 0; !nameAttr && i < sizeof(simpleAttributeOIDs) /
878 sizeof(simpleAttributeOIDs[0]); i++)
879 nameAttr = CertFindRDNAttr(simpleAttributeOIDs[i], info);
882 /* FIXME: gotta then look for a rfc822Name choice in ext.
883 * Failing that, look for the first attribute.
885 FIXME("CERT_NAME_SIMPLE_DISPLAY_TYPE: stub\n");
890 ret = CertRDNValueToStrW(nameAttr->dwValueType, &nameAttr->Value,
891 pszNameString, cchNameString);
896 case CERT_NAME_FRIENDLY_DISPLAY_TYPE:
898 DWORD cch = cchNameString;
900 if (CertGetCertificateContextProperty(pCertContext,
901 CERT_FRIENDLY_NAME_PROP_ID, pszNameString, &cch))
904 ret = CertGetNameStringW(pCertContext,
905 CERT_NAME_SIMPLE_DISPLAY_TYPE, dwFlags, pvTypePara, pszNameString,
910 FIXME("unimplemented for type %ld\n", dwType);