2 * Copyright 2002 Mike McCormack for CodeWeavers
3 * Copyright 2005-2006 Juan Lang
4 * Copyright 2018 Dmitry Timoshkov
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/port.h"
26 #define NONAMELESSUNION
29 #define CRYPT_OID_INFO_HAS_EXTRA_FIELDS
34 #include "wine/debug.h"
35 #include "wine/list.h"
36 #include "crypt32_private.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(crypt
);
41 static const WCHAR DllW
[] = { 'D','l','l',0 };
43 static CRITICAL_SECTION funcSetCS
;
44 static CRITICAL_SECTION_DEBUG funcSetCSDebug
=
47 { &funcSetCSDebug
.ProcessLocksList
, &funcSetCSDebug
.ProcessLocksList
},
48 0, 0, { (DWORD_PTR
)(__FILE__
": funcSetCS") }
50 static CRITICAL_SECTION funcSetCS
= { &funcSetCSDebug
, -1, 0, 0, 0, 0 };
51 static struct list funcSets
= { &funcSets
, &funcSets
};
56 CRITICAL_SECTION cs
; /* protects functions */
57 struct list functions
;
65 CRYPT_OID_FUNC_ENTRY entry
;
69 static const WCHAR ROOT
[] = {'R','O','O','T',0};
70 static const WCHAR MY
[] = {'M','Y',0};
71 static const WCHAR CA
[] = {'C','A',0};
72 static const WCHAR ADDRESSBOOK
[] = {'A','D','D','R','E','S','S','B','O','O','K',0};
73 static const WCHAR TRUSTEDPUBLISHER
[] = {'T','r','u','s','t','e','d','P','u','b','l','i','s','h','e','r',0};
74 static const WCHAR DISALLOWED
[] = {'D','i','s','a','l','l','o','w','e','d',0};
75 static const LPCWSTR LocalizedKeys
[] = {ROOT
,MY
,CA
,ADDRESSBOOK
,TRUSTEDPUBLISHER
,DISALLOWED
};
76 static WCHAR LocalizedNames
[ARRAY_SIZE(LocalizedKeys
)][256];
78 static const WCHAR nameW
[] = { 'N','a','m','e',0 };
79 static const WCHAR algidW
[] = { 'A','l','g','i','d',0 };
80 static const WCHAR extraW
[] = { 'E','x','t','r','a','I','n','f','o',0 };
81 static const WCHAR cngalgidW
[] = { 'C','N','G','A','l','g','i','d',0 };
82 static const WCHAR cngextraalgidW
[] = { 'C','N','G','E','x','t','r','a','A','l','g','i','d',0 };
83 static const WCHAR flagsW
[] = { 'F','l','a','g','s',0 };
85 static void free_function_sets(void)
87 struct OIDFunctionSet
*setCursor
, *setNext
;
89 LIST_FOR_EACH_ENTRY_SAFE(setCursor
, setNext
, &funcSets
,
90 struct OIDFunctionSet
, next
)
92 struct OIDFunction
*functionCursor
, *funcNext
;
94 list_remove(&setCursor
->next
);
95 CryptMemFree(setCursor
->name
);
96 LIST_FOR_EACH_ENTRY_SAFE(functionCursor
, funcNext
,
97 &setCursor
->functions
, struct OIDFunction
, next
)
99 list_remove(&functionCursor
->next
);
100 CryptMemFree(functionCursor
);
102 setCursor
->cs
.DebugInfo
->Spare
[0] = 0;
103 DeleteCriticalSection(&setCursor
->cs
);
104 CryptMemFree(setCursor
);
106 DeleteCriticalSection(&funcSetCS
);
109 /* There is no free function associated with this; therefore, the sets are
110 * freed when crypt32.dll is unloaded.
112 HCRYPTOIDFUNCSET WINAPI
CryptInitOIDFunctionSet(LPCSTR pszFuncName
,
115 struct OIDFunctionSet
*cursor
, *ret
= NULL
;
117 TRACE("(%s, %x)\n", debugstr_a(pszFuncName
), dwFlags
);
119 EnterCriticalSection(&funcSetCS
);
120 LIST_FOR_EACH_ENTRY(cursor
, &funcSets
, struct OIDFunctionSet
, next
)
122 if (!_strnicmp(pszFuncName
, cursor
->name
, -1))
130 ret
= CryptMemAlloc(sizeof(struct OIDFunctionSet
));
133 memset(ret
, 0, sizeof(*ret
));
134 ret
->name
= CryptMemAlloc(strlen(pszFuncName
) + 1);
137 InitializeCriticalSection(&ret
->cs
);
138 ret
->cs
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": OIDFunctionSet.cs");
139 list_init(&ret
->functions
);
140 strcpy(ret
->name
, pszFuncName
);
141 list_add_tail(&funcSets
, &ret
->next
);
150 LeaveCriticalSection(&funcSetCS
);
155 static char *CRYPT_GetKeyName(DWORD dwEncodingType
, LPCSTR pszFuncName
,
158 static const char szEncodingTypeFmt
[] =
159 "Software\\Microsoft\\Cryptography\\OID\\EncodingType %d\\%s\\%s";
161 char numericOID
[7]; /* enough for "#65535" */
165 /* MSDN says the encoding type is a mask, but it isn't treated that way.
166 * (E.g., if dwEncodingType were 3, the key names "EncodingType 1" and
167 * "EncodingType 2" would be expected if it were a mask. Instead native
168 * stores values in "EncodingType 3".
170 if (IS_INTOID(pszOID
))
172 snprintf(numericOID
, sizeof(numericOID
), "#%d", LOWORD(pszOID
));
178 /* This is enough: the lengths of the two string parameters are explicitly
179 * counted, and we need up to five additional characters for the encoding
180 * type. These are covered by the "%d", "%s", and "%s" characters in the
181 * format specifier that are removed by sprintf.
183 len
= sizeof(szEncodingTypeFmt
) + lstrlenA(pszFuncName
) + lstrlenA(oid
);
184 szKey
= CryptMemAlloc(len
);
186 sprintf(szKey
, szEncodingTypeFmt
,
187 GET_CERT_ENCODING_TYPE(dwEncodingType
), pszFuncName
, oid
);
191 BOOL WINAPI
CryptGetDefaultOIDDllList(HCRYPTOIDFUNCSET hFuncSet
,
192 DWORD dwEncodingType
, LPWSTR pwszDllList
, DWORD
*pcchDllList
)
194 struct OIDFunctionSet
*set
= hFuncSet
;
199 TRACE("(%p, %d, %p, %p)\n", hFuncSet
, dwEncodingType
, pwszDllList
,
202 keyName
= CRYPT_GetKeyName(dwEncodingType
, set
->name
, "DEFAULT");
203 rc
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keyName
, 0, NULL
, 0,
204 KEY_READ
, NULL
, &key
, NULL
);
207 DWORD size
= *pcchDllList
* sizeof(WCHAR
);
209 rc
= RegQueryValueExW(key
, DllW
, NULL
, NULL
, (LPBYTE
)pwszDllList
,
212 *pcchDllList
= size
/ sizeof(WCHAR
);
215 /* No value, return an empty list */
216 if (pwszDllList
&& *pcchDllList
)
224 /* No value, return an empty list */
225 if (pwszDllList
&& *pcchDllList
)
229 CryptMemFree(keyName
);
234 BOOL WINAPI
CryptInstallOIDFunctionAddress(HMODULE hModule
,
235 DWORD dwEncodingType
, LPCSTR pszFuncName
, DWORD cFuncEntry
,
236 const CRYPT_OID_FUNC_ENTRY rgFuncEntry
[], DWORD dwFlags
)
239 struct OIDFunctionSet
*set
;
241 TRACE("(%p, %d, %s, %d, %p, %08x)\n", hModule
, dwEncodingType
,
242 debugstr_a(pszFuncName
), cFuncEntry
, rgFuncEntry
, dwFlags
);
244 set
= CryptInitOIDFunctionSet(pszFuncName
, 0);
249 EnterCriticalSection(&set
->cs
);
250 for (i
= 0; ret
&& i
< cFuncEntry
; i
++)
252 struct OIDFunction
*func
;
254 TRACE("OID %s, func %p\n", debugstr_a(rgFuncEntry
[i
].pszOID
), rgFuncEntry
[i
].pvFuncAddr
);
256 if (!IS_INTOID(rgFuncEntry
[i
].pszOID
))
257 func
= CryptMemAlloc(sizeof(struct OIDFunction
)
258 + strlen(rgFuncEntry
[i
].pszOID
) + 1);
260 func
= CryptMemAlloc(sizeof(struct OIDFunction
));
263 func
->encoding
= GET_CERT_ENCODING_TYPE(dwEncodingType
);
264 if (!IS_INTOID(rgFuncEntry
[i
].pszOID
))
268 oid
= (LPSTR
)((LPBYTE
)func
+ sizeof(*func
));
269 strcpy(oid
, rgFuncEntry
[i
].pszOID
);
270 func
->entry
.pszOID
= oid
;
273 func
->entry
.pszOID
= rgFuncEntry
[i
].pszOID
;
274 func
->entry
.pvFuncAddr
= rgFuncEntry
[i
].pvFuncAddr
;
275 func
->hModule
= hModule
;
276 list_add_tail(&set
->functions
, &func
->next
);
281 LeaveCriticalSection(&set
->cs
);
295 static BOOL
CRYPT_GetFuncFromReg(DWORD dwEncodingType
, LPCSTR pszOID
,
296 LPCSTR szFuncName
, LPVOID
*ppvFuncAddr
, HCRYPTOIDFUNCADDR
*phFuncAddr
)
300 const char *funcName
;
304 keyName
= CRYPT_GetKeyName(dwEncodingType
, szFuncName
, pszOID
);
305 rc
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
, keyName
, 0, KEY_READ
, &key
);
308 DWORD type
, size
= 0;
310 rc
= RegQueryValueExA(key
, "FuncName", NULL
, &type
, NULL
, &size
);
311 if ((!rc
|| rc
== ERROR_MORE_DATA
) && type
== REG_SZ
)
313 funcName
= CryptMemAlloc(size
);
314 rc
= RegQueryValueExA(key
, "FuncName", NULL
, &type
,
315 (LPBYTE
)funcName
, &size
);
318 funcName
= szFuncName
;
319 rc
= RegQueryValueExW(key
, DllW
, NULL
, &type
, NULL
, &size
);
320 if ((!rc
|| rc
== ERROR_MORE_DATA
) && type
== REG_SZ
)
322 LPWSTR dllName
= CryptMemAlloc(size
);
326 rc
= RegQueryValueExW(key
, DllW
, NULL
, NULL
,
327 (LPBYTE
)dllName
, &size
);
332 /* This is a bit of a hack; MSDN describes a more
333 * complicated unload routine than this will allow.
334 * Still, this seems to suffice for now.
336 lib
= LoadLibraryW(dllName
);
339 *ppvFuncAddr
= GetProcAddress(lib
, funcName
);
342 struct FuncAddr
*addr
=
343 CryptMemAlloc(sizeof(struct FuncAddr
));
348 addr
->dllList
= addr
->currentDll
= NULL
;
360 /* Unload the library, the caller doesn't want
361 * to unload it when the return value is NULL.
369 CryptMemFree(dllName
);
374 if (funcName
!= szFuncName
)
375 CryptMemFree((char *)funcName
);
380 CryptMemFree(keyName
);
384 BOOL WINAPI
CryptGetOIDFunctionAddress(HCRYPTOIDFUNCSET hFuncSet
,
385 DWORD dwEncodingType
, LPCSTR pszOID
, DWORD dwFlags
, void **ppvFuncAddr
,
386 HCRYPTOIDFUNCADDR
*phFuncAddr
)
389 struct OIDFunctionSet
*set
= hFuncSet
;
391 TRACE("(%p, %d, %s, %08x, %p, %p)\n", hFuncSet
, dwEncodingType
,
392 debugstr_a(pszOID
), dwFlags
, ppvFuncAddr
, phFuncAddr
);
395 if (!(dwFlags
& CRYPT_GET_INSTALLED_OID_FUNC_FLAG
))
397 struct OIDFunction
*function
;
399 EnterCriticalSection(&set
->cs
);
400 LIST_FOR_EACH_ENTRY(function
, &set
->functions
, struct OIDFunction
, next
)
402 if (function
->encoding
== GET_CERT_ENCODING_TYPE(dwEncodingType
))
404 if (!IS_INTOID(pszOID
))
406 if (!IS_INTOID(function
->entry
.pszOID
) &&
407 !_strnicmp(function
->entry
.pszOID
, pszOID
, -1))
409 *ppvFuncAddr
= function
->entry
.pvFuncAddr
;
410 *phFuncAddr
= NULL
; /* FIXME: what should it be? */
415 else if (function
->entry
.pszOID
== pszOID
)
417 *ppvFuncAddr
= function
->entry
.pvFuncAddr
;
418 *phFuncAddr
= NULL
; /* FIXME: what should it be? */
424 LeaveCriticalSection(&set
->cs
);
427 ret
= CRYPT_GetFuncFromReg(dwEncodingType
, pszOID
, set
->name
,
428 ppvFuncAddr
, phFuncAddr
);
429 TRACE("returning %d\n", ret
);
433 static BOOL
is_module_registered(HMODULE hModule
)
435 struct OIDFunctionSet
*set
;
438 EnterCriticalSection(&funcSetCS
);
440 LIST_FOR_EACH_ENTRY(set
, &funcSets
, struct OIDFunctionSet
, next
)
442 struct OIDFunction
*function
;
444 EnterCriticalSection(&set
->cs
);
446 LIST_FOR_EACH_ENTRY(function
, &set
->functions
, struct OIDFunction
, next
)
448 if (function
->hModule
== hModule
)
455 LeaveCriticalSection(&set
->cs
);
460 LeaveCriticalSection(&funcSetCS
);
465 BOOL WINAPI
CryptFreeOIDFunctionAddress(HCRYPTOIDFUNCADDR hFuncAddr
,
468 TRACE("(%p, %08x)\n", hFuncAddr
, dwFlags
);
470 /* FIXME: as MSDN states, need to check for DllCanUnloadNow in the DLL,
471 * and only unload it if it can be unloaded. Also need to implement ref
472 * counting on the functions.
476 struct FuncAddr
*addr
= hFuncAddr
;
478 if (!is_module_registered(addr
->lib
))
480 CryptMemFree(addr
->dllList
);
481 FreeLibrary(addr
->lib
);
488 static BOOL
CRYPT_GetFuncFromDll(LPCWSTR dll
, LPCSTR func
, HMODULE
*lib
,
493 *lib
= LoadLibraryW(dll
);
496 *ppvFuncAddr
= GetProcAddress(*lib
, func
);
508 BOOL WINAPI
CryptGetDefaultOIDFunctionAddress(HCRYPTOIDFUNCSET hFuncSet
,
509 DWORD dwEncodingType
, LPCWSTR pwszDll
, DWORD dwFlags
, void **ppvFuncAddr
,
510 HCRYPTOIDFUNCADDR
*phFuncAddr
)
512 struct OIDFunctionSet
*set
= hFuncSet
;
515 TRACE("(%p, %d, %s, %08x, %p, %p)\n", hFuncSet
, dwEncodingType
,
516 debugstr_w(pwszDll
), dwFlags
, ppvFuncAddr
, phFuncAddr
);
523 ret
= CRYPT_GetFuncFromDll(pwszDll
, set
->name
, &lib
, ppvFuncAddr
);
526 struct FuncAddr
*addr
= CryptMemAlloc(sizeof(struct FuncAddr
));
531 addr
->dllList
= addr
->currentDll
= NULL
;
538 SetLastError(ERROR_OUTOFMEMORY
);
543 SetLastError(ERROR_FILE_NOT_FOUND
);
547 struct FuncAddr
*addr
= *phFuncAddr
;
553 ret
= CryptGetDefaultOIDDllList(hFuncSet
, dwEncodingType
, NULL
,
557 LPWSTR dllList
= CryptMemAlloc(size
* sizeof(WCHAR
));
561 ret
= CryptGetDefaultOIDDllList(hFuncSet
, dwEncodingType
,
565 addr
= CryptMemAlloc(sizeof(struct FuncAddr
));
568 addr
->dllList
= dllList
;
569 addr
->currentDll
= dllList
;
575 CryptMemFree(dllList
);
576 SetLastError(ERROR_OUTOFMEMORY
);
583 SetLastError(ERROR_OUTOFMEMORY
);
590 if (!*addr
->currentDll
)
592 CryptFreeOIDFunctionAddress(*phFuncAddr
, 0);
593 SetLastError(ERROR_FILE_NOT_FOUND
);
599 /* FIXME: as elsewhere, can't free until DllCanUnloadNow says
600 * it's possible, and should defer unloading for some time to
601 * avoid repeated LoadLibrary/FreeLibrary on the same dll.
603 FreeLibrary(addr
->lib
);
604 ret
= CRYPT_GetFuncFromDll(addr
->currentDll
, set
->name
,
605 &addr
->lib
, ppvFuncAddr
);
608 /* Move past the current DLL */
609 addr
->currentDll
+= lstrlenW(addr
->currentDll
) + 1;
614 CryptFreeOIDFunctionAddress(*phFuncAddr
, 0);
615 SetLastError(ERROR_FILE_NOT_FOUND
);
624 /***********************************************************************
625 * CryptRegisterOIDFunction (CRYPT32.@)
627 * Register the DLL and the functions it uses to cover the combination
628 * of encoding type, function name and OID.
631 * dwEncodingType [I] Encoding type to be used.
632 * pszFuncName [I] Name of the function to be registered.
633 * pszOID [I] OID of the function (numeric or string).
634 * pwszDll [I] The DLL that is to be registered.
635 * pszOverrideFuncName [I] Name of the function in the DLL.
639 * Failure: FALSE. (Look at GetLastError()).
642 * Registry errors are always reported via SetLastError().
644 BOOL WINAPI
CryptRegisterOIDFunction(DWORD dwEncodingType
, LPCSTR pszFuncName
,
645 LPCSTR pszOID
, LPCWSTR pwszDll
, LPCSTR pszOverrideFuncName
)
651 TRACE("(%x, %s, %s, %s, %s)\n", dwEncodingType
, debugstr_a(pszFuncName
),
652 debugstr_a(pszOID
), debugstr_w(pwszDll
), debugstr_a(pszOverrideFuncName
));
654 /* Native does nothing pwszDll is NULL */
658 /* I'm not matching MS bug for bug here, because I doubt any app depends on
659 * it: native "succeeds" if pszFuncName is NULL, but the nonsensical entry
660 * it creates would never be used.
662 if (!pszFuncName
|| !pszOID
)
664 SetLastError(E_INVALIDARG
);
668 szKey
= CRYPT_GetKeyName(dwEncodingType
, pszFuncName
, pszOID
);
669 TRACE("Key name is %s\n", debugstr_a(szKey
));
674 r
= RegCreateKeyA(HKEY_LOCAL_MACHINE
, szKey
, &hKey
);
677 if (r
!= ERROR_SUCCESS
) goto error_close_key
;
679 /* write the values */
680 if (pszOverrideFuncName
)
682 r
= RegSetValueExA(hKey
, "FuncName", 0, REG_SZ
,
683 (const BYTE
*)pszOverrideFuncName
, lstrlenA(pszOverrideFuncName
) + 1);
684 if (r
!= ERROR_SUCCESS
) goto error_close_key
;
686 r
= RegSetValueExW(hKey
, DllW
, 0, REG_SZ
, (const BYTE
*) pwszDll
,
687 (lstrlenW(pwszDll
) + 1) * sizeof (WCHAR
));
693 if (r
!= ERROR_SUCCESS
)
702 /***********************************************************************
703 * CryptUnregisterOIDInfo (CRYPT32.@)
705 BOOL WINAPI
CryptUnregisterOIDInfo(PCCRYPT_OID_INFO info
)
711 TRACE("(%p)\n", info
);
713 if (!info
|| info
->cbSize
!= sizeof(*info
) || !info
->pszOID
)
715 SetLastError(E_INVALIDARG
);
719 err
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
, "Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptDllFindOIDInfo", 0, KEY_ALL_ACCESS
, &root
);
720 if (err
!= ERROR_SUCCESS
)
726 key_name
= CryptMemAlloc(strlen(info
->pszOID
) + 16);
729 sprintf(key_name
, "%s!%u", info
->pszOID
, info
->dwGroupId
);
730 err
= RegDeleteKeyA(root
, key_name
);
733 err
= ERROR_OUTOFMEMORY
;
735 CryptMemFree(key_name
);
744 /***********************************************************************
745 * CryptRegisterOIDInfo (CRYPT32.@)
747 BOOL WINAPI
CryptRegisterOIDInfo(PCCRYPT_OID_INFO info
, DWORD flags
)
750 HKEY root
= 0, key
= 0;
753 TRACE("(%p, %x)\n", info
, flags
);
755 if (!info
|| info
->cbSize
!= sizeof(*info
) || !info
->pszOID
)
757 SetLastError(E_INVALIDARG
);
761 if (!info
->dwGroupId
) return TRUE
;
763 key_name
= CryptMemAlloc(strlen(info
->pszOID
) + 16);
766 err
= ERROR_OUTOFMEMORY
;
770 err
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, "Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptDllFindOIDInfo",
771 0, NULL
, 0, KEY_ALL_ACCESS
, NULL
, &root
, NULL
);
772 if (err
!= ERROR_SUCCESS
) goto done
;
774 sprintf(key_name
, "%s!%u", info
->pszOID
, info
->dwGroupId
);
775 err
= RegCreateKeyA(root
, key_name
, &key
);
776 if (err
!= ERROR_SUCCESS
) goto done
;
780 err
= RegSetValueExW(key
, flagsW
, 0, REG_DWORD
, (const BYTE
*)&flags
, sizeof(flags
));
781 if (err
!= ERROR_SUCCESS
) goto done
;
786 err
= RegSetValueExW(key
, nameW
, 0, REG_SZ
, (const BYTE
*)info
->pwszName
, (lstrlenW(info
->pwszName
) + 1) * sizeof(WCHAR
));
787 if (err
!= ERROR_SUCCESS
) goto done
;
792 err
= RegSetValueExW(key
, algidW
, 0, REG_DWORD
, (const BYTE
*)&info
->u
.Algid
, sizeof(info
->u
.Algid
));
793 if (err
!= ERROR_SUCCESS
) goto done
;
796 if (info
->ExtraInfo
.cbData
&& info
->ExtraInfo
.pbData
)
798 err
= RegSetValueExW(key
, extraW
, 0, REG_BINARY
, info
->ExtraInfo
.pbData
, info
->ExtraInfo
.cbData
);
799 if (err
!= ERROR_SUCCESS
) goto done
;
802 if (info
->pwszCNGAlgid
)
804 err
= RegSetValueExW(key
, cngalgidW
, 0, REG_SZ
, (const BYTE
*)info
->pwszCNGAlgid
, (lstrlenW(info
->pwszCNGAlgid
) + 1) * sizeof(WCHAR
));
805 if (err
!= ERROR_SUCCESS
) goto done
;
808 if (info
->pwszCNGExtraAlgid
)
810 err
= RegSetValueExW(key
, cngextraalgidW
, 0, REG_SZ
, (const BYTE
*)info
->pwszCNGExtraAlgid
, (lstrlenW(info
->pwszCNGExtraAlgid
) + 1) * sizeof(WCHAR
));
811 if (err
!= ERROR_SUCCESS
) goto done
;
815 CryptMemFree(key_name
);
816 if (key
) RegCloseKey(key
);
817 if (root
) RegCloseKey(root
);
825 /***********************************************************************
826 * CryptUnregisterOIDFunction (CRYPT32.@)
828 BOOL WINAPI
CryptUnregisterOIDFunction(DWORD dwEncodingType
, LPCSTR pszFuncName
,
834 TRACE("%x %s %s\n", dwEncodingType
, debugstr_a(pszFuncName
),
837 if (!pszFuncName
|| !pszOID
)
839 SetLastError(ERROR_INVALID_PARAMETER
);
843 szKey
= CRYPT_GetKeyName(dwEncodingType
, pszFuncName
, pszOID
);
844 rc
= RegDeleteKeyA(HKEY_LOCAL_MACHINE
, szKey
);
851 BOOL WINAPI
CryptGetOIDFunctionValue(DWORD dwEncodingType
, LPCSTR pszFuncName
,
852 LPCSTR pszOID
, LPCWSTR pwszValueName
, DWORD
*pdwValueType
, BYTE
*pbValueData
,
859 TRACE("%x %s %s %s %p %p %p\n", dwEncodingType
, debugstr_a(pszFuncName
),
860 debugstr_a(pszOID
), debugstr_w(pwszValueName
), pdwValueType
, pbValueData
,
863 if (!GET_CERT_ENCODING_TYPE(dwEncodingType
))
866 if (!pszFuncName
|| !pszOID
|| !pwszValueName
)
868 SetLastError(ERROR_INVALID_PARAMETER
);
872 szKey
= CRYPT_GetKeyName(dwEncodingType
, pszFuncName
, pszOID
);
873 rc
= RegOpenKeyA(HKEY_LOCAL_MACHINE
, szKey
, &hKey
);
879 rc
= RegQueryValueExW(hKey
, pwszValueName
, NULL
, pdwValueType
,
880 pbValueData
, pcbValueData
);
888 BOOL WINAPI
CryptSetOIDFunctionValue(DWORD dwEncodingType
, LPCSTR pszFuncName
,
889 LPCSTR pszOID
, LPCWSTR pwszValueName
, DWORD dwValueType
,
890 const BYTE
*pbValueData
, DWORD cbValueData
)
896 TRACE("%x %s %s %s %d %p %d\n", dwEncodingType
, debugstr_a(pszFuncName
),
897 debugstr_a(pszOID
), debugstr_w(pwszValueName
), dwValueType
, pbValueData
,
900 if (!GET_CERT_ENCODING_TYPE(dwEncodingType
))
903 if (!pszFuncName
|| !pszOID
|| !pwszValueName
)
905 SetLastError(ERROR_INVALID_PARAMETER
);
909 szKey
= CRYPT_GetKeyName(dwEncodingType
, pszFuncName
, pszOID
);
910 rc
= RegOpenKeyA(HKEY_LOCAL_MACHINE
, szKey
, &hKey
);
916 rc
= RegSetValueExW(hKey
, pwszValueName
, 0, dwValueType
, pbValueData
,
925 static LPCWSTR
CRYPT_FindStringInMultiString(LPCWSTR multi
, LPCWSTR toFind
)
927 LPCWSTR ret
= NULL
, ptr
;
929 for (ptr
= multi
; ptr
&& *ptr
&& !ret
; ptr
+= lstrlenW(ptr
) + 1)
931 if (!lstrcmpiW(ptr
, toFind
))
937 static DWORD
CRYPT_GetMultiStringCharacterLen(LPCWSTR multi
)
945 /* Count terminating empty string */
947 for (ptr
= multi
; *ptr
; ptr
+= lstrlenW(ptr
) + 1)
948 ret
+= lstrlenW(ptr
) + 1;
955 static LPWSTR
CRYPT_AddStringToMultiString(LPWSTR multi
, LPCWSTR toAdd
,
962 /* FIXME: ignoring index, is that okay? */
963 ret
= CryptMemAlloc((lstrlenW(toAdd
) + 2) * sizeof(WCHAR
));
966 /* copy string, including NULL terminator */
967 memcpy(ret
, toAdd
, (lstrlenW(toAdd
) + 1) * sizeof(WCHAR
));
968 /* add terminating empty string */
969 *(ret
+ lstrlenW(toAdd
) + 1) = 0;
974 DWORD len
= CRYPT_GetMultiStringCharacterLen(multi
);
976 ret
= CryptMemRealloc(multi
, (len
+ lstrlenW(toAdd
) + 1) *
982 if (index
== CRYPT_REGISTER_LAST_INDEX
)
983 spotToAdd
= ret
+ len
- 1;
988 /* FIXME: if index is too large for the string, toAdd is
989 * added to the end. Is that okay?
991 for (i
= 0, spotToAdd
= ret
; i
< index
&& *spotToAdd
;
992 spotToAdd
+= lstrlenW(spotToAdd
) + 1)
997 /* Copy existing string "right" */
998 memmove(spotToAdd
+ lstrlenW(toAdd
) + 1, spotToAdd
,
999 (len
- (spotToAdd
- ret
)) * sizeof(WCHAR
));
1000 /* Copy new string */
1001 memcpy(spotToAdd
, toAdd
, (lstrlenW(toAdd
) + 1) * sizeof(WCHAR
));
1013 static BOOL
CRYPT_RemoveStringFromMultiString(LPWSTR multi
, LPCWSTR toRemove
)
1015 LPWSTR spotToRemove
= (LPWSTR
)CRYPT_FindStringInMultiString(multi
,
1021 DWORD len
= CRYPT_GetMultiStringCharacterLen(multi
);
1023 if (spotToRemove
+ lstrlenW(toRemove
) + 2 >= multi
+ len
)
1025 /* Removing last string in list, terminate multi string directly */
1027 *(spotToRemove
+ 1) = 0;
1031 LPCWSTR nextStr
= spotToRemove
+ lstrlenW(toRemove
) + 1;
1033 /* Copy remainder of string "left" */
1034 memmove(spotToRemove
, nextStr
,
1035 (len
- (nextStr
- multi
)) * sizeof(WCHAR
));
1041 SetLastError(ERROR_FILE_NOT_FOUND
);
1047 static BOOL
CRYPT_GetDefaultOIDKey(DWORD dwEncodingType
, LPCSTR pszFuncName
,
1053 keyName
= CRYPT_GetKeyName(dwEncodingType
, pszFuncName
, "DEFAULT");
1054 TRACE("Key name is %s\n", debugstr_a(keyName
));
1059 r
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keyName
, 0, NULL
, 0, KEY_ALL_ACCESS
,
1061 CryptMemFree(keyName
);
1062 if (r
!= ERROR_SUCCESS
)
1070 static LPWSTR
CRYPT_GetDefaultOIDDlls(HKEY key
)
1076 r
= RegQueryValueExW(key
, DllW
, NULL
, &type
, NULL
, &size
);
1077 if (r
== ERROR_SUCCESS
&& type
== REG_MULTI_SZ
)
1079 dlls
= CryptMemAlloc(size
);
1080 r
= RegQueryValueExW(key
, DllW
, NULL
, &type
, (LPBYTE
)dlls
, &size
);
1081 if (r
!= ERROR_SUCCESS
)
1092 static inline BOOL
CRYPT_SetDefaultOIDDlls(HKEY key
, LPCWSTR dlls
)
1094 DWORD len
= CRYPT_GetMultiStringCharacterLen(dlls
);
1097 if ((r
= RegSetValueExW(key
, DllW
, 0, REG_MULTI_SZ
, (const BYTE
*)dlls
,
1098 len
* sizeof (WCHAR
))))
1100 return r
== ERROR_SUCCESS
;
1103 /***********************************************************************
1104 * CryptRegisterDefaultOIDFunction (CRYPT32.@)
1106 BOOL WINAPI
CryptRegisterDefaultOIDFunction(DWORD dwEncodingType
,
1107 LPCSTR pszFuncName
, DWORD dwIndex
, LPCWSTR pwszDll
)
1113 TRACE("(%x, %s, %d, %s)\n", dwEncodingType
, debugstr_a(pszFuncName
),
1114 dwIndex
, debugstr_w(pwszDll
));
1118 SetLastError(E_INVALIDARG
);
1122 if (!CRYPT_GetDefaultOIDKey(dwEncodingType
, pszFuncName
, &key
))
1125 dlls
= CRYPT_GetDefaultOIDDlls(key
);
1126 if (CRYPT_FindStringInMultiString(dlls
, pwszDll
))
1127 SetLastError(ERROR_FILE_EXISTS
);
1130 dlls
= CRYPT_AddStringToMultiString(dlls
, pwszDll
, dwIndex
);
1132 ret
= CRYPT_SetDefaultOIDDlls(key
, dlls
);
1139 BOOL WINAPI
CryptUnregisterDefaultOIDFunction(DWORD dwEncodingType
,
1140 LPCSTR pszFuncName
, LPCWSTR pwszDll
)
1146 TRACE("(%x, %s, %s)\n", dwEncodingType
, debugstr_a(pszFuncName
),
1147 debugstr_w(pwszDll
));
1151 SetLastError(E_INVALIDARG
);
1155 if (!CRYPT_GetDefaultOIDKey(dwEncodingType
, pszFuncName
, &key
))
1158 dlls
= CRYPT_GetDefaultOIDDlls(key
);
1159 if ((ret
= CRYPT_RemoveStringFromMultiString(dlls
, pwszDll
)))
1160 ret
= CRYPT_SetDefaultOIDDlls(key
, dlls
);
1166 static void oid_init_localizednames(void)
1170 for(i
= 0; i
< ARRAY_SIZE(LocalizedKeys
); i
++)
1172 LoadStringW(hInstance
, IDS_LOCALIZEDNAME_ROOT
+i
, LocalizedNames
[i
], 256);
1176 /********************************************************************
1177 * CryptFindLocalizedName (CRYPT32.@)
1179 LPCWSTR WINAPI
CryptFindLocalizedName(LPCWSTR pwszCryptName
)
1183 for(i
= 0; i
< ARRAY_SIZE(LocalizedKeys
); i
++)
1185 if(!lstrcmpiW(LocalizedKeys
[i
], pwszCryptName
))
1187 return LocalizedNames
[i
];
1191 FIXME("No name for: %s - stub\n",debugstr_w(pwszCryptName
));
1195 static CRITICAL_SECTION oidInfoCS
;
1196 static CRITICAL_SECTION_DEBUG oidInfoCSDebug
=
1199 { &oidInfoCSDebug
.ProcessLocksList
, &oidInfoCSDebug
.ProcessLocksList
},
1200 0, 0, { (DWORD_PTR
)(__FILE__
": oidInfoCS") }
1202 static CRITICAL_SECTION oidInfoCS
= { &oidInfoCSDebug
, -1, 0, 0, 0, 0 };
1203 static struct list oidInfo
= { &oidInfo
, &oidInfo
};
1205 static const WCHAR tripledes
[] = { '3','d','e','s',0 };
1206 static const WCHAR cms3deswrap
[] = { 'C','M','S','3','D','E','S','w','r','a',
1208 static const WCHAR cmsrc2wrap
[] = { 'C','M','S','R','C','2','w','r','a','p',0 };
1209 static const WCHAR des
[] = { 'd','e','s',0 };
1210 static const WCHAR md2
[] = { 'm','d','2',0 };
1211 static const WCHAR md4
[] = { 'm','d','4',0 };
1212 static const WCHAR md5
[] = { 'm','d','5',0 };
1213 static const WCHAR rc2
[] = { 'r','c','2',0 };
1214 static const WCHAR rc4
[] = { 'r','c','4',0 };
1215 static const WCHAR sha
[] = { 's','h','a',0 };
1216 static const WCHAR sha1
[] = { 's','h','a','1',0 };
1217 static const WCHAR sha256
[] = { 's','h','a','2','5','6',0 };
1218 static const WCHAR sha384
[] = { 's','h','a','3','8','4',0 };
1219 static const WCHAR sha512
[] = { 's','h','a','5','1','2',0 };
1220 static const WCHAR RSA
[] = { 'R','S','A',0 };
1221 static const WCHAR RSA_KEYX
[] = { 'R','S','A','_','K','E','Y','X',0 };
1222 static const WCHAR RSA_SIGN
[] = { 'R','S','A','_','S','I','G','N',0 };
1223 static const WCHAR DSA
[] = { 'D','S','A',0 };
1224 static const WCHAR DSA_SIGN
[] = { 'D','S','A','_','S','I','G','N',0 };
1225 static const WCHAR DH
[] = { 'D','H',0 };
1226 static const WCHAR DSS
[] = { 'D','S','S',0 };
1227 static const WCHAR mosaicKMandUpdSig
[] =
1228 { 'm','o','s','a','i','c','K','M','a','n','d','U','p','d','S','i','g',0 };
1229 static const WCHAR ESDH
[] = { 'E','S','D','H',0 };
1230 static const WCHAR NO_SIGN
[] = { 'N','O','S','I','G','N',0 };
1231 static const WCHAR dsaSHA1
[] = { 'd','s','a','S','H','A','1',0 };
1232 static const WCHAR md2RSA
[] = { 'm','d','2','R','S','A',0 };
1233 static const WCHAR md4RSA
[] = { 'm','d','4','R','S','A',0 };
1234 static const WCHAR md5RSA
[] = { 'm','d','5','R','S','A',0 };
1235 static const WCHAR shaDSA
[] = { 's','h','a','D','S','A',0 };
1236 static const WCHAR sha1DSA
[] = { 's','h','a','1','D','S','A',0 };
1237 static const WCHAR shaRSA
[] = { 's','h','a','R','S','A',0 };
1238 static const WCHAR sha1RSA
[] = { 's','h','a','1','R','S','A',0 };
1239 static const WCHAR sha256RSA
[] = { 's','h','a','2','5','6','R','S','A',0 };
1240 static const WCHAR sha384RSA
[] = { 's','h','a','3','8','4','R','S','A',0 };
1241 static const WCHAR sha512RSA
[] = { 's','h','a','5','1','2','R','S','A',0 };
1242 static const WCHAR mosaicUpdatedSig
[] =
1243 { 'm','o','s','a','i','c','U','p','d','a','t','e','d','S','i','g',0 };
1244 static const WCHAR sha256ECDSA
[] = { 's','h','a','2','5','6','E','C','D','S','A',0 };
1245 static const WCHAR sha384ECDSA
[] = { 's','h','a','3','8','4','E','C','D','S','A',0 };
1246 static const WCHAR CN
[] = { 'C','N',0 };
1247 static const WCHAR L
[] = { 'L',0 };
1248 static const WCHAR O
[] = { 'O',0 };
1249 static const WCHAR OU
[] = { 'O','U',0 };
1250 static const WCHAR E
[] = { 'E',0 };
1251 static const WCHAR C
[] = { 'C',0 };
1252 static const WCHAR S
[] = { 'S',0 };
1253 static const WCHAR ST
[] = { 'S','T',0 };
1254 static const WCHAR STREET
[] = { 'S','T','R','E','E','T',0 };
1255 static const WCHAR T
[] = { 'T',0 };
1256 static const WCHAR Title
[] = { 'T','i','t','l','e',0 };
1257 static const WCHAR G
[] = { 'G',0 };
1258 static const WCHAR GivenName
[] = { 'G','i','v','e','n','N','a','m','e',0 };
1259 static const WCHAR I
[] = { 'I',0 };
1260 static const WCHAR Initials
[] = { 'I','n','i','t','i','a','l','s',0 };
1261 static const WCHAR SN
[] = { 'S','N',0 };
1262 static const WCHAR DC
[] = { 'D','C',0 };
1263 static const WCHAR Description
[] =
1264 { 'D','e','s','c','r','i','p','t','i','o','n',0 };
1265 static const WCHAR PostalCode
[] = { 'P','o','s','t','a','l','C','o','d','e',0 };
1266 static const WCHAR POBox
[] = { 'P','O','B','o','x',0 };
1267 static const WCHAR Phone
[] = { 'P','h','o','n','e',0 };
1268 static const WCHAR X21Address
[] = { 'X','2','1','A','d','d','r','e','s','s',0 };
1269 static const WCHAR dnQualifier
[] =
1270 { 'd','n','Q','u','a','l','i','f','i','e','r',0 };
1271 static const WCHAR SpcSpAgencyInfo
[] = { 'S','p','c','S','p','A','g','e','n','c','y','I','n','f','o',0 };
1272 static const WCHAR SpcFinancialCriteria
[] = { 'S','p','c','F','i','n','a','n','c','i','a','l','C','r','i','t','e','r','i','a',0 };
1273 static const WCHAR SpcMinimalCriteria
[] = { 'S','p','c','M','i','n','i','m','a','l','C','r','i','t','e','r','i','a',0 };
1274 static const WCHAR Email
[] = { 'E','m','a','i','l',0 };
1275 static const WCHAR GN
[] = { 'G','N',0 };
1276 static const WCHAR SERIALNUMBER
[] = { 'S','E','R','I','A','L','N','U','M','B','E','R',0 };
1278 static const DWORD noNullFlag
= CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG
;
1279 static const DWORD mosaicFlags
= CRYPT_OID_INHIBIT_SIGNATURE_FORMAT_FLAG
|
1280 CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG
;
1281 static const CRYPT_DATA_BLOB noNullBlob
= { sizeof(noNullFlag
),
1282 (LPBYTE
)&noNullFlag
};
1283 static const CRYPT_DATA_BLOB mosaicFlagsBlob
= { sizeof(mosaicFlags
),
1284 (LPBYTE
)&mosaicFlags
};
1286 static const DWORD rsaSign
= CALG_RSA_SIGN
;
1287 static const DWORD dssSign
[2] = { CALG_DSS_SIGN
,
1288 CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG
};
1289 static const DWORD mosaicSign
[2] = { CALG_DSS_SIGN
,
1290 CRYPT_OID_INHIBIT_SIGNATURE_FORMAT_FLAG
|
1291 CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG
};
1292 static const DWORD ecdsaSign
[2] = { CALG_OID_INFO_PARAMETERS
, CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG
};
1293 static const CRYPT_DATA_BLOB rsaSignBlob
= { sizeof(rsaSign
),
1295 static const CRYPT_DATA_BLOB dssSignBlob
= { sizeof(dssSign
),
1297 static const CRYPT_DATA_BLOB mosaicSignBlob
= { sizeof(mosaicSign
),
1298 (LPBYTE
)mosaicSign
};
1299 static const CRYPT_DATA_BLOB ecdsaSignBlob
= { sizeof(ecdsaSign
), (BYTE
*)ecdsaSign
};
1301 static const DWORD ia5String
[] = { CERT_RDN_IA5_STRING
, 0 };
1302 static const DWORD numericString
[] = { CERT_RDN_NUMERIC_STRING
, 0 };
1303 static const DWORD printableString
[] = { CERT_RDN_PRINTABLE_STRING
, 0 };
1304 static const DWORD domainCompTypes
[] = { CERT_RDN_IA5_STRING
,
1305 CERT_RDN_UTF8_STRING
, 0 };
1306 static const CRYPT_DATA_BLOB ia5StringBlob
= { sizeof(ia5String
),
1307 (LPBYTE
)ia5String
};
1308 static const CRYPT_DATA_BLOB numericStringBlob
= { sizeof(numericString
),
1309 (LPBYTE
)numericString
};
1310 static const CRYPT_DATA_BLOB printableStringBlob
= { sizeof(printableString
),
1311 (LPBYTE
)printableString
};
1312 static const CRYPT_DATA_BLOB domainCompTypesBlob
= { sizeof(domainCompTypes
),
1313 (LPBYTE
)domainCompTypes
};
1315 static const struct OIDInfoConstructor
{
1320 const CRYPT_DATA_BLOB
*blob
;
1321 const WCHAR
*pwszCNGAlgid
;
1322 const WCHAR
*pwszCNGExtraAlgid
;
1323 } oidInfoConstructors
[] = {
1324 { 1, szOID_OIWSEC_sha1
, CALG_SHA1
, sha1
, NULL
},
1325 { 1, szOID_OIWSEC_sha1
, CALG_SHA1
, sha
, NULL
},
1326 { 1, szOID_OIWSEC_sha
, CALG_SHA
, sha
, NULL
},
1327 { 1, szOID_RSA_MD5
, CALG_MD5
, md5
, NULL
},
1328 { 1, szOID_RSA_MD4
, CALG_MD4
, md4
, NULL
},
1329 { 1, szOID_RSA_MD2
, CALG_MD2
, md2
, NULL
},
1330 /* NOTE: Windows Vista+ uses -1 instead of CALG_SHA_* following SHA entries. */
1331 { 1, szOID_NIST_sha256
, CALG_SHA_256
, sha256
, NULL
},
1332 { 1, szOID_NIST_sha384
, CALG_SHA_384
, sha384
, NULL
},
1333 { 1, szOID_NIST_sha512
, CALG_SHA_512
, sha512
, NULL
},
1335 { 2, szOID_OIWSEC_desCBC
, CALG_DES
, des
, NULL
},
1336 { 2, szOID_RSA_DES_EDE3_CBC
, CALG_3DES
, tripledes
, NULL
},
1337 { 2, szOID_RSA_RC2CBC
, CALG_RC2
, rc2
, NULL
},
1338 { 2, szOID_RSA_RC4
, CALG_RC4
, rc4
, NULL
},
1339 { 2, szOID_RSA_SMIMEalgCMS3DESwrap
, CALG_3DES
, cms3deswrap
, NULL
},
1340 { 2, szOID_RSA_SMIMEalgCMSRC2wrap
, CALG_RC2
, cmsrc2wrap
, NULL
},
1342 { 3, szOID_RSA_RSA
, CALG_RSA_KEYX
, RSA
, NULL
},
1343 { 3, szOID_X957_DSA
, CALG_DSS_SIGN
, DSA
, &noNullBlob
},
1344 { 3, szOID_ANSI_X942_DH
, CALG_DH_SF
, DH
, &noNullBlob
},
1345 { 3, szOID_RSA_RSA
, CALG_RSA_KEYX
, RSA_KEYX
, NULL
},
1346 { 3, szOID_RSA_RSA
, CALG_RSA_SIGN
, RSA
, NULL
},
1347 { 3, szOID_RSA_RSA
, CALG_RSA_SIGN
, RSA_SIGN
, NULL
},
1348 { 3, szOID_OIWSEC_dsa
, CALG_DSS_SIGN
, DSA
, &noNullBlob
},
1349 { 3, szOID_OIWSEC_dsa
, CALG_DSS_SIGN
, DSS
, &noNullBlob
},
1350 { 3, szOID_OIWSEC_dsa
, CALG_DSS_SIGN
, DSA_SIGN
, &noNullBlob
},
1351 { 3, szOID_RSA_DH
, CALG_DH_SF
, DH
, &noNullBlob
},
1352 { 3, szOID_OIWSEC_rsaXchg
, CALG_RSA_KEYX
, RSA_KEYX
, NULL
},
1353 { 3, szOID_INFOSEC_mosaicKMandUpdSig
, CALG_DSS_SIGN
, mosaicKMandUpdSig
,
1355 { 3, szOID_RSA_SMIMEalgESDH
, CALG_DH_EPHEM
, ESDH
, &noNullBlob
},
1356 { 3, szOID_PKIX_NO_SIGNATURE
, CALG_NO_SIGN
, NO_SIGN
, NULL
},
1358 { 4, szOID_RSA_SHA1RSA
, CALG_SHA1
, sha1RSA
, &rsaSignBlob
},
1359 { 4, szOID_RSA_SHA256RSA
, CALG_SHA_256
, sha256RSA
, &rsaSignBlob
},
1360 { 4, szOID_RSA_SHA384RSA
, CALG_SHA_384
, sha384RSA
, &rsaSignBlob
},
1361 { 4, szOID_RSA_SHA512RSA
, CALG_SHA_512
, sha512RSA
, &rsaSignBlob
},
1362 { 4, szOID_RSA_MD5RSA
, CALG_MD5
, md5RSA
, &rsaSignBlob
},
1363 { 4, szOID_X957_SHA1DSA
, CALG_SHA1
, sha1DSA
, &dssSignBlob
},
1364 { 4, szOID_OIWSEC_sha1RSASign
, CALG_SHA1
, sha1RSA
, &rsaSignBlob
},
1365 { 4, szOID_OIWSEC_sha1RSASign
, CALG_SHA1
, shaRSA
, &rsaSignBlob
},
1366 { 4, szOID_OIWSEC_shaRSA
, CALG_SHA1
, shaRSA
, &rsaSignBlob
},
1367 { 4, szOID_OIWSEC_md5RSA
, CALG_MD5
, md5RSA
, &rsaSignBlob
},
1368 { 4, szOID_RSA_MD2RSA
, CALG_MD2
, md2RSA
, &rsaSignBlob
},
1369 { 4, szOID_RSA_MD4RSA
, CALG_MD4
, md4RSA
, &rsaSignBlob
},
1370 { 4, szOID_OIWSEC_md4RSA
, CALG_MD4
, md4RSA
, &rsaSignBlob
},
1371 { 4, szOID_OIWSEC_md4RSA2
, CALG_MD4
, md4RSA
, &rsaSignBlob
},
1372 { 4, szOID_OIWDIR_md2RSA
, CALG_MD2
, md2RSA
, &rsaSignBlob
},
1373 { 4, szOID_OIWSEC_shaDSA
, CALG_SHA1
, sha1DSA
, &dssSignBlob
},
1374 { 4, szOID_OIWSEC_shaDSA
, CALG_SHA1
, shaDSA
, &dssSignBlob
},
1375 { 4, szOID_OIWSEC_dsaSHA1
, CALG_SHA1
, dsaSHA1
, &dssSignBlob
},
1376 { 4, szOID_INFOSEC_mosaicUpdatedSig
, CALG_SHA1
, mosaicUpdatedSig
,
1378 { 4, szOID_ECDSA_SHA256
, CALG_OID_INFO_CNG_ONLY
, sha256ECDSA
, &ecdsaSignBlob
,
1379 BCRYPT_SHA256_ALGORITHM
, CRYPT_OID_INFO_ECC_PARAMETERS_ALGORITHM
},
1380 { 4, szOID_ECDSA_SHA384
, CALG_OID_INFO_CNG_ONLY
, sha384ECDSA
, &ecdsaSignBlob
,
1381 BCRYPT_SHA384_ALGORITHM
, CRYPT_OID_INFO_ECC_PARAMETERS_ALGORITHM
},
1383 { 5, szOID_COMMON_NAME
, 0, CN
, NULL
},
1384 { 5, szOID_LOCALITY_NAME
, 0, L
, NULL
},
1385 { 5, szOID_ORGANIZATION_NAME
, 0, O
, NULL
},
1386 { 5, szOID_ORGANIZATIONAL_UNIT_NAME
, 0, OU
, NULL
},
1387 { 5, szOID_RSA_emailAddr
, 0, E
, &ia5StringBlob
},
1388 { 5, szOID_RSA_emailAddr
, 0, Email
, &ia5StringBlob
},
1389 { 5, szOID_COUNTRY_NAME
, 0, C
, &printableStringBlob
},
1390 { 5, szOID_STATE_OR_PROVINCE_NAME
, 0, S
, NULL
},
1391 { 5, szOID_STATE_OR_PROVINCE_NAME
, 0, ST
, NULL
},
1392 { 5, szOID_STREET_ADDRESS
, 0, STREET
, NULL
},
1393 { 5, szOID_TITLE
, 0, T
, NULL
},
1394 { 5, szOID_TITLE
, 0, Title
, NULL
},
1395 { 5, szOID_GIVEN_NAME
, 0, G
, NULL
},
1396 { 5, szOID_GIVEN_NAME
, 0, GN
, NULL
},
1397 { 5, szOID_GIVEN_NAME
, 0, GivenName
, NULL
},
1398 { 5, szOID_INITIALS
, 0, I
, NULL
},
1399 { 5, szOID_INITIALS
, 0, Initials
, NULL
},
1400 { 5, szOID_SUR_NAME
, 0, SN
, NULL
},
1401 { 5, szOID_DOMAIN_COMPONENT
, 0, DC
, &domainCompTypesBlob
},
1402 { 5, szOID_DESCRIPTION
, 0, Description
, NULL
},
1403 { 5, szOID_POSTAL_CODE
, 0, PostalCode
, NULL
},
1404 { 5, szOID_POST_OFFICE_BOX
, 0, POBox
, NULL
},
1405 { 5, szOID_TELEPHONE_NUMBER
, 0, Phone
, &printableStringBlob
},
1406 { 5, szOID_X21_ADDRESS
, 0, X21Address
, &numericStringBlob
},
1407 { 5, szOID_DN_QUALIFIER
, 0, dnQualifier
, NULL
},
1408 { 5, szOID_DEVICE_SERIAL_NUMBER
, 0, SERIALNUMBER
, NULL
},
1410 { 6, szOID_AUTHORITY_KEY_IDENTIFIER2
, 0, (LPCWSTR
)IDS_AUTHORITY_KEY_ID
, NULL
},
1411 { 6, szOID_AUTHORITY_KEY_IDENTIFIER
, 0, (LPCWSTR
)IDS_AUTHORITY_KEY_ID
, NULL
},
1412 { 6, szOID_KEY_ATTRIBUTES
, 0, (LPCWSTR
)IDS_KEY_ATTRIBUTES
, NULL
},
1413 { 6, szOID_KEY_USAGE_RESTRICTION
, 0, (LPCWSTR
)IDS_KEY_USAGE_RESTRICTION
, NULL
},
1414 { 6, szOID_SUBJECT_ALT_NAME2
, 0, (LPCWSTR
)IDS_SUBJECT_ALT_NAME
, NULL
},
1415 { 6, szOID_SUBJECT_ALT_NAME
, 0, (LPCWSTR
)IDS_SUBJECT_ALT_NAME
, NULL
},
1416 { 6, szOID_ISSUER_ALT_NAME2
, 0, (LPCWSTR
)IDS_ISSUER_ALT_NAME
, NULL
},
1417 { 6, szOID_ISSUER_ALT_NAME2
, 0, (LPCWSTR
)IDS_ISSUER_ALT_NAME
, NULL
},
1418 { 6, szOID_BASIC_CONSTRAINTS2
, 0, (LPCWSTR
)IDS_BASIC_CONSTRAINTS
, NULL
},
1419 { 6, szOID_BASIC_CONSTRAINTS
, 0, (LPCWSTR
)IDS_BASIC_CONSTRAINTS
, NULL
},
1420 { 6, szOID_KEY_USAGE
, 0, (LPCWSTR
)IDS_KEY_USAGE
, NULL
},
1421 { 6, szOID_CERT_POLICIES
, 0, (LPCWSTR
)IDS_CERT_POLICIES
, NULL
},
1422 { 6, szOID_SUBJECT_KEY_IDENTIFIER
, 0, (LPCWSTR
)IDS_SUBJECT_KEY_IDENTIFIER
, NULL
},
1423 { 6, szOID_CRL_REASON_CODE
, 0, (LPCWSTR
)IDS_CRL_REASON_CODE
, NULL
},
1424 { 6, szOID_CRL_DIST_POINTS
, 0, (LPCWSTR
)IDS_CRL_DIST_POINTS
, NULL
},
1425 { 6, szOID_ENHANCED_KEY_USAGE
, 0, (LPCWSTR
)IDS_ENHANCED_KEY_USAGE
, NULL
},
1426 { 6, szOID_AUTHORITY_INFO_ACCESS
, 0, (LPCWSTR
)IDS_AUTHORITY_INFO_ACCESS
, NULL
},
1427 { 6, szOID_CERT_EXTENSIONS
, 0, (LPCWSTR
)IDS_CERT_EXTENSIONS
, NULL
},
1428 { 6, szOID_RSA_certExtensions
, 0, (LPCWSTR
)IDS_CERT_EXTENSIONS
, NULL
},
1429 { 6, szOID_NEXT_UPDATE_LOCATION
, 0, (LPCWSTR
)IDS_NEXT_UPDATE_LOCATION
, NULL
},
1430 { 6, szOID_YESNO_TRUST_ATTR
, 0, (LPCWSTR
)IDS_YES_OR_NO_TRUST
, NULL
},
1431 { 6, szOID_RSA_emailAddr
, 0, (LPCWSTR
)IDS_EMAIL_ADDRESS
, NULL
},
1432 { 6, szOID_RSA_unstructName
, 0, (LPCWSTR
)IDS_UNSTRUCTURED_NAME
, NULL
},
1433 { 6, szOID_RSA_contentType
, 0, (LPCWSTR
)IDS_CONTENT_TYPE
, NULL
},
1434 { 6, szOID_RSA_messageDigest
, 0, (LPCWSTR
)IDS_MESSAGE_DIGEST
, NULL
},
1435 { 6, szOID_RSA_signingTime
, 0, (LPCWSTR
)IDS_SIGNING_TIME
, NULL
},
1436 { 6, szOID_RSA_counterSign
, 0, (LPCWSTR
)IDS_COUNTER_SIGN
, NULL
},
1437 { 6, szOID_RSA_challengePwd
, 0, (LPCWSTR
)IDS_CHALLENGE_PASSWORD
, NULL
},
1438 { 6, szOID_RSA_unstructAddr
, 0, (LPCWSTR
)IDS_UNSTRUCTURED_ADDRESS
, NULL
},
1439 { 6, szOID_RSA_SMIMECapabilities
, 0, (LPCWSTR
)IDS_SMIME_CAPABILITIES
, NULL
},
1440 { 6, szOID_RSA_preferSignedData
, 0, (LPCWSTR
)IDS_PREFER_SIGNED_DATA
, NULL
},
1441 { 6, szOID_PKIX_POLICY_QUALIFIER_CPS
, 0, (LPCWSTR
)IDS_CPS
, NULL
},
1442 { 6, szOID_PKIX_POLICY_QUALIFIER_USERNOTICE
, 0, (LPCWSTR
)IDS_USER_NOTICE
, NULL
},
1443 { 6, szOID_PKIX_OCSP
, 0, (LPCWSTR
)IDS_OCSP
, NULL
},
1444 { 6, szOID_PKIX_CA_ISSUERS
, 0, (LPCWSTR
)IDS_CA_ISSUER
, NULL
},
1445 { 6, szOID_ENROLL_CERTTYPE_EXTENSION
, 0, (LPCWSTR
)IDS_CERT_TEMPLATE_NAME
, NULL
},
1446 { 6, szOID_ENROLL_CERTTYPE_EXTENSION
, 0, (LPCWSTR
)IDS_CERT_TYPE
, NULL
},
1447 { 6, szOID_CERT_MANIFOLD
, 0, (LPCWSTR
)IDS_CERT_MANIFOLD
, NULL
},
1448 { 6, szOID_NETSCAPE_CERT_TYPE
, 0, (LPCWSTR
)IDS_NETSCAPE_CERT_TYPE
, NULL
},
1449 { 6, szOID_NETSCAPE_BASE_URL
, 0, (LPCWSTR
)IDS_NETSCAPE_BASE_URL
, NULL
},
1450 { 6, szOID_NETSCAPE_REVOCATION_URL
, 0, (LPCWSTR
)IDS_NETSCAPE_REVOCATION_URL
, NULL
},
1451 { 6, szOID_NETSCAPE_CA_REVOCATION_URL
, 0, (LPCWSTR
)IDS_NETSCAPE_CA_REVOCATION_URL
, NULL
},
1452 { 6, szOID_NETSCAPE_CERT_RENEWAL_URL
, 0, (LPCWSTR
)IDS_NETSCAPE_CERT_RENEWAL_URL
, NULL
},
1453 { 6, szOID_NETSCAPE_CA_POLICY_URL
, 0, (LPCWSTR
)IDS_NETSCAPE_CA_POLICY_URL
, NULL
},
1454 { 6, szOID_NETSCAPE_SSL_SERVER_NAME
, 0, (LPCWSTR
)IDS_NETSCAPE_SSL_SERVER_NAME
, NULL
},
1455 { 6, szOID_NETSCAPE_COMMENT
, 0, (LPCWSTR
)IDS_NETSCAPE_COMMENT
, NULL
},
1456 { 6, "1.3.6.1.4.1.311.2.1.10", 0, SpcSpAgencyInfo
, NULL
},
1457 { 6, "1.3.6.1.4.1.311.2.1.27", 0, SpcFinancialCriteria
, NULL
},
1458 { 6, "1.3.6.1.4.1.311.2.1.26", 0, SpcMinimalCriteria
, NULL
},
1459 { 6, szOID_COUNTRY_NAME
, 0, (LPCWSTR
)IDS_COUNTRY
, NULL
},
1460 { 6, szOID_ORGANIZATION_NAME
, 0, (LPCWSTR
)IDS_ORGANIZATION
, NULL
},
1461 { 6, szOID_ORGANIZATIONAL_UNIT_NAME
, 0, (LPCWSTR
)IDS_ORGANIZATIONAL_UNIT
, NULL
},
1462 { 6, szOID_COMMON_NAME
, 0, (LPCWSTR
)IDS_COMMON_NAME
, NULL
},
1463 { 6, szOID_LOCALITY_NAME
, 0, (LPCWSTR
)IDS_LOCALITY
, NULL
},
1464 { 6, szOID_STATE_OR_PROVINCE_NAME
, 0, (LPCWSTR
)IDS_STATE_OR_PROVINCE
, NULL
},
1465 { 6, szOID_TITLE
, 0, (LPCWSTR
)IDS_TITLE
, NULL
},
1466 { 6, szOID_GIVEN_NAME
, 0, (LPCWSTR
)IDS_GIVEN_NAME
, NULL
},
1467 { 6, szOID_INITIALS
, 0, (LPCWSTR
)IDS_INITIALS
, NULL
},
1468 { 6, szOID_SUR_NAME
, 0, (LPCWSTR
)IDS_SUR_NAME
, NULL
},
1469 { 6, szOID_DOMAIN_COMPONENT
, 0, (LPCWSTR
)IDS_DOMAIN_COMPONENT
, NULL
},
1470 { 6, szOID_STREET_ADDRESS
, 0, (LPCWSTR
)IDS_STREET_ADDRESS
, NULL
},
1471 { 6, szOID_DEVICE_SERIAL_NUMBER
, 0, (LPCWSTR
)IDS_SERIAL_NUMBER
, NULL
},
1472 { 6, szOID_CERTSRV_CA_VERSION
, 0, (LPCWSTR
)IDS_CA_VERSION
, NULL
},
1473 { 6, szOID_CERTSRV_CROSSCA_VERSION
, 0, (LPCWSTR
)IDS_CROSS_CA_VERSION
, NULL
},
1474 { 6, szOID_SERIALIZED
, 0, (LPCWSTR
)IDS_SERIALIZED_SIG_SERIAL_NUMBER
, NULL
},
1475 { 6, szOID_NT_PRINCIPAL_NAME
, 0, (LPCWSTR
)IDS_PRINCIPAL_NAME
, NULL
},
1476 { 6, szOID_PRODUCT_UPDATE
, 0, (LPCWSTR
)IDS_WINDOWS_PRODUCT_UPDATE
, NULL
},
1477 { 6, szOID_ENROLLMENT_NAME_VALUE_PAIR
, 0, (LPCWSTR
)IDS_ENROLLMENT_NAME_VALUE_PAIR
, NULL
},
1478 { 6, szOID_OS_VERSION
, 0, (LPCWSTR
)IDS_OS_VERSION
, NULL
},
1479 { 6, szOID_ENROLLMENT_CSP_PROVIDER
, 0, (LPCWSTR
)IDS_ENROLLMENT_CSP
, NULL
},
1480 { 6, szOID_CRL_NUMBER
, 0, (LPCWSTR
)IDS_CRL_NUMBER
, NULL
},
1481 { 6, szOID_DELTA_CRL_INDICATOR
, 0, (LPCWSTR
)IDS_DELTA_CRL_INDICATOR
, NULL
},
1482 { 6, szOID_ISSUING_DIST_POINT
, 0, (LPCWSTR
)IDS_ISSUING_DIST_POINT
, NULL
},
1483 { 6, szOID_FRESHEST_CRL
, 0, (LPCWSTR
)IDS_FRESHEST_CRL
, NULL
},
1484 { 6, szOID_NAME_CONSTRAINTS
, 0, (LPCWSTR
)IDS_NAME_CONSTRAINTS
, NULL
},
1485 { 6, szOID_POLICY_MAPPINGS
, 0, (LPCWSTR
)IDS_POLICY_MAPPINGS
, NULL
},
1486 { 6, szOID_LEGACY_POLICY_MAPPINGS
, 0, (LPCWSTR
)IDS_POLICY_MAPPINGS
, NULL
},
1487 { 6, szOID_POLICY_CONSTRAINTS
, 0, (LPCWSTR
)IDS_POLICY_CONSTRAINTS
, NULL
},
1488 { 6, szOID_CROSS_CERT_DIST_POINTS
, 0, (LPCWSTR
)IDS_CROSS_CERT_DIST_POINTS
, NULL
},
1489 { 6, szOID_APPLICATION_CERT_POLICIES
, 0, (LPCWSTR
)IDS_APPLICATION_POLICIES
, NULL
},
1490 { 6, szOID_APPLICATION_POLICY_MAPPINGS
, 0, (LPCWSTR
)IDS_APPLICATION_POLICY_MAPPINGS
, NULL
},
1491 { 6, szOID_APPLICATION_POLICY_CONSTRAINTS
, 0, (LPCWSTR
)IDS_APPLICATION_POLICY_CONSTRAINTS
, NULL
},
1492 { 6, szOID_CT_PKI_DATA
, 0, (LPCWSTR
)IDS_CMC_DATA
, NULL
},
1493 { 6, szOID_CT_PKI_RESPONSE
, 0, (LPCWSTR
)IDS_CMC_RESPONSE
, NULL
},
1494 { 6, szOID_CMC
, 0, (LPCWSTR
)IDS_UNSIGNED_CMC_REQUEST
, NULL
},
1495 { 6, szOID_CMC_STATUS_INFO
, 0, (LPCWSTR
)IDS_CMC_STATUS_INFO
, NULL
},
1496 { 6, szOID_CMC_ADD_EXTENSIONS
, 0, (LPCWSTR
)IDS_CMC_EXTENSIONS
, NULL
},
1497 { 6, szOID_CTL
, 0, (LPCWSTR
)IDS_CMC_ATTRIBUTES
, NULL
},
1498 { 6, szOID_RSA_data
, 0, (LPCWSTR
)IDS_PKCS_7_DATA
, NULL
},
1499 { 6, szOID_RSA_signedData
, 0, (LPCWSTR
)IDS_PKCS_7_SIGNED
, NULL
},
1500 { 6, szOID_RSA_envelopedData
, 0, (LPCWSTR
)IDS_PKCS_7_ENVELOPED
, NULL
},
1501 { 6, szOID_RSA_signEnvData
, 0, (LPCWSTR
)IDS_PKCS_7_SIGNED_ENVELOPED
, NULL
},
1502 { 6, szOID_RSA_digestedData
, 0, (LPCWSTR
)IDS_PKCS_7_DIGESTED
, NULL
},
1503 { 6, szOID_RSA_encryptedData
, 0, (LPCWSTR
)IDS_PKCS_7_ENCRYPTED
, NULL
},
1504 { 6, szOID_CERTSRV_PREVIOUS_CERT_HASH
, 0, (LPCWSTR
)IDS_PREVIOUS_CA_CERT_HASH
, NULL
},
1505 { 6, szOID_CRL_VIRTUAL_BASE
, 0, (LPCWSTR
)IDS_CRL_VIRTUAL_BASE
, NULL
},
1506 { 6, szOID_CRL_NEXT_PUBLISH
, 0, (LPCWSTR
)IDS_CRL_NEXT_PUBLISH
, NULL
},
1507 { 6, szOID_KP_CA_EXCHANGE
, 0, (LPCWSTR
)IDS_CA_EXCHANGE
, NULL
},
1508 { 6, szOID_KP_KEY_RECOVERY_AGENT
, 0, (LPCWSTR
)IDS_KEY_RECOVERY_AGENT
, NULL
},
1509 { 6, szOID_CERTIFICATE_TEMPLATE
, 0, (LPCWSTR
)IDS_CERTIFICATE_TEMPLATE
, NULL
},
1510 { 6, szOID_ENTERPRISE_OID_ROOT
, 0, (LPCWSTR
)IDS_ENTERPRISE_ROOT_OID
, NULL
},
1511 { 6, szOID_RDN_DUMMY_SIGNER
, 0, (LPCWSTR
)IDS_RDN_DUMMY_SIGNER
, NULL
},
1512 { 6, szOID_ARCHIVED_KEY_ATTR
, 0, (LPCWSTR
)IDS_ARCHIVED_KEY_ATTR
, NULL
},
1513 { 6, szOID_CRL_SELF_CDP
, 0, (LPCWSTR
)IDS_CRL_SELF_CDP
, NULL
},
1514 { 6, szOID_REQUIRE_CERT_CHAIN_POLICY
, 0, (LPCWSTR
)IDS_REQUIRE_CERT_CHAIN_POLICY
, NULL
},
1515 { 6, szOID_CMC_TRANSACTION_ID
, 0, (LPCWSTR
)IDS_TRANSACTION_ID
, NULL
},
1516 { 6, szOID_CMC_SENDER_NONCE
, 0, (LPCWSTR
)IDS_SENDER_NONCE
, NULL
},
1517 { 6, szOID_CMC_RECIPIENT_NONCE
, 0, (LPCWSTR
)IDS_RECIPIENT_NONCE
, NULL
},
1518 { 6, szOID_CMC_REG_INFO
, 0, (LPCWSTR
)IDS_REG_INFO
, NULL
},
1519 { 6, szOID_CMC_GET_CERT
, 0, (LPCWSTR
)IDS_GET_CERTIFICATE
, NULL
},
1520 { 6, szOID_CMC_GET_CRL
, 0, (LPCWSTR
)IDS_GET_CRL
, NULL
},
1521 { 6, szOID_CMC_REVOKE_REQUEST
, 0, (LPCWSTR
)IDS_REVOKE_REQUEST
, NULL
},
1522 { 6, szOID_CMC_QUERY_PENDING
, 0, (LPCWSTR
)IDS_QUERY_PENDING
, NULL
},
1523 { 6, szOID_SORTED_CTL
, 0, (LPCWSTR
)IDS_SORTED_CTL
, NULL
},
1524 { 6, szOID_ARCHIVED_KEY_CERT_HASH
, 0, (LPCWSTR
)IDS_ARCHIVED_KEY_CERT_HASH
, NULL
},
1525 { 6, szOID_PRIVATEKEY_USAGE_PERIOD
, 0, (LPCWSTR
)IDS_PRIVATE_KEY_USAGE_PERIOD
, NULL
},
1526 { 6, szOID_REQUEST_CLIENT_INFO
, 0, (LPCWSTR
)IDS_CLIENT_INFORMATION
, NULL
},
1528 { 7, szOID_PKIX_KP_SERVER_AUTH
, 0, (LPCWSTR
)IDS_SERVER_AUTHENTICATION
, NULL
},
1529 { 7, szOID_PKIX_KP_CLIENT_AUTH
, 0, (LPCWSTR
)IDS_CLIENT_AUTHENTICATION
, NULL
},
1530 { 7, szOID_PKIX_KP_CODE_SIGNING
, 0, (LPCWSTR
)IDS_CODE_SIGNING
, NULL
},
1531 { 7, szOID_PKIX_KP_EMAIL_PROTECTION
, 0, (LPCWSTR
)IDS_SECURE_EMAIL
, NULL
},
1532 { 7, szOID_PKIX_KP_TIMESTAMP_SIGNING
, 0, (LPCWSTR
)IDS_TIME_STAMPING
, NULL
},
1533 { 7, szOID_KP_CTL_USAGE_SIGNING
, 0, (LPCWSTR
)IDS_MICROSOFT_TRUST_LIST_SIGNING
, NULL
},
1534 { 7, szOID_KP_TIME_STAMP_SIGNING
, 0, (LPCWSTR
)IDS_MICROSOFT_TIME_STAMPING
, NULL
},
1535 { 7, szOID_PKIX_KP_IPSEC_END_SYSTEM
, 0, (LPCWSTR
)IDS_IPSEC_END_SYSTEM
, NULL
},
1536 { 7, szOID_PKIX_KP_IPSEC_TUNNEL
, 0, (LPCWSTR
)IDS_IPSEC_TUNNEL
, NULL
},
1537 { 7, szOID_PKIX_KP_IPSEC_USER
, 0, (LPCWSTR
)IDS_IPSEC_USER
, NULL
},
1538 { 7, szOID_KP_EFS
, 0, (LPCWSTR
)IDS_EFS
, NULL
},
1539 { 7, szOID_WHQL_CRYPTO
, 0, (LPCWSTR
)IDS_WHQL_CRYPTO
, NULL
},
1540 { 7, szOID_NT5_CRYPTO
, 0, (LPCWSTR
)IDS_NT5_CRYPTO
, NULL
},
1541 { 7, szOID_OEM_WHQL_CRYPTO
, 0, (LPCWSTR
)IDS_OEM_WHQL_CRYPTO
, NULL
},
1542 { 7, szOID_EMBEDDED_NT_CRYPTO
, 0, (LPCWSTR
)IDS_EMBEDDED_NT_CRYPTO
, NULL
},
1543 { 7, szOID_LICENSES
, 0, (LPCWSTR
)IDS_KEY_PACK_LICENSES
, NULL
},
1544 { 7, szOID_LICENSE_SERVER
, 0, (LPCWSTR
)IDS_LICENSE_SERVER
, NULL
},
1545 { 7, szOID_KP_SMARTCARD_LOGON
, 0, (LPCWSTR
)IDS_SMART_CARD_LOGON
, NULL
},
1546 { 7, szOID_DRM
, 0, (LPCWSTR
)IDS_DIGITAL_RIGHTS
, NULL
},
1547 { 7, szOID_KP_QUALIFIED_SUBORDINATION
, 0, (LPCWSTR
)IDS_QUALIFIED_SUBORDINATION
, NULL
},
1548 { 7, szOID_KP_KEY_RECOVERY
, 0, (LPCWSTR
)IDS_KEY_RECOVERY
, NULL
},
1549 { 7, szOID_KP_DOCUMENT_SIGNING
, 0, (LPCWSTR
)IDS_DOCUMENT_SIGNING
, NULL
},
1550 { 7, szOID_IPSEC_KP_IKE_INTERMEDIATE
, 0, (LPCWSTR
)IDS_IPSEC_IKE_INTERMEDIATE
, NULL
},
1551 { 7, szOID_EFS_RECOVERY
, 0, (LPCWSTR
)IDS_FILE_RECOVERY
, NULL
},
1552 { 7, szOID_ROOT_LIST_SIGNER
, 0, (LPCWSTR
)IDS_ROOT_LIST_SIGNER
, NULL
},
1553 { 7, szOID_ANY_APPLICATION_POLICY
, 0, (LPCWSTR
)IDS_ANY_APPLICATION_POLICIES
, NULL
},
1554 { 7, szOID_DS_EMAIL_REPLICATION
, 0, (LPCWSTR
)IDS_DS_EMAIL_REPLICATION
, NULL
},
1555 { 7, szOID_ENROLLMENT_AGENT
, 0, (LPCWSTR
)IDS_ENROLLMENT_AGENT
, NULL
},
1556 { 7, szOID_KP_KEY_RECOVERY_AGENT
, 0, (LPCWSTR
)IDS_KEY_RECOVERY_AGENT
, NULL
},
1557 { 7, szOID_KP_CA_EXCHANGE
, 0, (LPCWSTR
)IDS_CA_EXCHANGE
, NULL
},
1558 { 7, szOID_KP_LIFETIME_SIGNING
, 0, (LPCWSTR
)IDS_LIFETIME_SIGNING
, NULL
},
1560 { 8, szOID_ANY_CERT_POLICY
, 0, (LPCWSTR
)IDS_ANY_CERT_POLICY
, NULL
},
1564 CRYPT_OID_INFO info
;
1568 static struct OIDInfo
*read_oid_info(HKEY root
, char *key_name
, DWORD
*flags
)
1571 DWORD len
, oid_len
, name_len
= 0, extra_len
= 0, cngalgid_len
= 0, cngextra_len
= 0, group_id
= 0;
1572 struct OIDInfo
*info
;
1575 if (RegOpenKeyExA(root
, key_name
, 0, KEY_READ
, &key
))
1578 p
= strchr(key_name
, '!');
1581 group_id
= strtol(p
+ 1, NULL
, 10);
1585 oid_len
= strlen(key_name
) + 1;
1587 RegQueryValueExW(key
, nameW
, NULL
, NULL
, NULL
, &name_len
);
1588 RegQueryValueExW(key
, extraW
, NULL
, NULL
, NULL
, &extra_len
);
1589 RegQueryValueExW(key
, cngalgidW
, NULL
, NULL
, NULL
, &cngalgid_len
);
1590 RegQueryValueExW(key
, cngextraalgidW
, NULL
, NULL
, NULL
, &cngextra_len
);
1592 info
= CryptMemAlloc(sizeof(*info
) + oid_len
+ name_len
+ extra_len
+ cngalgid_len
+ cngextra_len
);
1596 len
= sizeof(*flags
);
1597 RegQueryValueExW(key
, flagsW
, NULL
, NULL
, (BYTE
*)flags
, &len
);
1599 memset(info
, 0, sizeof(*info
));
1600 info
->info
.cbSize
= sizeof(info
->info
);
1602 p
= (char *)(info
+ 1);
1604 info
->info
.pszOID
= p
;
1605 strcpy((char *)info
->info
.pszOID
, key_name
);
1610 info
->info
.pwszName
= (WCHAR
*)p
;
1611 RegQueryValueExW(key
, nameW
, NULL
, NULL
, (BYTE
*)info
->info
.pwszName
, &name_len
);
1615 info
->info
.dwGroupId
= group_id
;
1617 len
= sizeof(info
->info
.u
.Algid
);
1618 RegQueryValueExW(key
, algidW
, NULL
, NULL
, (BYTE
*)&info
->info
.u
.Algid
, &len
);
1622 info
->info
.ExtraInfo
.cbData
= extra_len
;
1623 info
->info
.ExtraInfo
.pbData
= (BYTE
*)p
;
1624 RegQueryValueExW(key
, extraW
, NULL
, NULL
, info
->info
.ExtraInfo
.pbData
, &extra_len
);
1630 info
->info
.pwszCNGAlgid
= (WCHAR
*)p
;
1631 RegQueryValueExW(key
, cngalgidW
, NULL
, NULL
, (BYTE
*)info
->info
.pwszCNGAlgid
, &cngalgid_len
);
1637 info
->info
.pwszCNGExtraAlgid
= (WCHAR
*)p
;
1638 RegQueryValueExW(key
, cngextraalgidW
, NULL
, NULL
, (BYTE
*)info
->info
.pwszCNGExtraAlgid
, &cngalgid_len
);
1647 static void init_registered_oid_info(void)
1652 err
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
, "Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptDllFindOIDInfo",
1653 0, KEY_ALL_ACCESS
, &root
);
1654 if (err
!= ERROR_SUCCESS
) return;
1659 char key_name
[MAX_PATH
];
1660 struct OIDInfo
*info
;
1663 err
= RegEnumKeyA(root
, idx
++, key_name
, MAX_PATH
);
1664 if (err
== ERROR_NO_MORE_ITEMS
)
1667 if (err
== ERROR_SUCCESS
)
1669 if ((info
= read_oid_info(root
, key_name
, &flags
)))
1671 TRACE("adding oid %s, name %s, groupid %u, algid %u, extra %u, CNG algid %s, CNG extra %s\n",
1672 debugstr_a(info
->info
.pszOID
), debugstr_w(info
->info
.pwszName
),
1673 info
->info
.dwGroupId
, info
->info
.u
.Algid
, info
->info
.ExtraInfo
.cbData
,
1674 debugstr_w(info
->info
.pwszCNGAlgid
), debugstr_w(info
->info
.pwszCNGExtraAlgid
));
1676 if (flags
& CRYPT_INSTALL_OID_INFO_BEFORE_FLAG
)
1677 list_add_head(&oidInfo
, &info
->entry
);
1679 list_add_tail(&oidInfo
, &info
->entry
);
1687 static void init_oid_info(void)
1691 oid_init_localizednames();
1692 for (i
= 0; i
< ARRAY_SIZE(oidInfoConstructors
); i
++)
1694 if (!IS_INTRESOURCE(oidInfoConstructors
[i
].pwszName
))
1696 struct OIDInfo
*info
;
1698 /* The name is a static string, so just use the same pointer */
1699 info
= CryptMemAlloc(sizeof(struct OIDInfo
));
1702 memset(info
, 0, sizeof(*info
));
1703 info
->info
.cbSize
= sizeof(CRYPT_OID_INFO
);
1704 info
->info
.pszOID
= oidInfoConstructors
[i
].pszOID
;
1705 info
->info
.pwszName
= oidInfoConstructors
[i
].pwszName
;
1706 info
->info
.dwGroupId
= oidInfoConstructors
[i
].dwGroupId
;
1707 info
->info
.u
.Algid
= oidInfoConstructors
[i
].Algid
;
1708 if (oidInfoConstructors
[i
].blob
)
1710 info
->info
.ExtraInfo
.cbData
=
1711 oidInfoConstructors
[i
].blob
->cbData
;
1712 info
->info
.ExtraInfo
.pbData
=
1713 oidInfoConstructors
[i
].blob
->pbData
;
1715 info
->info
.pwszCNGAlgid
= oidInfoConstructors
[i
].pwszCNGAlgid
;
1716 info
->info
.pwszCNGExtraAlgid
= oidInfoConstructors
[i
].pwszCNGExtraAlgid
;
1717 list_add_tail(&oidInfo
, &info
->entry
);
1722 LPCWSTR stringresource
;
1723 int len
= LoadStringW(hInstance
,
1724 (UINT_PTR
)oidInfoConstructors
[i
].pwszName
,
1725 (LPWSTR
)&stringresource
, 0);
1729 struct OIDInfo
*info
= CryptMemAlloc(sizeof(struct OIDInfo
) +
1730 (len
+ 1) * sizeof(WCHAR
));
1734 memset(info
, 0, sizeof(*info
));
1735 info
->info
.cbSize
= sizeof(CRYPT_OID_INFO
);
1736 info
->info
.pszOID
= oidInfoConstructors
[i
].pszOID
;
1737 info
->info
.pwszName
= (LPWSTR
)(info
+ 1);
1738 info
->info
.dwGroupId
= oidInfoConstructors
[i
].dwGroupId
;
1739 info
->info
.u
.Algid
= oidInfoConstructors
[i
].Algid
;
1740 memcpy(info
+ 1, stringresource
, len
*sizeof(WCHAR
));
1741 ((LPWSTR
)(info
+ 1))[len
] = 0;
1742 if (oidInfoConstructors
[i
].blob
)
1744 info
->info
.ExtraInfo
.cbData
=
1745 oidInfoConstructors
[i
].blob
->cbData
;
1746 info
->info
.ExtraInfo
.pbData
=
1747 oidInfoConstructors
[i
].blob
->pbData
;
1749 info
->info
.pwszCNGAlgid
= oidInfoConstructors
[i
].pwszCNGAlgid
;
1750 info
->info
.pwszCNGExtraAlgid
= oidInfoConstructors
[i
].pwszCNGExtraAlgid
;
1751 list_add_tail(&oidInfo
, &info
->entry
);
1758 static void free_oid_info(void)
1760 struct OIDInfo
*info
, *next
;
1762 LIST_FOR_EACH_ENTRY_SAFE(info
, next
, &oidInfo
, struct OIDInfo
, entry
)
1764 list_remove(&info
->entry
);
1767 DeleteCriticalSection(&oidInfoCS
);
1770 /***********************************************************************
1771 * CryptEnumOIDInfo (CRYPT32.@)
1773 BOOL WINAPI
CryptEnumOIDInfo(DWORD dwGroupId
, DWORD dwFlags
, void *pvArg
,
1774 PFN_CRYPT_ENUM_OID_INFO pfnEnumOIDInfo
)
1777 struct OIDInfo
*info
;
1779 TRACE("(%d, %08x, %p, %p)\n", dwGroupId
, dwFlags
, pvArg
,
1782 EnterCriticalSection(&oidInfoCS
);
1783 LIST_FOR_EACH_ENTRY(info
, &oidInfo
, struct OIDInfo
, entry
)
1785 if (!dwGroupId
|| dwGroupId
== info
->info
.dwGroupId
)
1787 ret
= pfnEnumOIDInfo(&info
->info
, pvArg
);
1792 LeaveCriticalSection(&oidInfoCS
);
1796 PCCRYPT_OID_INFO WINAPI
CryptFindOIDInfo(DWORD dwKeyType
, void *pvKey
,
1799 PCCRYPT_OID_INFO ret
= NULL
;
1801 TRACE("(%d, %p, %d)\n", dwKeyType
, pvKey
, dwGroupId
);
1805 case CRYPT_OID_INFO_ALGID_KEY
:
1807 struct OIDInfo
*info
;
1809 TRACE("CRYPT_OID_INFO_ALGID_KEY: %d\n", *(DWORD
*)pvKey
);
1810 EnterCriticalSection(&oidInfoCS
);
1811 LIST_FOR_EACH_ENTRY(info
, &oidInfo
, struct OIDInfo
, entry
)
1813 if (info
->info
.u
.Algid
== *(DWORD
*)pvKey
&&
1814 (!dwGroupId
|| info
->info
.dwGroupId
== dwGroupId
))
1820 LeaveCriticalSection(&oidInfoCS
);
1823 case CRYPT_OID_INFO_NAME_KEY
:
1825 struct OIDInfo
*info
;
1827 TRACE("CRYPT_OID_INFO_NAME_KEY: %s\n", debugstr_w(pvKey
));
1828 EnterCriticalSection(&oidInfoCS
);
1829 LIST_FOR_EACH_ENTRY(info
, &oidInfo
, struct OIDInfo
, entry
)
1831 if (!lstrcmpW(info
->info
.pwszName
, pvKey
) &&
1832 (!dwGroupId
|| info
->info
.dwGroupId
== dwGroupId
))
1838 LeaveCriticalSection(&oidInfoCS
);
1841 case CRYPT_OID_INFO_OID_KEY
:
1843 struct OIDInfo
*info
;
1846 TRACE("CRYPT_OID_INFO_OID_KEY: %s\n", debugstr_a(oid
));
1847 EnterCriticalSection(&oidInfoCS
);
1848 LIST_FOR_EACH_ENTRY(info
, &oidInfo
, struct OIDInfo
, entry
)
1850 if (!lstrcmpA(info
->info
.pszOID
, oid
) &&
1851 (!dwGroupId
|| info
->info
.dwGroupId
== dwGroupId
))
1857 LeaveCriticalSection(&oidInfoCS
);
1860 case CRYPT_OID_INFO_SIGN_KEY
:
1862 struct OIDInfo
*info
;
1864 TRACE("CRYPT_OID_INFO_SIGN_KEY: %d\n", *(DWORD
*)pvKey
);
1865 EnterCriticalSection(&oidInfoCS
);
1866 LIST_FOR_EACH_ENTRY(info
, &oidInfo
, struct OIDInfo
, entry
)
1868 if (info
->info
.u
.Algid
== *(DWORD
*)pvKey
&&
1869 info
->info
.ExtraInfo
.cbData
>= sizeof(DWORD
) &&
1870 *(DWORD
*)info
->info
.ExtraInfo
.pbData
==
1871 *(DWORD
*)((LPBYTE
)pvKey
+ sizeof(DWORD
)) &&
1872 (!dwGroupId
|| info
->info
.dwGroupId
== dwGroupId
))
1878 LeaveCriticalSection(&oidInfoCS
);
1885 LPCSTR WINAPI
CertAlgIdToOID(DWORD dwAlgId
)
1888 PCCRYPT_OID_INFO info
= CryptFindOIDInfo(CRYPT_OID_INFO_ALGID_KEY
,
1898 DWORD WINAPI
CertOIDToAlgId(LPCSTR pszObjId
)
1901 PCCRYPT_OID_INFO info
= CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY
,
1902 (void *)pszObjId
, 0);
1905 ret
= info
->u
.Algid
;
1911 void crypt_oid_init(void)
1914 init_registered_oid_info();
1917 void crypt_oid_free(void)
1919 free_function_sets();