ReactOS 0.4.17-dev-470-gf9e3448
oid.c File Reference
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#include "wincrypt.h"
#include "winreg.h"
#include "winternl.h"
#include "winuser.h"
#include "wine/debug.h"
#include "wine/list.h"
#include "crypt32_private.h"
#include "cryptres.h"
Include dependency graph for oid.c:

Go to the source code of this file.

Classes

struct  OIDFunctionSet
 
struct  OIDFunction
 
struct  FuncAddr
 
struct  OIDInfoConstructor
 
struct  OIDInfo
 

Macros

#define CRYPT_OID_INFO_HAS_EXTRA_FIELDS
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (crypt)
 
static void free_function_sets (void)
 
HCRYPTOIDFUNCSET WINAPI CryptInitOIDFunctionSet (LPCSTR pszFuncName, DWORD dwFlags)
 
static charCRYPT_GetKeyName (DWORD dwEncodingType, LPCSTR pszFuncName, LPCSTR pszOID)
 
BOOL WINAPI CryptGetDefaultOIDDllList (HCRYPTOIDFUNCSET hFuncSet, DWORD dwEncodingType, LPWSTR pwszDllList, DWORD *pcchDllList)
 
BOOL WINAPI CryptInstallOIDFunctionAddress (HMODULE hModule, DWORD dwEncodingType, LPCSTR pszFuncName, DWORD cFuncEntry, const CRYPT_OID_FUNC_ENTRY rgFuncEntry[], DWORD dwFlags)
 
static BOOL CRYPT_GetFuncFromReg (DWORD dwEncodingType, LPCSTR pszOID, LPCSTR szFuncName, LPVOID *ppvFuncAddr, HCRYPTOIDFUNCADDR *phFuncAddr)
 
BOOL WINAPI CryptGetOIDFunctionAddress (HCRYPTOIDFUNCSET hFuncSet, DWORD dwEncodingType, LPCSTR pszOID, DWORD dwFlags, void **ppvFuncAddr, HCRYPTOIDFUNCADDR *phFuncAddr)
 
static BOOL is_module_registered (HMODULE hModule)
 
BOOL WINAPI CryptFreeOIDFunctionAddress (HCRYPTOIDFUNCADDR hFuncAddr, DWORD dwFlags)
 
static BOOL CRYPT_GetFuncFromDll (LPCWSTR dll, LPCSTR func, HMODULE *lib, void **ppvFuncAddr)
 
BOOL WINAPI CryptGetDefaultOIDFunctionAddress (HCRYPTOIDFUNCSET hFuncSet, DWORD dwEncodingType, LPCWSTR pwszDll, DWORD dwFlags, void **ppvFuncAddr, HCRYPTOIDFUNCADDR *phFuncAddr)
 
BOOL WINAPI CryptRegisterOIDFunction (DWORD dwEncodingType, LPCSTR pszFuncName, LPCSTR pszOID, LPCWSTR pwszDll, LPCSTR pszOverrideFuncName)
 
BOOL WINAPI CryptUnregisterOIDInfo (PCCRYPT_OID_INFO info)
 
BOOL WINAPI CryptRegisterOIDInfo (PCCRYPT_OID_INFO info, DWORD flags)
 
BOOL WINAPI CryptUnregisterOIDFunction (DWORD dwEncodingType, LPCSTR pszFuncName, LPCSTR pszOID)
 
BOOL WINAPI CryptGetOIDFunctionValue (DWORD dwEncodingType, LPCSTR pszFuncName, LPCSTR pszOID, LPCWSTR pwszValueName, DWORD *pdwValueType, BYTE *pbValueData, DWORD *pcbValueData)
 
BOOL WINAPI CryptSetOIDFunctionValue (DWORD dwEncodingType, LPCSTR pszFuncName, LPCSTR pszOID, LPCWSTR pwszValueName, DWORD dwValueType, const BYTE *pbValueData, DWORD cbValueData)
 
static LPCWSTR CRYPT_FindStringInMultiString (LPCWSTR multi, LPCWSTR toFind)
 
static DWORD CRYPT_GetMultiStringCharacterLen (LPCWSTR multi)
 
static LPWSTR CRYPT_AddStringToMultiString (LPWSTR multi, LPCWSTR toAdd, DWORD index)
 
static BOOL CRYPT_RemoveStringFromMultiString (LPWSTR multi, LPCWSTR toRemove)
 
static BOOL CRYPT_GetDefaultOIDKey (DWORD dwEncodingType, LPCSTR pszFuncName, PHKEY key)
 
static LPWSTR CRYPT_GetDefaultOIDDlls (HKEY key)
 
static BOOL CRYPT_SetDefaultOIDDlls (HKEY key, LPCWSTR dlls)
 
BOOL WINAPI CryptRegisterDefaultOIDFunction (DWORD dwEncodingType, LPCSTR pszFuncName, DWORD dwIndex, LPCWSTR pwszDll)
 
BOOL WINAPI CryptUnregisterDefaultOIDFunction (DWORD dwEncodingType, LPCSTR pszFuncName, LPCWSTR pwszDll)
 
static void oid_init_localizednames (void)
 
LPCWSTR WINAPI CryptFindLocalizedName (LPCWSTR pwszCryptName)
 
static struct OIDInforead_oid_info (HKEY root, char *key_name, DWORD *flags)
 
static void init_registered_oid_info (void)
 
static void init_oid_info (void)
 
static void free_oid_info (void)
 
BOOL WINAPI CryptEnumOIDInfo (DWORD dwGroupId, DWORD dwFlags, void *pvArg, PFN_CRYPT_ENUM_OID_INFO pfnEnumOIDInfo)
 
PCCRYPT_OID_INFO WINAPI CryptFindOIDInfo (DWORD dwKeyType, void *pvKey, DWORD dwGroupId)
 
LPCSTR WINAPI CertAlgIdToOID (DWORD dwAlgId)
 
DWORD WINAPI CertOIDToAlgId (LPCSTR pszObjId)
 
void crypt_oid_init (void)
 
void crypt_oid_free (void)
 

Variables

static CRITICAL_SECTION funcSetCS = { &funcSetCSDebug, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG funcSetCSDebug
 
static struct list funcSets = { &funcSets, &funcSets }
 
static const LPCWSTR LocalizedKeys []
 
static WCHAR LocalizedNames [ARRAY_SIZE(LocalizedKeys)][256]
 
static CRITICAL_SECTION oidInfoCS = { &oidInfoCSDebug, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG oidInfoCSDebug
 
static struct list oidInfo = { &oidInfo, &oidInfo }
 
static const DWORD noNullFlag = CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG
 
static const DWORD mosaicFlags
 
static const CRYPT_DATA_BLOB noNullBlob
 
static const CRYPT_DATA_BLOB mosaicFlagsBlob
 
static const DWORD rsaSign = CALG_RSA_SIGN
 
static const DWORD dssSign [2]
 
static const DWORD mosaicSign [2]
 
static const DWORD ecdsaSign [2] = { CALG_OID_INFO_PARAMETERS, CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG }
 
static const CRYPT_DATA_BLOB rsaSignBlob
 
static const CRYPT_DATA_BLOB dssSignBlob
 
static const CRYPT_DATA_BLOB mosaicSignBlob
 
static const CRYPT_DATA_BLOB ecdsaSignBlob = { sizeof(ecdsaSign), (BYTE *)ecdsaSign }
 
static const DWORD ia5String [] = { CERT_RDN_IA5_STRING, 0 }
 
static const DWORD numericString [] = { CERT_RDN_NUMERIC_STRING, 0 }
 
static const DWORD printableString [] = { CERT_RDN_PRINTABLE_STRING, 0 }
 
static const DWORD domainCompTypes []
 
static const CRYPT_DATA_BLOB ia5StringBlob
 
static const CRYPT_DATA_BLOB numericStringBlob
 
static const CRYPT_DATA_BLOB printableStringBlob
 
static const CRYPT_DATA_BLOB domainCompTypesBlob
 
static const struct OIDInfoConstructor oidInfoConstructors []
 

Macro Definition Documentation

◆ CRYPT_OID_INFO_HAS_EXTRA_FIELDS

#define CRYPT_OID_INFO_HAS_EXTRA_FIELDS

Definition at line 27 of file oid.c.

Function Documentation

◆ CertAlgIdToOID()

LPCSTR WINAPI CertAlgIdToOID ( DWORD  dwAlgId)

Definition at line 1803 of file oid.c.

1804{
1805 LPCSTR ret;
1807 &dwAlgId, 0);
1808
1809 if (info)
1810 ret = info->pszOID;
1811 else
1812 ret = NULL;
1813 return ret;
1814}
#define NULL
Definition: types.h:112
PCCRYPT_OID_INFO WINAPI CryptFindOIDInfo(DWORD dwKeyType, void *pvKey, DWORD dwGroupId)
Definition: oid.c:1714
return ret
Definition: mutex.c:146
const char * LPCSTR
Definition: typedefs.h:52
#define CRYPT_OID_INFO_ALGID_KEY
Definition: wincrypt.h:1957

Referenced by CRYPT_EncodePKCSDigestedData(), CRYPT_ExportPublicKeyInfoEx(), and test_AlgIDToOID().

◆ CertOIDToAlgId()

DWORD WINAPI CertOIDToAlgId ( LPCSTR  pszObjId)

◆ CRYPT_AddStringToMultiString()

static LPWSTR CRYPT_AddStringToMultiString ( LPWSTR  multi,
LPCWSTR  toAdd,
DWORD  index 
)
static

Definition at line 946 of file oid.c.

948{
949 LPWSTR ret;
950
951 if (!multi)
952 {
953 /* FIXME: ignoring index, is that okay? */
954 ret = CryptMemAlloc((lstrlenW(toAdd) + 2) * sizeof(WCHAR));
955 if (ret)
956 {
957 /* copy string, including NULL terminator */
958 memcpy(ret, toAdd, (lstrlenW(toAdd) + 1) * sizeof(WCHAR));
959 /* add terminating empty string */
960 *(ret + lstrlenW(toAdd) + 1) = 0;
961 }
962 }
963 else
964 {
966
967 ret = CryptMemRealloc(multi, (len + lstrlenW(toAdd) + 1) *
968 sizeof(WCHAR));
969 if (ret)
970 {
971 LPWSTR spotToAdd;
972
974 spotToAdd = ret + len - 1;
975 else
976 {
977 DWORD i;
978
979 /* FIXME: if index is too large for the string, toAdd is
980 * added to the end. Is that okay?
981 */
982 for (i = 0, spotToAdd = ret; i < index && *spotToAdd;
983 spotToAdd += lstrlenW(spotToAdd) + 1)
984 ;
985 }
986 if (spotToAdd)
987 {
988 /* Copy existing string "right" */
989 memmove(spotToAdd + lstrlenW(toAdd) + 1, spotToAdd,
990 (len - (spotToAdd - ret)) * sizeof(WCHAR));
991 /* Copy new string */
992 memcpy(spotToAdd, toAdd, (lstrlenW(toAdd) + 1) * sizeof(WCHAR));
993 }
994 else
995 {
997 ret = NULL;
998 }
999 }
1000 }
1001 return ret;
1002}
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:136
LPVOID WINAPI CryptMemRealloc(LPVOID pv, ULONG cbSize)
Definition: main.c:141
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:146
static DWORD CRYPT_GetMultiStringCharacterLen(LPCWSTR multi)
Definition: oid.c:928
#define lstrlenW
Definition: compat.h:750
GLuint index
Definition: glext.h:6031
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
short WCHAR
Definition: pedump.c:58
uint16_t * LPWSTR
Definition: typedefs.h:56
#define CRYPT_REGISTER_LAST_INDEX
Definition: wincrypt.h:2706

Referenced by CryptRegisterDefaultOIDFunction().

◆ CRYPT_FindStringInMultiString()

static LPCWSTR CRYPT_FindStringInMultiString ( LPCWSTR  multi,
LPCWSTR  toFind 
)
static

Definition at line 916 of file oid.c.

917{
918 LPCWSTR ret = NULL, ptr;
919
920 for (ptr = multi; ptr && *ptr && !ret; ptr += lstrlenW(ptr) + 1)
921 {
922 if (!lstrcmpiW(ptr, toFind))
923 ret = ptr;
924 }
925 return ret;
926}
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4171
static PVOID ptr
Definition: dispmode.c:27
const uint16_t * LPCWSTR
Definition: typedefs.h:57

Referenced by CRYPT_RemoveStringFromMultiString(), and CryptRegisterDefaultOIDFunction().

◆ CRYPT_GetDefaultOIDDlls()

static LPWSTR CRYPT_GetDefaultOIDDlls ( HKEY  key)
static

Definition at line 1061 of file oid.c.

1062{
1063 LONG r;
1064 DWORD type, size;
1065 LPWSTR dlls;
1066
1067 r = RegQueryValueExW(key, L"Dll", NULL, &type, NULL, &size);
1068 if (r == ERROR_SUCCESS && type == REG_MULTI_SZ)
1069 {
1071 r = RegQueryValueExW(key, L"Dll", NULL, &type, (LPBYTE)dlls, &size);
1072 if (r != ERROR_SUCCESS)
1073 {
1075 dlls = NULL;
1076 }
1077 }
1078 else
1079 dlls = NULL;
1080 return dlls;
1081}
static struct list dlls
Definition: apartment.c:63
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define L(x)
Definition: resources.c:13
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLsizeiptr size
Definition: glext.h:5919
#define REG_MULTI_SZ
Definition: nt_native.h:1504
long LONG
Definition: pedump.c:60
Definition: copy.c:22
unsigned char * LPBYTE
Definition: typedefs.h:53

Referenced by CryptRegisterDefaultOIDFunction(), and CryptUnregisterDefaultOIDFunction().

◆ CRYPT_GetDefaultOIDKey()

static BOOL CRYPT_GetDefaultOIDKey ( DWORD  dwEncodingType,
LPCSTR  pszFuncName,
PHKEY  key 
)
static

Definition at line 1038 of file oid.c.

1040{
1041 LPSTR keyName;
1042 LONG r;
1043
1044 keyName = CRYPT_GetKeyName(dwEncodingType, pszFuncName, "DEFAULT");
1045 TRACE("Key name is %s\n", debugstr_a(keyName));
1046
1047 if (!keyName)
1048 return FALSE;
1049
1051 NULL, key, NULL);
1052 CryptMemFree(keyName);
1053 if (r != ERROR_SUCCESS)
1054 {
1055 SetLastError(r);
1056 return FALSE;
1057 }
1058 return TRUE;
1059}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegCreateKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD Reserved, _In_ LPSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_ LPDWORD lpdwDisposition)
Definition: reg.c:1034
static char * CRYPT_GetKeyName(DWORD dwEncodingType, LPCSTR pszFuncName, LPCSTR pszOID)
Definition: oid.c:146
#define SetLastError(x)
Definition: compat.h:752
#define debugstr_a
Definition: kernel32.h:31
#define KEY_ALL_ACCESS
Definition: nt_native.h:1044
#define TRACE(s)
Definition: solgame.cpp:4
char * LPSTR
Definition: typedefs.h:51
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by CryptRegisterDefaultOIDFunction(), and CryptUnregisterDefaultOIDFunction().

◆ CRYPT_GetFuncFromDll()

static BOOL CRYPT_GetFuncFromDll ( LPCWSTR  dll,
LPCSTR  func,
HMODULE lib,
void **  ppvFuncAddr 
)
static

Definition at line 479 of file oid.c.

481{
482 BOOL ret = FALSE;
483
484 *lib = LoadLibraryW(dll);
485 if (*lib)
486 {
487 *ppvFuncAddr = GetProcAddress(*lib, func);
488 if (*ppvFuncAddr)
489 ret = TRUE;
490 else
491 {
492 FreeLibrary(*lib);
493 *lib = NULL;
494 }
495 }
496 return ret;
497}
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
unsigned int BOOL
Definition: ntddk_ex.h:94
GLenum func
Definition: glext.h:6028

Referenced by CryptGetDefaultOIDFunctionAddress().

◆ CRYPT_GetFuncFromReg()

static BOOL CRYPT_GetFuncFromReg ( DWORD  dwEncodingType,
LPCSTR  pszOID,
LPCSTR  szFuncName,
LPVOID ppvFuncAddr,
HCRYPTOIDFUNCADDR phFuncAddr 
)
static

Definition at line 286 of file oid.c.

288{
289 BOOL ret = FALSE;
290 char *keyName;
291 const char *funcName;
292 HKEY key;
293 LSTATUS rc;
294
295 keyName = CRYPT_GetKeyName(dwEncodingType, szFuncName, pszOID);
296 rc = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keyName, 0, KEY_READ, &key);
297 if (!rc)
298 {
299 DWORD type, size = 0;
300
301 rc = RegQueryValueExA(key, "FuncName", NULL, &type, NULL, &size);
302 if ((!rc || rc == ERROR_MORE_DATA) && type == REG_SZ)
303 {
304 funcName = CryptMemAlloc(size);
305 rc = RegQueryValueExA(key, "FuncName", NULL, &type,
306 (LPBYTE)funcName, &size);
307 }
308 else
309 funcName = szFuncName;
310 rc = RegQueryValueExW(key, L"Dll", NULL, &type, NULL, &size);
311 if ((!rc || rc == ERROR_MORE_DATA) && type == REG_SZ)
312 {
313 LPWSTR dllName = CryptMemAlloc(size);
314
315 if (dllName)
316 {
317 rc = RegQueryValueExW(key, L"Dll", NULL, NULL,
318 (LPBYTE)dllName, &size);
319 if (!rc)
320 {
321 HMODULE lib;
322
323 /* This is a bit of a hack; MSDN describes a more
324 * complicated unload routine than this will allow.
325 * Still, this seems to suffice for now.
326 */
327 lib = LoadLibraryW(dllName);
328 if (lib)
329 {
330 *ppvFuncAddr = GetProcAddress(lib, funcName);
331 if (*ppvFuncAddr)
332 {
333 struct FuncAddr *addr =
334 CryptMemAlloc(sizeof(struct FuncAddr));
335
336 if (addr)
337 {
338 addr->lib = lib;
339 addr->dllList = addr->currentDll = NULL;
340 *phFuncAddr = addr;
341 ret = TRUE;
342 }
343 else
344 {
345 *phFuncAddr = NULL;
347 }
348 }
349 else
350 {
351 /* Unload the library, the caller doesn't want
352 * to unload it when the return value is NULL.
353 */
355 }
356 }
357 }
358 else
359 SetLastError(rc);
360 CryptMemFree(dllName);
361 }
362 }
363 else
364 SetLastError(rc);
365 if (funcName != szFuncName)
366 CryptMemFree((char *)funcName);
368 }
369 else
370 SetLastError(rc);
371 CryptMemFree(keyName);
372 return ret;
373}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_MORE_DATA
Definition: dderror.h:13
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3298
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4009
GLenum const GLvoid * addr
Definition: glext.h:9621
#define REG_SZ
Definition: layer.c:22
#define KEY_READ
Definition: nt_native.h:1026
Definition: oid.c:280
HMODULE lib
Definition: oid.c:281

Referenced by CryptGetOIDFunctionAddress().

◆ CRYPT_GetKeyName()

static char * CRYPT_GetKeyName ( DWORD  dwEncodingType,
LPCSTR  pszFuncName,
LPCSTR  pszOID 
)
static

Definition at line 146 of file oid.c.

148{
149 static const char szEncodingTypeFmt[] =
150 "Software\\Microsoft\\Cryptography\\OID\\EncodingType %ld\\%s\\%s";
151 UINT len;
152 char numericOID[7]; /* enough for "#65535" */
153 const char *oid;
154 LPSTR szKey;
155
156 /* MSDN says the encoding type is a mask, but it isn't treated that way.
157 * (E.g., if dwEncodingType were 3, the key names "EncodingType 1" and
158 * "EncodingType 2" would be expected if it were a mask. Instead native
159 * stores values in "EncodingType 3".
160 */
161 if (IS_INTOID(pszOID))
162 {
163 snprintf(numericOID, sizeof(numericOID), "#%d", LOWORD(pszOID));
164 oid = numericOID;
165 }
166 else
167 oid = pszOID;
168
169 /* This is enough: the lengths of the two string parameters are explicitly
170 * counted, and we need up to five additional characters for the encoding
171 * type. These are covered by the "%d", "%s", and "%s" characters in the
172 * format specifier that are removed by sprintf.
173 */
174 len = sizeof(szEncodingTypeFmt) + lstrlenA(pszFuncName) + lstrlenA(oid);
175 szKey = CryptMemAlloc(len);
176 if (szKey)
177 sprintf(szKey, szEncodingTypeFmt,
178 GET_CERT_ENCODING_TYPE(dwEncodingType), pszFuncName, oid);
179 return szKey;
180}
#define IS_INTOID(x)
unsigned int UINT
Definition: sysinfo.c:13
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define sprintf
Definition: sprintf.c:45
#define LOWORD(l)
Definition: pedump.c:82
#define GET_CERT_ENCODING_TYPE(x)
Definition: wincrypt.h:2496
#define snprintf
Definition: wintirpc.h:48

Referenced by CRYPT_GetDefaultOIDKey(), CRYPT_GetFuncFromReg(), CryptGetDefaultOIDDllList(), CryptGetOIDFunctionValue(), CryptRegisterOIDFunction(), CryptSetOIDFunctionValue(), and CryptUnregisterOIDFunction().

◆ CRYPT_GetMultiStringCharacterLen()

static DWORD CRYPT_GetMultiStringCharacterLen ( LPCWSTR  multi)
static

Definition at line 928 of file oid.c.

929{
930 DWORD ret;
931
932 if (multi)
933 {
934 LPCWSTR ptr;
935
936 /* Count terminating empty string */
937 ret = 1;
938 for (ptr = multi; *ptr; ptr += lstrlenW(ptr) + 1)
939 ret += lstrlenW(ptr) + 1;
940 }
941 else
942 ret = 0;
943 return ret;
944}

Referenced by CRYPT_AddStringToMultiString(), CRYPT_RemoveStringFromMultiString(), and CRYPT_SetDefaultOIDDlls().

◆ crypt_oid_free()

void crypt_oid_free ( void  )

Definition at line 1835 of file oid.c.

1836{
1838 free_oid_info();
1839}
static void free_oid_info(void)
Definition: oid.c:1676
static void free_function_sets(void)
Definition: oid.c:76

Referenced by DllMain().

◆ crypt_oid_init()

void crypt_oid_init ( void  )

Definition at line 1829 of file oid.c.

1830{
1831 init_oid_info();
1833}
static void init_oid_info(void)
Definition: oid.c:1605
static void init_registered_oid_info(void)
Definition: oid.c:1565

Referenced by DllMain().

◆ CRYPT_RemoveStringFromMultiString()

static BOOL CRYPT_RemoveStringFromMultiString ( LPWSTR  multi,
LPCWSTR  toRemove 
)
static

Definition at line 1004 of file oid.c.

1005{
1006 LPWSTR spotToRemove = (LPWSTR)CRYPT_FindStringInMultiString(multi,
1007 toRemove);
1008 BOOL ret;
1009
1010 if (spotToRemove)
1011 {
1013
1014 if (spotToRemove + lstrlenW(toRemove) + 2 >= multi + len)
1015 {
1016 /* Removing last string in list, terminate multi string directly */
1017 *spotToRemove = 0;
1018 *(spotToRemove + 1) = 0;
1019 }
1020 else
1021 {
1022 LPCWSTR nextStr = spotToRemove + lstrlenW(toRemove) + 1;
1023
1024 /* Copy remainder of string "left" */
1025 memmove(spotToRemove, nextStr,
1026 (len - (nextStr - multi)) * sizeof(WCHAR));
1027 }
1028 ret = TRUE;
1029 }
1030 else
1031 {
1033 ret = FALSE;
1034 }
1035 return ret;
1036}
static LPCWSTR CRYPT_FindStringInMultiString(LPCWSTR multi, LPCWSTR toFind)
Definition: oid.c:916
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79

Referenced by CryptUnregisterDefaultOIDFunction().

◆ CRYPT_SetDefaultOIDDlls()

static BOOL CRYPT_SetDefaultOIDDlls ( HKEY  key,
LPCWSTR  dlls 
)
inlinestatic

Definition at line 1083 of file oid.c.

1084{
1086 LONG r;
1087
1088 if ((r = RegSetValueExW(key, L"Dll", 0, REG_MULTI_SZ, (const BYTE *)dlls,
1089 len * sizeof (WCHAR))))
1090 SetLastError(r);
1091 return r == ERROR_SUCCESS;
1092}
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
unsigned char BYTE
Definition: xxhash.c:193

Referenced by CryptRegisterDefaultOIDFunction(), and CryptUnregisterDefaultOIDFunction().

◆ CryptEnumOIDInfo()

BOOL WINAPI CryptEnumOIDInfo ( DWORD  dwGroupId,
DWORD  dwFlags,
void pvArg,
PFN_CRYPT_ENUM_OID_INFO  pfnEnumOIDInfo 
)

Definition at line 1691 of file oid.c.

1693{
1694 BOOL ret = TRUE;
1695 struct OIDInfo *info;
1696
1697 TRACE("(%ld, %08lx, %p, %p)\n", dwGroupId, dwFlags, pvArg,
1698 pfnEnumOIDInfo);
1699
1702 {
1703 if (!dwGroupId || dwGroupId == info->info.dwGroupId)
1704 {
1705 ret = pfnEnumOIDInfo(&info->info, pvArg);
1706 if (!ret)
1707 break;
1708 }
1709 }
1711 return ret;
1712}
static struct list oidInfo
Definition: oid.c:1194
static CRITICAL_SECTION oidInfoCS
Definition: oid.c:1186
uint32_t entry
Definition: isohybrid.c:63
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
Definition: oid.c:1481
CRYPT_OID_INFO info
Definition: oid.c:1482
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

Referenced by PrintOID(), test_enumOIDInfo(), and WTHelperGetKnownUsages().

◆ CryptFindLocalizedName()

LPCWSTR WINAPI CryptFindLocalizedName ( LPCWSTR  pwszCryptName)

Definition at line 1170 of file oid.c.

1171{
1172 unsigned int i;
1173
1174 for(i = 0; i < ARRAY_SIZE(LocalizedKeys); i++)
1175 {
1176 if(!lstrcmpiW(LocalizedKeys[i], pwszCryptName))
1177 {
1178 return LocalizedNames[i];
1179 }
1180 }
1181
1182 FIXME("No name for: %s - stub\n",debugstr_w(pwszCryptName));
1183 return NULL;
1184}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
static const LPCWSTR LocalizedKeys[]
Definition: oid.c:65
static WCHAR LocalizedNames[ARRAY_SIZE(LocalizedKeys)][256]
Definition: oid.c:74
#define debugstr_w
Definition: kernel32.h:32

Referenced by CStore::CStore(), enum_store_callback(), and show_cert_stores().

◆ CryptFindOIDInfo()

PCCRYPT_OID_INFO WINAPI CryptFindOIDInfo ( DWORD  dwKeyType,
void pvKey,
DWORD  dwGroupId 
)

Definition at line 1714 of file oid.c.

1716{
1718
1719 TRACE("(%ld, %p, %ld)\n", dwKeyType, pvKey, dwGroupId);
1720
1721 switch(dwKeyType)
1722 {
1724 {
1725 struct OIDInfo *info;
1726
1727 TRACE("CRYPT_OID_INFO_ALGID_KEY: %ld\n", *(DWORD *)pvKey);
1730 {
1731 if (info->info.Algid == *(DWORD *)pvKey &&
1732 (!dwGroupId || info->info.dwGroupId == dwGroupId))
1733 {
1734 ret = &info->info;
1735 break;
1736 }
1737 }
1739 break;
1740 }
1742 {
1743 struct OIDInfo *info;
1744
1745 TRACE("CRYPT_OID_INFO_NAME_KEY: %s\n", debugstr_w(pvKey));
1748 {
1749 if (!wcscmp(info->info.pwszName, pvKey) &&
1750 (!dwGroupId || info->info.dwGroupId == dwGroupId))
1751 {
1752 ret = &info->info;
1753 break;
1754 }
1755 }
1757 break;
1758 }
1760 {
1761 struct OIDInfo *info;
1762 LPSTR oid = pvKey;
1763
1764 TRACE("CRYPT_OID_INFO_OID_KEY: %s\n", debugstr_a(oid));
1767 {
1768 if (!lstrcmpA(info->info.pszOID, oid) &&
1769 (!dwGroupId || info->info.dwGroupId == dwGroupId))
1770 {
1771 ret = &info->info;
1772 break;
1773 }
1774 }
1776 break;
1777 }
1779 {
1780 struct OIDInfo *info;
1781
1782 TRACE("CRYPT_OID_INFO_SIGN_KEY: %ld\n", *(DWORD *)pvKey);
1785 {
1786 if (info->info.Algid == *(DWORD *)pvKey &&
1787 info->info.ExtraInfo.cbData >= sizeof(DWORD) &&
1788 *(DWORD *)info->info.ExtraInfo.pbData ==
1789 *(DWORD *)((LPBYTE)pvKey + sizeof(DWORD)) &&
1790 (!dwGroupId || info->info.dwGroupId == dwGroupId))
1791 {
1792 ret = &info->info;
1793 break;
1794 }
1795 }
1797 break;
1798 }
1799 }
1800 return ret;
1801}
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4104
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1977
#define CRYPT_OID_INFO_SIGN_KEY
Definition: wincrypt.h:1958
#define CRYPT_OID_INFO_NAME_KEY
Definition: wincrypt.h:1956

Referenced by add_cert_extension_detail(), add_oid_text_to_control(), cert_name_to_str_with_indent(), CertAlgIdToOID(), CertGetPublicKeyLength(), CertOIDToAlgId(), CertStrToNameW(), CRYPT_FormatEnhancedKeyUsage(), CRYPT_VerifyCertSignatureFromPublicKeyInfo(), CryptHashToBeSigned(), CryptSignCertificate(), field_format_public_key(), find_oid_in_list(), get_cert_usages(), initialize_purpose_selection(), request_query_option(), show_cert_usages(), test_findOIDInfo(), and test_registerOIDInfo().

◆ CryptFreeOIDFunctionAddress()

BOOL WINAPI CryptFreeOIDFunctionAddress ( HCRYPTOIDFUNCADDR  hFuncAddr,
DWORD  dwFlags 
)

Definition at line 456 of file oid.c.

458{
459 TRACE("(%p, %08lx)\n", hFuncAddr, dwFlags);
460
461 /* FIXME: as MSDN states, need to check for DllCanUnloadNow in the DLL,
462 * and only unload it if it can be unloaded. Also need to implement ref
463 * counting on the functions.
464 */
465 if (hFuncAddr)
466 {
467 struct FuncAddr *addr = hFuncAddr;
468
469 if (!is_module_registered(addr->lib))
470 {
471 CryptMemFree(addr->dllList);
472 FreeLibrary(addr->lib);
474 }
475 }
476 return TRUE;
477}
static BOOL is_module_registered(HMODULE hModule)
Definition: oid.c:424

Referenced by CertVerifyCertificateChainPolicy(), CertVerifyRevocation(), CRYPT_ExportEncryptedKey(), CRYPT_ExportPublicKeyInfoEx(), CRYPT_GenKey(), CRYPT_ImportEncryptedKey(), CRYPT_ImportPublicKeyInfoEx(), CRYPT_ProvOpenStore(), CryptDecodeObjectEx(), CryptEncodeObject(), CryptEncodeObjectEx(), CryptExportPublicKeyInfoEx(), CryptFormatObject(), CryptGetDefaultOIDFunctionAddress(), CryptGetObjectUrl(), CryptImportPublicKeyInfoEx(), CryptRetrieveObjectByUrlW(), and test_installOIDFunctionAddress().

◆ CryptGetDefaultOIDDllList()

BOOL WINAPI CryptGetDefaultOIDDllList ( HCRYPTOIDFUNCSET  hFuncSet,
DWORD  dwEncodingType,
LPWSTR  pwszDllList,
DWORD pcchDllList 
)

Definition at line 182 of file oid.c.

184{
185 struct OIDFunctionSet *set = hFuncSet;
186 char *keyName;
187 HKEY key;
188 LSTATUS rc;
189
190 TRACE("(%p, %ld, %p, %p)\n", hFuncSet, dwEncodingType, pwszDllList,
191 pcchDllList);
192
193 keyName = CRYPT_GetKeyName(dwEncodingType, set->name, "DEFAULT");
194 rc = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keyName, 0, NULL, 0,
195 KEY_READ, NULL, &key, NULL);
196 if (!rc)
197 {
198 DWORD size = *pcchDllList * sizeof(WCHAR);
199
200 rc = RegQueryValueExW(key, L"Dll", NULL, NULL, (LPBYTE)pwszDllList,
201 &size);
202 if (!rc)
203 *pcchDllList = size / sizeof(WCHAR);
204 else
205 {
206 /* No value, return an empty list */
207 if (pwszDllList && *pcchDllList)
208 *pwszDllList = '\0';
209 *pcchDllList = 1;
210 }
212 }
213 else
214 {
215 /* No value, return an empty list */
216 if (pwszDllList && *pcchDllList)
217 *pwszDllList = '\0';
218 *pcchDllList = 1;
219 }
220 CryptMemFree(keyName);
221
222 return TRUE;
223}
Definition: _set.h:50

Referenced by CertVerifyRevocation(), CryptGetDefaultOIDFunctionAddress(), and test_oidFunctionSet().

◆ CryptGetDefaultOIDFunctionAddress()

BOOL WINAPI CryptGetDefaultOIDFunctionAddress ( HCRYPTOIDFUNCSET  hFuncSet,
DWORD  dwEncodingType,
LPCWSTR  pwszDll,
DWORD  dwFlags,
void **  ppvFuncAddr,
HCRYPTOIDFUNCADDR phFuncAddr 
)

Definition at line 499 of file oid.c.

502{
503 struct OIDFunctionSet *set = hFuncSet;
504 BOOL ret = FALSE;
505
506 TRACE("(%p, %ld, %s, %08lx, %p, %p)\n", hFuncSet, dwEncodingType,
507 debugstr_w(pwszDll), dwFlags, ppvFuncAddr, phFuncAddr);
508
509 if (pwszDll)
510 {
511 HMODULE lib;
512
513 *phFuncAddr = NULL;
514 ret = CRYPT_GetFuncFromDll(pwszDll, set->name, &lib, ppvFuncAddr);
515 if (ret)
516 {
517 struct FuncAddr *addr = CryptMemAlloc(sizeof(struct FuncAddr));
518
519 if (addr)
520 {
521 addr->lib = lib;
522 addr->dllList = addr->currentDll = NULL;
523 *phFuncAddr = addr;
524 }
525 else
526 {
528 *ppvFuncAddr = NULL;
530 ret = FALSE;
531 }
532 }
533 else
535 }
536 else
537 {
538 struct FuncAddr *addr = *phFuncAddr;
539
540 if (!addr)
541 {
542 DWORD size;
543
544 ret = CryptGetDefaultOIDDllList(hFuncSet, dwEncodingType, NULL,
545 &size);
546 if (ret)
547 {
549
550 if (dllList)
551 {
552 ret = CryptGetDefaultOIDDllList(hFuncSet, dwEncodingType,
553 dllList, &size);
554 if (ret)
555 {
556 addr = CryptMemAlloc(sizeof(struct FuncAddr));
557 if (addr)
558 {
559 addr->dllList = dllList;
560 addr->currentDll = dllList;
561 addr->lib = NULL;
562 *phFuncAddr = addr;
563 }
564 else
565 {
568 ret = FALSE;
569 }
570 }
571 }
572 else
573 {
575 ret = FALSE;
576 }
577 }
578 }
579 if (addr)
580 {
581 if (!*addr->currentDll)
582 {
583 CryptFreeOIDFunctionAddress(*phFuncAddr, 0);
585 *phFuncAddr = NULL;
586 ret = FALSE;
587 }
588 else
589 {
590 /* FIXME: as elsewhere, can't free until DllCanUnloadNow says
591 * it's possible, and should defer unloading for some time to
592 * avoid repeated LoadLibrary/FreeLibrary on the same dll.
593 */
594 FreeLibrary(addr->lib);
595 ret = CRYPT_GetFuncFromDll(addr->currentDll, set->name,
596 &addr->lib, ppvFuncAddr);
597 if (ret)
598 {
599 /* Move past the current DLL */
600 addr->currentDll += lstrlenW(addr->currentDll) + 1;
601 *phFuncAddr = addr;
602 }
603 else
604 {
605 CryptFreeOIDFunctionAddress(*phFuncAddr, 0);
607 *phFuncAddr = NULL;
608 }
609 }
610 }
611 }
612 return ret;
613}
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
BOOL WINAPI CryptGetDefaultOIDDllList(HCRYPTOIDFUNCSET hFuncSet, DWORD dwEncodingType, LPWSTR pwszDllList, DWORD *pcchDllList)
Definition: oid.c:182
static BOOL CRYPT_GetFuncFromDll(LPCWSTR dll, LPCSTR func, HMODULE *lib, void **ppvFuncAddr)
Definition: oid.c:479
BOOL WINAPI CryptFreeOIDFunctionAddress(HCRYPTOIDFUNCADDR hFuncAddr, DWORD dwFlags)
Definition: oid.c:456
LPWSTR dllList
Definition: oid.c:282

Referenced by CertVerifyRevocation(), and test_getDefaultOIDFunctionAddress().

◆ CryptGetOIDFunctionAddress()

BOOL WINAPI CryptGetOIDFunctionAddress ( HCRYPTOIDFUNCSET  hFuncSet,
DWORD  dwEncodingType,
LPCSTR  pszOID,
DWORD  dwFlags,
void **  ppvFuncAddr,
HCRYPTOIDFUNCADDR phFuncAddr 
)

Definition at line 375 of file oid.c.

378{
379 BOOL ret = FALSE;
380 struct OIDFunctionSet *set = hFuncSet;
381
382 TRACE("(%p, %ld, %s, %08lx, %p, %p)\n", hFuncSet, dwEncodingType,
383 debugstr_a(pszOID), dwFlags, ppvFuncAddr, phFuncAddr);
384
385 *ppvFuncAddr = NULL;
387 {
388 struct OIDFunction *function;
389
391 LIST_FOR_EACH_ENTRY(function, &set->functions, struct OIDFunction, next)
392 {
393 if (function->encoding == GET_CERT_ENCODING_TYPE(dwEncodingType))
394 {
395 if (!IS_INTOID(pszOID))
396 {
397 if (!IS_INTOID(function->entry.pszOID) &&
398 !stricmp(function->entry.pszOID, pszOID))
399 {
400 *ppvFuncAddr = function->entry.pvFuncAddr;
401 *phFuncAddr = NULL; /* FIXME: what should it be? */
402 ret = TRUE;
403 break;
404 }
405 }
406 else if (function->entry.pszOID == pszOID)
407 {
408 *ppvFuncAddr = function->entry.pvFuncAddr;
409 *phFuncAddr = NULL; /* FIXME: what should it be? */
410 ret = TRUE;
411 break;
412 }
413 }
414 }
416 }
417 if (!*ppvFuncAddr)
418 ret = CRYPT_GetFuncFromReg(dwEncodingType, pszOID, set->name,
419 ppvFuncAddr, phFuncAddr);
420 TRACE("returning %d\n", ret);
421 return ret;
422}
static BOOL CRYPT_GetFuncFromReg(DWORD dwEncodingType, LPCSTR pszOID, LPCSTR szFuncName, LPVOID *ppvFuncAddr, HCRYPTOIDFUNCADDR *phFuncAddr)
Definition: oid.c:286
#define stricmp(_String1, _String2)
Definition: compat.h:24
static unsigned __int64 next
Definition: rand_nt.c:6
CRYPT_OID_FUNC_ENTRY entry
Definition: oid.c:61
DWORD encoding
Definition: oid.c:60
void * pvFuncAddr
Definition: wincrypt.h:1570
LPCSTR pszOID
Definition: wincrypt.h:1569
#define CRYPT_GET_INSTALLED_OID_FUNC_FLAG
Definition: wincrypt.h:2703

Referenced by CertVerifyCertificateChainPolicy(), CRYPT_ExportEncryptedKey(), CRYPT_ExportPublicKeyInfoEx(), CRYPT_GenKey(), CRYPT_GetCreateFunction(), CRYPT_GetRetrieveFunction(), CRYPT_ImportEncryptedKey(), CRYPT_ImportPublicKeyInfoEx(), CRYPT_LoadDecoderExFunc(), CRYPT_LoadDecoderFunc(), CRYPT_LoadEncoderExFunc(), CRYPT_LoadEncoderFunc(), CRYPT_ProvOpenStore(), CryptExportPublicKeyInfoEx(), CryptFormatObject(), CryptGetObjectUrl(), CryptImportPublicKeyInfoEx(), test_installOIDFunctionAddress(), test_oidFunctionSet(), and test_verify_ecc_signature().

◆ CryptGetOIDFunctionValue()

BOOL WINAPI CryptGetOIDFunctionValue ( DWORD  dwEncodingType,
LPCSTR  pszFuncName,
LPCSTR  pszOID,
LPCWSTR  pwszValueName,
DWORD pdwValueType,
BYTE pbValueData,
DWORD pcbValueData 
)

Definition at line 842 of file oid.c.

845{
846 LPSTR szKey;
847 LONG rc;
848 HKEY hKey;
849
850 TRACE("%lx %s %s %s %p %p %p\n", dwEncodingType, debugstr_a(pszFuncName),
851 debugstr_a(pszOID), debugstr_w(pwszValueName), pdwValueType, pbValueData,
852 pcbValueData);
853
854 if (!GET_CERT_ENCODING_TYPE(dwEncodingType))
855 return TRUE;
856
857 if (!pszFuncName || !pszOID || !pwszValueName)
858 {
860 return FALSE;
861 }
862
863 szKey = CRYPT_GetKeyName(dwEncodingType, pszFuncName, pszOID);
864 rc = RegOpenKeyA(HKEY_LOCAL_MACHINE, szKey, &hKey);
865 CryptMemFree(szKey);
866 if (rc)
867 SetLastError(rc);
868 else
869 {
870 rc = RegQueryValueExW(hKey, pwszValueName, NULL, pdwValueType,
871 pbValueData, pcbValueData);
872 if (rc)
873 SetLastError(rc);
875 }
876 return !rc;
877}
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3234
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
FxAutoRegKey hKey
_In_z_ PCWSTR pwszValueName
Definition: ntuser.h:42

◆ CryptInitOIDFunctionSet()

HCRYPTOIDFUNCSET WINAPI CryptInitOIDFunctionSet ( LPCSTR  pszFuncName,
DWORD  dwFlags 
)

Definition at line 103 of file oid.c.

105{
106 struct OIDFunctionSet *cursor, *ret = NULL;
107
108 TRACE("(%s, %lx)\n", debugstr_a(pszFuncName), dwFlags);
109
112 {
113 if (!stricmp(pszFuncName, cursor->name))
114 {
115 ret = cursor;
116 break;
117 }
118 }
119 if (!ret)
120 {
121 ret = CryptMemAlloc(sizeof(struct OIDFunctionSet));
122 if (ret)
123 {
124 memset(ret, 0, sizeof(*ret));
125 ret->name = CryptMemAlloc(strlen(pszFuncName) + 1);
126 if (ret->name)
127 {
129 ret->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": OIDFunctionSet.cs");
130 list_init(&ret->functions);
131 strcpy(ret->name, pszFuncName);
132 list_add_tail(&funcSets, &ret->next);
133 }
134 else
135 {
137 ret = NULL;
138 }
139 }
140 }
142
143 return ret;
144}
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
static void list_init(struct list_entry *head)
Definition: list.h:51
static CRITICAL_SECTION funcSetCS
Definition: oid.c:39
static struct list funcSets
Definition: oid.c:47
BOOL WINAPI InitializeCriticalSectionEx(OUT LPCRITICAL_SECTION lpCriticalSection, IN DWORD dwSpinCount, IN DWORD flags)
Definition: sync.c:107
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
const char cursor[]
Definition: icontest.c:13
strcpy
Definition: string.h:131
#define memset(x, y, z)
Definition: compat.h:39
#define DWORD_PTR
Definition: treelist.c:76
#define RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO
Definition: winnt_old.h:1156

Referenced by CertVerifyCertificateChainPolicy(), CertVerifyRevocation(), CRYPT_ExportEncryptedKey(), CRYPT_ExportPublicKeyInfoEx(), CRYPT_GenKey(), CRYPT_GetCreateFunction(), CRYPT_GetRetrieveFunction(), CRYPT_ImportEncryptedKey(), CRYPT_ImportPublicKeyInfoEx(), CRYPT_LoadDecoderExFunc(), CRYPT_LoadDecoderFunc(), CRYPT_LoadEncoderExFunc(), CRYPT_LoadEncoderFunc(), CRYPT_ProvOpenStore(), CryptExportPublicKeyInfoEx(), CryptFormatObject(), CryptGetObjectUrl(), CryptImportPublicKeyInfoEx(), CryptInstallOIDFunctionAddress(), test_getDefaultOIDFunctionAddress(), test_installOIDFunctionAddress(), test_oidFunctionSet(), and test_verify_ecc_signature().

◆ CryptInstallOIDFunctionAddress()

BOOL WINAPI CryptInstallOIDFunctionAddress ( HMODULE  hModule,
DWORD  dwEncodingType,
LPCSTR  pszFuncName,
DWORD  cFuncEntry,
const CRYPT_OID_FUNC_ENTRY  rgFuncEntry[],
DWORD  dwFlags 
)

Definition at line 225 of file oid.c.

228{
229 BOOL ret = TRUE;
230 struct OIDFunctionSet *set;
231
232 TRACE("(%p, %ld, %s, %ld, %p, %08lx)\n", hModule, dwEncodingType,
233 debugstr_a(pszFuncName), cFuncEntry, rgFuncEntry, dwFlags);
234
235 set = CryptInitOIDFunctionSet(pszFuncName, 0);
236 if (set)
237 {
238 DWORD i;
239
241 for (i = 0; ret && i < cFuncEntry; i++)
242 {
243 struct OIDFunction *func;
244
245 TRACE("OID %s, func %p\n", debugstr_a(rgFuncEntry[i].pszOID), rgFuncEntry[i].pvFuncAddr);
246
247 if (!IS_INTOID(rgFuncEntry[i].pszOID))
248 func = CryptMemAlloc(sizeof(struct OIDFunction)
249 + strlen(rgFuncEntry[i].pszOID) + 1);
250 else
251 func = CryptMemAlloc(sizeof(struct OIDFunction));
252 if (func)
253 {
254 func->encoding = GET_CERT_ENCODING_TYPE(dwEncodingType);
255 if (!IS_INTOID(rgFuncEntry[i].pszOID))
256 {
257 LPSTR oid;
258
259 oid = (LPSTR)((LPBYTE)func + sizeof(*func));
260 strcpy(oid, rgFuncEntry[i].pszOID);
261 func->entry.pszOID = oid;
262 }
263 else
264 func->entry.pszOID = rgFuncEntry[i].pszOID;
265 func->entry.pvFuncAddr = rgFuncEntry[i].pvFuncAddr;
266 func->hModule = hModule;
267 list_add_tail(&set->functions, &func->next);
268 }
269 else
270 ret = FALSE;
271 }
273 }
274 else
275 ret = FALSE;
276 return ret;
277}
HMODULE hModule
Definition: animate.c:44
HCRYPTOIDFUNCSET WINAPI CryptInitOIDFunctionSet(LPCSTR pszFuncName, DWORD dwFlags)
Definition: oid.c:103

Referenced by test_installOIDFunctionAddress().

◆ CryptRegisterDefaultOIDFunction()

BOOL WINAPI CryptRegisterDefaultOIDFunction ( DWORD  dwEncodingType,
LPCSTR  pszFuncName,
DWORD  dwIndex,
LPCWSTR  pwszDll 
)

Definition at line 1097 of file oid.c.

1099{
1100 HKEY key;
1101 LPWSTR dlls;
1102 BOOL ret = FALSE;
1103
1104 TRACE("(%lx, %s, %ld, %s)\n", dwEncodingType, debugstr_a(pszFuncName),
1105 dwIndex, debugstr_w(pwszDll));
1106
1107 if (!pwszDll)
1108 {
1110 return FALSE;
1111 }
1112
1113 if (!CRYPT_GetDefaultOIDKey(dwEncodingType, pszFuncName, &key))
1114 return FALSE;
1115
1117 if (CRYPT_FindStringInMultiString(dlls, pwszDll))
1119 else
1120 {
1121 dlls = CRYPT_AddStringToMultiString(dlls, pwszDll, dwIndex);
1122 if (dlls)
1124 }
1127 return ret;
1128}
#define E_INVALIDARG
Definition: ddrawi.h:101
static LPWSTR CRYPT_AddStringToMultiString(LPWSTR multi, LPCWSTR toAdd, DWORD index)
Definition: oid.c:946
static BOOL CRYPT_GetDefaultOIDKey(DWORD dwEncodingType, LPCSTR pszFuncName, PHKEY key)
Definition: oid.c:1038
static BOOL CRYPT_SetDefaultOIDDlls(HKEY key, LPCWSTR dlls)
Definition: oid.c:1083
static LPWSTR CRYPT_GetDefaultOIDDlls(HKEY key)
Definition: oid.c:1061
#define ERROR_FILE_EXISTS
Definition: winerror.h:287

Referenced by DllRegisterServer(), test_getDefaultOIDFunctionAddress(), and test_registerDefaultOIDFunction().

◆ CryptRegisterOIDFunction()

BOOL WINAPI CryptRegisterOIDFunction ( DWORD  dwEncodingType,
LPCSTR  pszFuncName,
LPCSTR  pszOID,
LPCWSTR  pwszDll,
LPCSTR  pszOverrideFuncName 
)

Definition at line 635 of file oid.c.

637{
638 LONG r;
639 HKEY hKey;
640 LPSTR szKey;
641
642 TRACE("(%lx, %s, %s, %s, %s)\n", dwEncodingType, debugstr_a(pszFuncName),
643 debugstr_a(pszOID), debugstr_w(pwszDll), debugstr_a(pszOverrideFuncName));
644
645 /* Native does nothing pwszDll is NULL */
646 if (!pwszDll)
647 return TRUE;
648
649 /* I'm not matching MS bug for bug here, because I doubt any app depends on
650 * it: native "succeeds" if pszFuncName is NULL, but the nonsensical entry
651 * it creates would never be used.
652 */
653 if (!pszFuncName || !pszOID)
654 {
656 return FALSE;
657 }
658
659 szKey = CRYPT_GetKeyName(dwEncodingType, pszFuncName, pszOID);
660 TRACE("Key name is %s\n", debugstr_a(szKey));
661
662 if (!szKey)
663 return FALSE;
664
666 CryptMemFree(szKey);
667
668 if (r != ERROR_SUCCESS) goto error_close_key;
669
670 /* write the values */
671 if (pszOverrideFuncName)
672 {
673 r = RegSetValueExA(hKey, "FuncName", 0, REG_SZ,
674 (const BYTE*)pszOverrideFuncName, lstrlenA(pszOverrideFuncName) + 1);
675 if (r != ERROR_SUCCESS) goto error_close_key;
676 }
677 r = RegSetValueExW(hKey, L"Dll", 0, REG_SZ, (const BYTE*) pwszDll,
678 (lstrlenW(pwszDll) + 1) * sizeof (WCHAR));
679
680error_close_key:
681
683
684 if (r != ERROR_SUCCESS)
685 {
687 return FALSE;
688 }
689
690 return TRUE;
691}
LONG WINAPI RegCreateKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1179
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4799

Referenced by DllRegisterServer(), and test_registerOIDFunction().

◆ CryptRegisterOIDInfo()

BOOL WINAPI CryptRegisterOIDInfo ( PCCRYPT_OID_INFO  info,
DWORD  flags 
)

Definition at line 738 of file oid.c.

739{
740 char *key_name;
741 HKEY root = 0, key = 0;
742 DWORD err;
743
744 TRACE("(%p, %lx)\n", info, flags );
745
746 if (!info || info->cbSize != sizeof(*info) || !info->pszOID)
747 {
749 return FALSE;
750 }
751
752 if (!info->dwGroupId) return TRUE;
753
754 key_name = CryptMemAlloc(strlen(info->pszOID) + 16);
755 if (!key_name)
756 {
758 goto done;
759 }
760
761 err = RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptDllFindOIDInfo",
762 0, NULL, 0, KEY_ALL_ACCESS, NULL, &root, NULL);
763 if (err != ERROR_SUCCESS) goto done;
764
765 sprintf(key_name, "%s!%lu", info->pszOID, info->dwGroupId);
767 if (err != ERROR_SUCCESS) goto done;
768
769 if (flags)
770 {
771 err = RegSetValueExW(key, L"Flags", 0, REG_DWORD, (const BYTE *)&flags, sizeof(flags));
772 if (err != ERROR_SUCCESS) goto done;
773 }
774
775 if (info->pwszName)
776 {
777 err = RegSetValueExW(key, L"Name", 0, REG_SZ, (const BYTE *)info->pwszName, (lstrlenW(info->pwszName) + 1) * sizeof(WCHAR));
778 if (err != ERROR_SUCCESS) goto done;
779 }
780
781 if (info->Algid)
782 {
783 err = RegSetValueExW(key, L"Algid", 0, REG_DWORD, (const BYTE *)&info->Algid, sizeof(info->Algid));
784 if (err != ERROR_SUCCESS) goto done;
785 }
786
787 if (info->ExtraInfo.cbData && info->ExtraInfo.pbData)
788 {
789 err = RegSetValueExW(key, L"ExtraInfo", 0, REG_BINARY, info->ExtraInfo.pbData, info->ExtraInfo.cbData);
790 if (err != ERROR_SUCCESS) goto done;
791 }
792
793 if (info->pwszCNGAlgid)
794 {
795 err = RegSetValueExW(key, L"CNGAlgid", 0, REG_SZ, (const BYTE *)info->pwszCNGAlgid, (lstrlenW(info->pwszCNGAlgid) + 1) * sizeof(WCHAR));
796 if (err != ERROR_SUCCESS) goto done;
797 }
798
799 if (info->pwszCNGExtraAlgid)
800 {
801 err = RegSetValueExW(key, L"CNGExtraAlgid", 0, REG_SZ, (const BYTE *)info->pwszCNGExtraAlgid, (lstrlenW(info->pwszCNGExtraAlgid) + 1) * sizeof(WCHAR));
802 if (err != ERROR_SUCCESS) goto done;
803 }
804
805done:
807 if (key) RegCloseKey(key);
808 if (root) RegCloseKey(root);
809
810 if (err)
812
813 return !err;
814}
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
GLbitfield flags
Definition: glext.h:7161
#define REG_BINARY
Definition: nt_native.h:1499
#define err(...)
#define REG_DWORD
Definition: sdbapi.c:615

Referenced by test_registerOIDInfo().

◆ CryptSetOIDFunctionValue()

BOOL WINAPI CryptSetOIDFunctionValue ( DWORD  dwEncodingType,
LPCSTR  pszFuncName,
LPCSTR  pszOID,
LPCWSTR  pwszValueName,
DWORD  dwValueType,
const BYTE pbValueData,
DWORD  cbValueData 
)

Definition at line 879 of file oid.c.

882{
883 LPSTR szKey;
884 LONG rc;
885 HKEY hKey;
886
887 TRACE("%lx %s %s %s %ld %p %ld\n", dwEncodingType, debugstr_a(pszFuncName),
888 debugstr_a(pszOID), debugstr_w(pwszValueName), dwValueType, pbValueData,
889 cbValueData);
890
891 if (!GET_CERT_ENCODING_TYPE(dwEncodingType))
892 return TRUE;
893
894 if (!pszFuncName || !pszOID || !pwszValueName)
895 {
897 return FALSE;
898 }
899
900 szKey = CRYPT_GetKeyName(dwEncodingType, pszFuncName, pszOID);
901 rc = RegOpenKeyA(HKEY_LOCAL_MACHINE, szKey, &hKey);
902 CryptMemFree(szKey);
903 if (rc)
904 SetLastError(rc);
905 else
906 {
907 rc = RegSetValueExW(hKey, pwszValueName, 0, dwValueType, pbValueData,
908 cbValueData);
909 if (rc)
910 SetLastError(rc);
912 }
913 return !rc;
914}

◆ CryptUnregisterDefaultOIDFunction()

BOOL WINAPI CryptUnregisterDefaultOIDFunction ( DWORD  dwEncodingType,
LPCSTR  pszFuncName,
LPCWSTR  pwszDll 
)

Definition at line 1130 of file oid.c.

1132{
1133 HKEY key;
1134 LPWSTR dlls;
1135 BOOL ret;
1136
1137 TRACE("(%lx, %s, %s)\n", dwEncodingType, debugstr_a(pszFuncName),
1138 debugstr_w(pwszDll));
1139
1140 if (!pwszDll)
1141 {
1143 return FALSE;
1144 }
1145
1146 if (!CRYPT_GetDefaultOIDKey(dwEncodingType, pszFuncName, &key))
1147 return FALSE;
1148
1150 if ((ret = CRYPT_RemoveStringFromMultiString(dlls, pwszDll)))
1154 return ret;
1155}
static BOOL CRYPT_RemoveStringFromMultiString(LPWSTR multi, LPCWSTR toRemove)
Definition: oid.c:1004

Referenced by DllUnregisterServer(), test_getDefaultOIDFunctionAddress(), and test_registerDefaultOIDFunction().

◆ CryptUnregisterOIDFunction()

BOOL WINAPI CryptUnregisterOIDFunction ( DWORD  dwEncodingType,
LPCSTR  pszFuncName,
LPCSTR  pszOID 
)

Definition at line 819 of file oid.c.

821{
822 LPSTR szKey;
823 LONG rc;
824
825 TRACE("%lx %s %s\n", dwEncodingType, debugstr_a(pszFuncName),
826 debugstr_a(pszOID));
827
828 if (!pszFuncName || !pszOID)
829 {
831 return FALSE;
832 }
833
834 szKey = CRYPT_GetKeyName(dwEncodingType, pszFuncName, pszOID);
836 CryptMemFree(szKey);
837 if (rc)
838 SetLastError(rc);
839 return !rc;
840}
LONG WINAPI RegDeleteKeyA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey)
Definition: reg.c:1224

Referenced by DllUnregisterServer(), and test_registerOIDFunction().

◆ CryptUnregisterOIDInfo()

BOOL WINAPI CryptUnregisterOIDInfo ( PCCRYPT_OID_INFO  info)

Definition at line 696 of file oid.c.

697{
698 char *key_name;
699 HKEY root;
700 DWORD err;
701
702 TRACE("(%p)\n", info);
703
704 if (!info || info->cbSize != sizeof(*info) || !info->pszOID)
705 {
707 return FALSE;
708 }
709
710 err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptDllFindOIDInfo", 0, KEY_ALL_ACCESS, &root);
711 if (err != ERROR_SUCCESS)
712 {
714 return FALSE;
715 }
716
717 key_name = CryptMemAlloc(strlen(info->pszOID) + 16);
718 if (key_name)
719 {
720 sprintf(key_name, "%s!%lu", info->pszOID, info->dwGroupId);
722 }
723 else
725
728
729 if (err)
731
732 return !err;
733}
struct _root root
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333

Referenced by test_registerOIDInfo().

◆ free_function_sets()

static void free_function_sets ( void  )
static

Definition at line 76 of file oid.c.

77{
78 struct OIDFunctionSet *setCursor, *setNext;
79
80 LIST_FOR_EACH_ENTRY_SAFE(setCursor, setNext, &funcSets,
81 struct OIDFunctionSet, next)
82 {
83 struct OIDFunction *functionCursor, *funcNext;
84
85 list_remove(&setCursor->next);
86 CryptMemFree(setCursor->name);
87 LIST_FOR_EACH_ENTRY_SAFE(functionCursor, funcNext,
88 &setCursor->functions, struct OIDFunction, next)
89 {
90 list_remove(&functionCursor->next);
91 CryptMemFree(functionCursor);
92 }
93 setCursor->cs.DebugInfo->Spare[0] = 0;
94 DeleteCriticalSection(&setCursor->cs);
95 CryptMemFree(setCursor);
96 }
98}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
struct list next
Definition: oid.c:54
LPSTR name
Definition: oid.c:51
struct list functions
Definition: oid.c:53
CRITICAL_SECTION cs
Definition: oid.c:52
struct list next
Definition: oid.c:62
PRTL_CRITICAL_SECTION_DEBUG DebugInfo
Definition: rtltypes.h:1450
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

Referenced by crypt_oid_free().

◆ free_oid_info()

static void free_oid_info ( void  )
static

Definition at line 1676 of file oid.c.

1677{
1678 struct OIDInfo *info, *next;
1679
1681 {
1682 list_remove(&info->entry);
1684 }
1686}

Referenced by crypt_oid_free().

◆ init_oid_info()

static void init_oid_info ( void  )
static

Definition at line 1605 of file oid.c.

1606{
1607 DWORD i;
1608
1610 for (i = 0; i < ARRAY_SIZE(oidInfoConstructors); i++)
1611 {
1612 if (!IS_INTRESOURCE(oidInfoConstructors[i].pwszName))
1613 {
1614 struct OIDInfo *info;
1615
1616 /* The name is a static string, so just use the same pointer */
1617 info = CryptMemAlloc(sizeof(struct OIDInfo));
1618 if (info)
1619 {
1620 memset(info, 0, sizeof(*info));
1621 info->info.cbSize = sizeof(CRYPT_OID_INFO);
1622 info->info.pszOID = oidInfoConstructors[i].pszOID;
1623 info->info.pwszName = oidInfoConstructors[i].pwszName;
1624 info->info.dwGroupId = oidInfoConstructors[i].dwGroupId;
1625 info->info.Algid = oidInfoConstructors[i].Algid;
1627 {
1628 info->info.ExtraInfo.cbData =
1629 oidInfoConstructors[i].blob->cbData;
1630 info->info.ExtraInfo.pbData =
1631 oidInfoConstructors[i].blob->pbData;
1632 }
1633 info->info.pwszCNGAlgid = oidInfoConstructors[i].pwszCNGAlgid;
1634 info->info.pwszCNGExtraAlgid = oidInfoConstructors[i].pwszCNGExtraAlgid;
1635 list_add_tail(&oidInfo, &info->entry);
1636 }
1637 }
1638 else
1639 {
1640 LPCWSTR stringresource;
1642 (UINT_PTR)oidInfoConstructors[i].pwszName,
1643 (LPWSTR)&stringresource, 0);
1644
1645 if (len)
1646 {
1647 struct OIDInfo *info = CryptMemAlloc(sizeof(struct OIDInfo) +
1648 (len + 1) * sizeof(WCHAR));
1649
1650 if (info)
1651 {
1652 memset(info, 0, sizeof(*info));
1653 info->info.cbSize = sizeof(CRYPT_OID_INFO);
1654 info->info.pszOID = oidInfoConstructors[i].pszOID;
1655 info->info.pwszName = (LPWSTR)(info + 1);
1656 info->info.dwGroupId = oidInfoConstructors[i].dwGroupId;
1657 info->info.Algid = oidInfoConstructors[i].Algid;
1658 memcpy(info + 1, stringresource, len*sizeof(WCHAR));
1659 ((LPWSTR)(info + 1))[len] = 0;
1661 {
1662 info->info.ExtraInfo.cbData =
1663 oidInfoConstructors[i].blob->cbData;
1664 info->info.ExtraInfo.pbData =
1665 oidInfoConstructors[i].blob->pbData;
1666 }
1667 info->info.pwszCNGAlgid = oidInfoConstructors[i].pwszCNGAlgid;
1668 info->info.pwszCNGExtraAlgid = oidInfoConstructors[i].pwszCNGExtraAlgid;
1669 list_add_tail(&oidInfo, &info->entry);
1670 }
1671 }
1672 }
1673 }
1674}
HINSTANCE hInstance
Definition: charmap.c:19
static const struct OIDInfoConstructor oidInfoConstructors[]
static void oid_init_localizednames(void)
Definition: oid.c:1157
#define IS_INTRESOURCE(x)
Definition: loader.c:613
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define LoadStringW
Definition: utils.h:64
Definition: image.c:134
struct _CRYPT_OID_INFO CRYPT_OID_INFO

Referenced by crypt_oid_init().

◆ init_registered_oid_info()

static void init_registered_oid_info ( void  )
static

Definition at line 1565 of file oid.c.

1566{
1567 DWORD err, idx;
1568 HKEY root;
1569
1570 err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptDllFindOIDInfo",
1571 0, KEY_ALL_ACCESS, &root);
1572 if (err != ERROR_SUCCESS) return;
1573
1574 idx = 0;
1575 for (;;)
1576 {
1577 char key_name[MAX_PATH];
1578 struct OIDInfo *info;
1579 DWORD flags;
1580
1582 if (err == ERROR_NO_MORE_ITEMS)
1583 break;
1584
1585 if (err == ERROR_SUCCESS)
1586 {
1587 if ((info = read_oid_info(root, key_name, &flags)))
1588 {
1589 TRACE("adding oid %s, name %s, groupid %lu, algid %u, extra %lu, CNG algid %s, CNG extra %s\n",
1590 debugstr_a(info->info.pszOID), debugstr_w(info->info.pwszName),
1591 info->info.dwGroupId, info->info.Algid, info->info.ExtraInfo.cbData,
1592 debugstr_w(info->info.pwszCNGAlgid), debugstr_w(info->info.pwszCNGExtraAlgid));
1593
1595 list_add_head(&oidInfo, &info->entry);
1596 else
1597 list_add_tail(&oidInfo, &info->entry);
1598 }
1599 }
1600 }
1601
1603}
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
unsigned int idx
Definition: utils.c:41
LONG WINAPI RegEnumKeyA(HKEY hKey, DWORD dwIndex, LPSTR lpName, DWORD cbName)
Definition: reg.c:2368
static struct OIDInfo * read_oid_info(HKEY root, char *key_name, DWORD *flags)
Definition: oid.c:1486
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
#define MAX_PATH
Definition: compat.h:34
#define CRYPT_INSTALL_OID_INFO_BEFORE_FLAG
Definition: wincrypt.h:2701

Referenced by crypt_oid_init().

◆ is_module_registered()

static BOOL is_module_registered ( HMODULE  hModule)
static

Definition at line 424 of file oid.c.

425{
426 struct OIDFunctionSet *set;
427 BOOL ret = FALSE;
428
430
432 {
433 struct OIDFunction *function;
434
436
437 LIST_FOR_EACH_ENTRY(function, &set->functions, struct OIDFunction, next)
438 {
439 if (function->hModule == hModule)
440 {
441 ret = TRUE;
442 break;
443 }
444 }
445
447
448 if (ret) break;
449 }
450
452
453 return ret;
454}
HMODULE hModule
Definition: oid.c:59

Referenced by CryptFreeOIDFunctionAddress().

◆ oid_init_localizednames()

static void oid_init_localizednames ( void  )
static

Definition at line 1157 of file oid.c.

1158{
1159 unsigned int i;
1160
1161 for(i = 0; i < ARRAY_SIZE(LocalizedKeys); i++)
1162 {
1164 }
1165}
#define IDS_LOCALIZEDNAME_ROOT
Definition: cryptres.h:162

Referenced by init_oid_info().

◆ read_oid_info()

static struct OIDInfo * read_oid_info ( HKEY  root,
char key_name,
DWORD flags 
)
static

Definition at line 1486 of file oid.c.

1487{
1488 HKEY key;
1489 DWORD len, oid_len, name_len = 0, extra_len = 0, cngalgid_len = 0, cngextra_len = 0, group_id = 0;
1490 struct OIDInfo *info;
1491 char *p;
1492
1494 return NULL;
1495
1496 p = strchr(key_name, '!');
1497 if (p)
1498 {
1499 group_id = strtol(p + 1, NULL, 10);
1500 *p = 0;
1501 }
1502
1503 oid_len = strlen(key_name) + 1;
1504
1505 RegQueryValueExW(key, L"Name", NULL, NULL, NULL, &name_len);
1506 RegQueryValueExW(key, L"ExtraInfo", NULL, NULL, NULL, &extra_len);
1507 RegQueryValueExW(key, L"CNGAlgid", NULL, NULL, NULL, &cngalgid_len);
1508 RegQueryValueExW(key, L"CNGExtraAlgid", NULL, NULL, NULL, &cngextra_len);
1509
1510 info = CryptMemAlloc(sizeof(*info) + oid_len + name_len + extra_len + cngalgid_len + cngextra_len);
1511 if (info)
1512 {
1513 *flags = 0;
1514 len = sizeof(*flags);
1515 RegQueryValueExW(key, L"Flags", NULL, NULL, (BYTE *)flags, &len);
1516
1517 memset(info, 0, sizeof(*info));
1518 info->info.cbSize = sizeof(info->info);
1519
1520 p = (char *)(info + 1);
1521
1522 info->info.pszOID = p;
1523 strcpy((char *)info->info.pszOID, key_name);
1524 p += oid_len;
1525
1526 if (name_len)
1527 {
1528 info->info.pwszName = (WCHAR *)p;
1529 RegQueryValueExW(key, L"Name", NULL, NULL, (BYTE *)info->info.pwszName, &name_len);
1530 p += name_len;
1531 }
1532
1533 info->info.dwGroupId = group_id;
1534
1535 len = sizeof(info->info.Algid);
1536 RegQueryValueExW(key, L"Algid", NULL, NULL, (BYTE *)&info->info.Algid, &len);
1537
1538 if (extra_len)
1539 {
1540 info->info.ExtraInfo.cbData = extra_len;
1541 info->info.ExtraInfo.pbData = (BYTE *)p;
1542 RegQueryValueExW(key, L"ExtraInfo", NULL, NULL, info->info.ExtraInfo.pbData, &extra_len);
1543 p += extra_len;
1544 }
1545
1546 if (cngalgid_len)
1547 {
1548 info->info.pwszCNGAlgid = (WCHAR *)p;
1549 RegQueryValueExW(key, L"CNGAlgid", NULL, NULL, (BYTE *)info->info.pwszCNGAlgid, &cngalgid_len);
1550 p += cngalgid_len;
1551 }
1552
1553 if (cngextra_len)
1554 {
1555 info->info.pwszCNGExtraAlgid = (WCHAR *)p;
1556 RegQueryValueExW(key, L"CNGExtraAlgid", NULL, NULL, (BYTE *)info->info.pwszCNGExtraAlgid, &cngalgid_len);
1557 }
1558 }
1559
1561
1562 return info;
1563}
_ACRTIMP __msvcrt_long __cdecl strtol(const char *, char **, int)
Definition: string.c:1838
_ACRTIMP char *__cdecl strchr(const char *, int)
Definition: string.c:3291
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by init_registered_oid_info().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( crypt  )

Variable Documentation

◆ domainCompTypes

const DWORD domainCompTypes[]
static
Initial value:
#define CERT_RDN_UTF8_STRING
Definition: wincrypt.h:2940
#define CERT_RDN_IA5_STRING
Definition: wincrypt.h:2931

Definition at line 1222 of file oid.c.

◆ domainCompTypesBlob

const CRYPT_DATA_BLOB domainCompTypesBlob
static
Initial value:
= { sizeof(domainCompTypes),
static const DWORD domainCompTypes[]
Definition: oid.c:1222

Definition at line 1230 of file oid.c.

◆ dssSign

const DWORD dssSign[2]
static
Initial value:
#define CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG
Definition: wincrypt.h:1953
#define CALG_DSS_SIGN
Definition: wincrypt.h:2070

Definition at line 1205 of file oid.c.

◆ dssSignBlob

const CRYPT_DATA_BLOB dssSignBlob
static
Initial value:
= { sizeof(dssSign),
static const DWORD dssSign[2]
Definition: oid.c:1205

Definition at line 1213 of file oid.c.

◆ ecdsaSign

Definition at line 1210 of file oid.c.

◆ ecdsaSignBlob

const CRYPT_DATA_BLOB ecdsaSignBlob = { sizeof(ecdsaSign), (BYTE *)ecdsaSign }
static

Definition at line 1217 of file oid.c.

◆ funcSetCS

static CRITICAL_SECTION funcSetCS = { &funcSetCSDebug, -1, 0, 0, 0, 0 }
static

Definition at line 39 of file oid.c.

Referenced by CryptInitOIDFunctionSet(), free_function_sets(), and is_module_registered().

◆ funcSetCSDebug

CRITICAL_SECTION_DEBUG funcSetCSDebug
static
Initial value:
=
{
0, 0, &funcSetCS,
0, 0, { (DWORD_PTR)(__FILE__ ": funcSetCS") }
}
static CRITICAL_SECTION_DEBUG funcSetCSDebug
Definition: oid.c:40

Definition at line 40 of file oid.c.

◆ funcSets

struct list funcSets = { &funcSets, &funcSets }
static

Definition at line 47 of file oid.c.

Referenced by CryptInitOIDFunctionSet(), free_function_sets(), and is_module_registered().

◆ ia5String

const DWORD ia5String[] = { CERT_RDN_IA5_STRING, 0 }
static

Definition at line 1219 of file oid.c.

◆ ia5StringBlob

const CRYPT_DATA_BLOB ia5StringBlob
static
Initial value:
= { sizeof(ia5String),
static const DWORD ia5String[]
Definition: oid.c:1219

Definition at line 1224 of file oid.c.

◆ LocalizedKeys

const LPCWSTR LocalizedKeys[]
static
Initial value:
=
{
L"ROOT",
L"MY",
L"CA",
L"ADDRESSBOOK",
L"TrustedPublisher",
L"Disallowed"
}

Definition at line 65 of file oid.c.

Referenced by CryptFindLocalizedName(), and oid_init_localizednames().

◆ LocalizedNames

WCHAR LocalizedNames[ARRAY_SIZE(LocalizedKeys)][256]
static

Definition at line 74 of file oid.c.

Referenced by CryptFindLocalizedName(), and oid_init_localizednames().

◆ mosaicFlags

const DWORD mosaicFlags
static
Initial value:

Definition at line 1197 of file oid.c.

◆ mosaicFlagsBlob

const CRYPT_DATA_BLOB mosaicFlagsBlob
static
Initial value:
= { sizeof(mosaicFlags),
static const DWORD mosaicFlags
Definition: oid.c:1197

Definition at line 1201 of file oid.c.

◆ mosaicSign

const DWORD mosaicSign[2]
static

◆ mosaicSignBlob

const CRYPT_DATA_BLOB mosaicSignBlob
static
Initial value:
= { sizeof(mosaicSign),
static const DWORD mosaicSign[2]
Definition: oid.c:1207

Definition at line 1215 of file oid.c.

◆ noNullBlob

const CRYPT_DATA_BLOB noNullBlob
static
Initial value:
= { sizeof(noNullFlag),
static const DWORD noNullFlag
Definition: oid.c:1196

Definition at line 1199 of file oid.c.

◆ noNullFlag

Definition at line 1196 of file oid.c.

◆ numericString

const DWORD numericString[] = { CERT_RDN_NUMERIC_STRING, 0 }
static

Definition at line 1220 of file oid.c.

◆ numericStringBlob

const CRYPT_DATA_BLOB numericStringBlob
static
Initial value:
= { sizeof(numericString),
static const DWORD numericString[]
Definition: oid.c:1220

Definition at line 1226 of file oid.c.

◆ oidInfo

◆ oidInfoConstructors

const struct OIDInfoConstructor oidInfoConstructors[]
static

Referenced by init_oid_info().

◆ oidInfoCS

static CRITICAL_SECTION oidInfoCS = { &oidInfoCSDebug, -1, 0, 0, 0, 0 }
static

Definition at line 1186 of file oid.c.

Referenced by CryptEnumOIDInfo(), CryptFindOIDInfo(), and free_oid_info().

◆ oidInfoCSDebug

CRITICAL_SECTION_DEBUG oidInfoCSDebug
static
Initial value:
=
{
0, 0, &oidInfoCS,
0, 0, { (DWORD_PTR)(__FILE__ ": oidInfoCS") }
}
static CRITICAL_SECTION_DEBUG oidInfoCSDebug
Definition: oid.c:1187

Definition at line 1187 of file oid.c.

◆ printableString

const DWORD printableString[] = { CERT_RDN_PRINTABLE_STRING, 0 }
static

Definition at line 1221 of file oid.c.

◆ printableStringBlob

const CRYPT_DATA_BLOB printableStringBlob
static
Initial value:
= { sizeof(printableString),
static const DWORD printableString[]
Definition: oid.c:1221

Definition at line 1228 of file oid.c.

◆ rsaSign

const DWORD rsaSign = CALG_RSA_SIGN
static

Definition at line 1204 of file oid.c.

◆ rsaSignBlob

const CRYPT_DATA_BLOB rsaSignBlob
static
Initial value:
= { sizeof(rsaSign),
static const DWORD rsaSign
Definition: oid.c:1204

Definition at line 1211 of file oid.c.