From 83f7f9b0ff2ff23e588c38f2463c4ba4dfb1d86c Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Fri, 14 Nov 2008 12:31:28 -0800 Subject: [PATCH] crypt32: Implement CryptFormatObject for alternate names. --- dlls/crypt32/object.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/dlls/crypt32/object.c b/dlls/crypt32/object.c index eb19ed4ebfe..fdab616db9d 100644 --- a/dlls/crypt32/object.c +++ b/dlls/crypt32/object.c @@ -1002,6 +1002,24 @@ static BOOL CRYPT_FormatAltNameInfo(DWORD dwFormatStrType, DWORD indentLevel, static const WCHAR colonSep[] = { ':',' ',0 }; +static BOOL WINAPI CRYPT_FormatAltName(DWORD dwCertEncodingType, + DWORD dwFormatType, DWORD dwFormatStrType, void *pFormatStruct, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, void *pbFormat, + DWORD *pcbFormat) +{ + BOOL ret; + CERT_ALT_NAME_INFO *info; + DWORD size; + + if ((ret = CryptDecodeObjectEx(dwCertEncodingType, X509_ALTERNATE_NAME, + pbEncoded, cbEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size))) + { + ret = CRYPT_FormatAltNameInfo(dwFormatStrType, 0, info, pbFormat, pcbFormat); + LocalFree(info); + } + return ret; +} + static BOOL CRYPT_FormatCertIssuer(DWORD dwFormatStrType, CERT_ALT_NAME_INFO *issuer, LPWSTR str, DWORD *pcbStr) { @@ -1956,6 +1974,9 @@ static CryptFormatObjectFunc CRYPT_GetBuiltinFormatFunction(DWORD encodingType, { switch (LOWORD(lpszStructType)) { + case LOWORD(X509_ALTERNATE_NAME): + format = CRYPT_FormatAltName; + break; case LOWORD(X509_BASIC_CONSTRAINTS2): format = CRYPT_FormatBasicConstraints2; break; @@ -1976,6 +1997,14 @@ static CryptFormatObjectFunc CRYPT_GetBuiltinFormatFunction(DWORD encodingType, break; } } + else if (!strcmp(lpszStructType, szOID_SUBJECT_ALT_NAME)) + format = CRYPT_FormatAltName; + else if (!strcmp(lpszStructType, szOID_ISSUER_ALT_NAME)) + format = CRYPT_FormatAltName; + else if (!strcmp(lpszStructType, szOID_SUBJECT_ALT_NAME2)) + format = CRYPT_FormatAltName; + else if (!strcmp(lpszStructType, szOID_ISSUER_ALT_NAME2)) + format = CRYPT_FormatAltName; else if (!strcmp(lpszStructType, szOID_BASIC_CONSTRAINTS2)) format = CRYPT_FormatBasicConstraints2; else if (!strcmp(lpszStructType, szOID_AUTHORITY_INFO_ACCESS))