From afc7a7989701946efa55b2cbcb6025450f1d5c01 Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Fri, 21 Nov 2008 07:44:19 -0800 Subject: [PATCH] crypt32: Implement CryptFormatObject for the Netscape string OIDs. --- dlls/crypt32/object.c | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/dlls/crypt32/object.c b/dlls/crypt32/object.c index 5784cc96f68..df5e5099a39 100644 --- a/dlls/crypt32/object.c +++ b/dlls/crypt32/object.c @@ -2253,6 +2253,42 @@ static BOOL WINAPI CRYPT_FormatSpcFinancialCriteria(DWORD dwCertEncodingType, return ret; } +static BOOL WINAPI CRYPT_FormatUnicodeString(DWORD dwCertEncodingType, + DWORD dwFormatType, DWORD dwFormatStrType, void *pFormatStruct, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, void *pbFormat, + DWORD *pcbFormat) +{ + CERT_NAME_VALUE *value; + DWORD size; + BOOL ret; + + if (!cbEncoded) + { + SetLastError(E_INVALIDARG); + return FALSE; + } + if ((ret = CryptDecodeObjectEx(dwCertEncodingType, X509_UNICODE_ANY_STRING, + pbEncoded, cbEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL, &value, &size))) + { + if (!pbFormat) + *pcbFormat = value->Value.cbData; + else if (*pcbFormat < value->Value.cbData) + { + *pcbFormat = value->Value.cbData; + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + LPWSTR str = pbFormat; + + *pcbFormat = value->Value.cbData; + strcpyW(str, (LPWSTR)value->Value.pbData); + } + } + return ret; +} + typedef BOOL (WINAPI *CryptFormatObjectFunc)(DWORD, DWORD, DWORD, void *, LPCSTR, const BYTE *, DWORD, void *, DWORD *); @@ -2318,6 +2354,14 @@ static CryptFormatObjectFunc CRYPT_GetBuiltinFormatFunction(DWORD encodingType, format = CRYPT_FormatEnhancedKeyUsage; else if (!strcmp(lpszStructType, szOID_NETSCAPE_CERT_TYPE)) format = CRYPT_FormatNetscapeCertType; + else if (!strcmp(lpszStructType, szOID_NETSCAPE_BASE_URL) || + !strcmp(lpszStructType, szOID_NETSCAPE_REVOCATION_URL) || + !strcmp(lpszStructType, szOID_NETSCAPE_CA_REVOCATION_URL) || + !strcmp(lpszStructType, szOID_NETSCAPE_CERT_RENEWAL_URL) || + !strcmp(lpszStructType, szOID_NETSCAPE_CA_POLICY_URL) || + !strcmp(lpszStructType, szOID_NETSCAPE_SSL_SERVER_NAME) || + !strcmp(lpszStructType, szOID_NETSCAPE_COMMENT)) + format = CRYPT_FormatUnicodeString; else if (!strcmp(lpszStructType, SPC_FINANCIAL_CRITERIA_OBJID)) format = CRYPT_FormatSpcFinancialCriteria; return format;