1 /* 2 * Copyright 2002 Mike McCormack for CodeWeavers 3 * Copyright 2005-2006 Juan Lang 4 * Copyright 2018 Dmitry Timoshkov 5 * 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. 10 * 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. 15 * 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 19 */ 20 21 #include "config.h" 22 #include "wine/port.h" 23 24 #include <stdio.h> 25 #include <stdarg.h> 26 #ifdef __REACTOS__ 27 #include <stdlib.h> 28 #endif 29 #define NONAMELESSUNION 30 #include "windef.h" 31 #include "winbase.h" 32 #define CRYPT_OID_INFO_HAS_EXTRA_FIELDS 33 #include "wincrypt.h" 34 #include "winreg.h" 35 #include "winuser.h" 36 #include "wine/debug.h" 37 #include "wine/list.h" 38 #include "crypt32_private.h" 39 #include "cryptres.h" 40 41 WINE_DEFAULT_DEBUG_CHANNEL(crypt); 42 43 static const WCHAR DllW[] = { 'D','l','l',0 }; 44 45 static CRITICAL_SECTION funcSetCS; 46 static CRITICAL_SECTION_DEBUG funcSetCSDebug = 47 { 48 0, 0, &funcSetCS, 49 { &funcSetCSDebug.ProcessLocksList, &funcSetCSDebug.ProcessLocksList }, 50 0, 0, { (DWORD_PTR)(__FILE__ ": funcSetCS") } 51 }; 52 static CRITICAL_SECTION funcSetCS = { &funcSetCSDebug, -1, 0, 0, 0, 0 }; 53 static struct list funcSets = { &funcSets, &funcSets }; 54 55 struct OIDFunctionSet 56 { 57 LPSTR name; 58 CRITICAL_SECTION cs; /* protects functions */ 59 struct list functions; 60 struct list next; 61 }; 62 63 struct OIDFunction 64 { 65 HMODULE hModule; 66 DWORD encoding; 67 CRYPT_OID_FUNC_ENTRY entry; 68 struct list next; 69 }; 70 71 static const WCHAR ROOT[] = {'R','O','O','T',0}; 72 static const WCHAR MY[] = {'M','Y',0}; 73 static const WCHAR CA[] = {'C','A',0}; 74 static const WCHAR ADDRESSBOOK[] = {'A','D','D','R','E','S','S','B','O','O','K',0}; 75 static const WCHAR TRUSTEDPUBLISHER[] = {'T','r','u','s','t','e','d','P','u','b','l','i','s','h','e','r',0}; 76 static const WCHAR DISALLOWED[] = {'D','i','s','a','l','l','o','w','e','d',0}; 77 static const LPCWSTR LocalizedKeys[] = {ROOT,MY,CA,ADDRESSBOOK,TRUSTEDPUBLISHER,DISALLOWED}; 78 static WCHAR LocalizedNames[ARRAY_SIZE(LocalizedKeys)][256]; 79 80 static const WCHAR nameW[] = { 'N','a','m','e',0 }; 81 static const WCHAR algidW[] = { 'A','l','g','i','d',0 }; 82 static const WCHAR extraW[] = { 'E','x','t','r','a','I','n','f','o',0 }; 83 static const WCHAR cngalgidW[] = { 'C','N','G','A','l','g','i','d',0 }; 84 static const WCHAR cngextraalgidW[] = { 'C','N','G','E','x','t','r','a','A','l','g','i','d',0 }; 85 static const WCHAR flagsW[] = { 'F','l','a','g','s',0 }; 86 87 static void free_function_sets(void) 88 { 89 struct OIDFunctionSet *setCursor, *setNext; 90 91 LIST_FOR_EACH_ENTRY_SAFE(setCursor, setNext, &funcSets, 92 struct OIDFunctionSet, next) 93 { 94 struct OIDFunction *functionCursor, *funcNext; 95 96 list_remove(&setCursor->next); 97 CryptMemFree(setCursor->name); 98 LIST_FOR_EACH_ENTRY_SAFE(functionCursor, funcNext, 99 &setCursor->functions, struct OIDFunction, next) 100 { 101 list_remove(&functionCursor->next); 102 CryptMemFree(functionCursor); 103 } 104 setCursor->cs.DebugInfo->Spare[0] = 0; 105 DeleteCriticalSection(&setCursor->cs); 106 CryptMemFree(setCursor); 107 } 108 DeleteCriticalSection(&funcSetCS); 109 } 110 111 /* There is no free function associated with this; therefore, the sets are 112 * freed when crypt32.dll is unloaded. 113 */ 114 HCRYPTOIDFUNCSET WINAPI CryptInitOIDFunctionSet(LPCSTR pszFuncName, 115 DWORD dwFlags) 116 { 117 struct OIDFunctionSet *cursor, *ret = NULL; 118 119 TRACE("(%s, %x)\n", debugstr_a(pszFuncName), dwFlags); 120 121 EnterCriticalSection(&funcSetCS); 122 LIST_FOR_EACH_ENTRY(cursor, &funcSets, struct OIDFunctionSet, next) 123 { 124 if (!strcasecmp(pszFuncName, cursor->name)) 125 { 126 ret = cursor; 127 break; 128 } 129 } 130 if (!ret) 131 { 132 ret = CryptMemAlloc(sizeof(struct OIDFunctionSet)); 133 if (ret) 134 { 135 memset(ret, 0, sizeof(*ret)); 136 ret->name = CryptMemAlloc(strlen(pszFuncName) + 1); 137 if (ret->name) 138 { 139 InitializeCriticalSection(&ret->cs); 140 ret->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": OIDFunctionSet.cs"); 141 list_init(&ret->functions); 142 strcpy(ret->name, pszFuncName); 143 list_add_tail(&funcSets, &ret->next); 144 } 145 else 146 { 147 CryptMemFree(ret); 148 ret = NULL; 149 } 150 } 151 } 152 LeaveCriticalSection(&funcSetCS); 153 154 return ret; 155 } 156 157 static char *CRYPT_GetKeyName(DWORD dwEncodingType, LPCSTR pszFuncName, 158 LPCSTR pszOID) 159 { 160 static const char szEncodingTypeFmt[] = 161 "Software\\Microsoft\\Cryptography\\OID\\EncodingType %d\\%s\\%s"; 162 UINT len; 163 char numericOID[7]; /* enough for "#65535" */ 164 const char *oid; 165 LPSTR szKey; 166 167 /* MSDN says the encoding type is a mask, but it isn't treated that way. 168 * (E.g., if dwEncodingType were 3, the key names "EncodingType 1" and 169 * "EncodingType 2" would be expected if it were a mask. Instead native 170 * stores values in "EncodingType 3". 171 */ 172 if (IS_INTOID(pszOID)) 173 { 174 snprintf(numericOID, sizeof(numericOID), "#%d", LOWORD(pszOID)); 175 oid = numericOID; 176 } 177 else 178 oid = pszOID; 179 180 /* This is enough: the lengths of the two string parameters are explicitly 181 * counted, and we need up to five additional characters for the encoding 182 * type. These are covered by the "%d", "%s", and "%s" characters in the 183 * format specifier that are removed by sprintf. 184 */ 185 len = sizeof(szEncodingTypeFmt) + lstrlenA(pszFuncName) + lstrlenA(oid); 186 szKey = CryptMemAlloc(len); 187 if (szKey) 188 sprintf(szKey, szEncodingTypeFmt, 189 GET_CERT_ENCODING_TYPE(dwEncodingType), pszFuncName, oid); 190 return szKey; 191 } 192 193 BOOL WINAPI CryptGetDefaultOIDDllList(HCRYPTOIDFUNCSET hFuncSet, 194 DWORD dwEncodingType, LPWSTR pwszDllList, DWORD *pcchDllList) 195 { 196 BOOL ret = TRUE; 197 struct OIDFunctionSet *set = hFuncSet; 198 char *keyName; 199 HKEY key; 200 LSTATUS rc; 201 202 TRACE("(%p, %d, %p, %p)\n", hFuncSet, dwEncodingType, pwszDllList, 203 pcchDllList); 204 205 keyName = CRYPT_GetKeyName(dwEncodingType, set->name, "DEFAULT"); 206 rc = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keyName, 0, NULL, 0, 207 KEY_READ, NULL, &key, NULL); 208 if (!rc) 209 { 210 DWORD size = *pcchDllList * sizeof(WCHAR); 211 212 rc = RegQueryValueExW(key, DllW, NULL, NULL, (LPBYTE)pwszDllList, 213 &size); 214 if (!rc) 215 *pcchDllList = size / sizeof(WCHAR); 216 else 217 { 218 /* No value, return an empty list */ 219 if (pwszDllList && *pcchDllList) 220 *pwszDllList = '\0'; 221 *pcchDllList = 1; 222 } 223 RegCloseKey(key); 224 } 225 else 226 { 227 /* No value, return an empty list */ 228 if (pwszDllList && *pcchDllList) 229 *pwszDllList = '\0'; 230 *pcchDllList = 1; 231 } 232 CryptMemFree(keyName); 233 234 return ret; 235 } 236 237 BOOL WINAPI CryptInstallOIDFunctionAddress(HMODULE hModule, 238 DWORD dwEncodingType, LPCSTR pszFuncName, DWORD cFuncEntry, 239 const CRYPT_OID_FUNC_ENTRY rgFuncEntry[], DWORD dwFlags) 240 { 241 BOOL ret = TRUE; 242 struct OIDFunctionSet *set; 243 244 TRACE("(%p, %d, %s, %d, %p, %08x)\n", hModule, dwEncodingType, 245 debugstr_a(pszFuncName), cFuncEntry, rgFuncEntry, dwFlags); 246 247 set = CryptInitOIDFunctionSet(pszFuncName, 0); 248 if (set) 249 { 250 DWORD i; 251 252 EnterCriticalSection(&set->cs); 253 for (i = 0; ret && i < cFuncEntry; i++) 254 { 255 struct OIDFunction *func; 256 257 TRACE("OID %s, func %p\n", debugstr_a(rgFuncEntry[i].pszOID), rgFuncEntry[i].pvFuncAddr); 258 259 if (!IS_INTOID(rgFuncEntry[i].pszOID)) 260 func = CryptMemAlloc(sizeof(struct OIDFunction) 261 + strlen(rgFuncEntry[i].pszOID) + 1); 262 else 263 func = CryptMemAlloc(sizeof(struct OIDFunction)); 264 if (func) 265 { 266 func->encoding = GET_CERT_ENCODING_TYPE(dwEncodingType); 267 if (!IS_INTOID(rgFuncEntry[i].pszOID)) 268 { 269 LPSTR oid; 270 271 oid = (LPSTR)((LPBYTE)func + sizeof(*func)); 272 strcpy(oid, rgFuncEntry[i].pszOID); 273 func->entry.pszOID = oid; 274 } 275 else 276 func->entry.pszOID = rgFuncEntry[i].pszOID; 277 func->entry.pvFuncAddr = rgFuncEntry[i].pvFuncAddr; 278 func->hModule = hModule; 279 list_add_tail(&set->functions, &func->next); 280 } 281 else 282 ret = FALSE; 283 } 284 LeaveCriticalSection(&set->cs); 285 } 286 else 287 ret = FALSE; 288 return ret; 289 } 290 291 struct FuncAddr 292 { 293 HMODULE lib; 294 LPWSTR dllList; 295 LPWSTR currentDll; 296 }; 297 298 static BOOL CRYPT_GetFuncFromReg(DWORD dwEncodingType, LPCSTR pszOID, 299 LPCSTR szFuncName, LPVOID *ppvFuncAddr, HCRYPTOIDFUNCADDR *phFuncAddr) 300 { 301 BOOL ret = FALSE; 302 char *keyName; 303 const char *funcName; 304 HKEY key; 305 LSTATUS rc; 306 307 keyName = CRYPT_GetKeyName(dwEncodingType, szFuncName, pszOID); 308 rc = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keyName, 0, KEY_READ, &key); 309 if (!rc) 310 { 311 DWORD type, size = 0; 312 313 rc = RegQueryValueExA(key, "FuncName", NULL, &type, NULL, &size); 314 if ((!rc || rc == ERROR_MORE_DATA) && type == REG_SZ) 315 { 316 funcName = CryptMemAlloc(size); 317 rc = RegQueryValueExA(key, "FuncName", NULL, &type, 318 (LPBYTE)funcName, &size); 319 } 320 else 321 funcName = szFuncName; 322 rc = RegQueryValueExW(key, DllW, NULL, &type, NULL, &size); 323 if ((!rc || rc == ERROR_MORE_DATA) && type == REG_SZ) 324 { 325 LPWSTR dllName = CryptMemAlloc(size); 326 327 if (dllName) 328 { 329 rc = RegQueryValueExW(key, DllW, NULL, NULL, 330 (LPBYTE)dllName, &size); 331 if (!rc) 332 { 333 HMODULE lib; 334 335 /* This is a bit of a hack; MSDN describes a more 336 * complicated unload routine than this will allow. 337 * Still, this seems to suffice for now. 338 */ 339 lib = LoadLibraryW(dllName); 340 if (lib) 341 { 342 *ppvFuncAddr = GetProcAddress(lib, funcName); 343 if (*ppvFuncAddr) 344 { 345 struct FuncAddr *addr = 346 CryptMemAlloc(sizeof(struct FuncAddr)); 347 348 if (addr) 349 { 350 addr->lib = lib; 351 addr->dllList = addr->currentDll = NULL; 352 *phFuncAddr = addr; 353 ret = TRUE; 354 } 355 else 356 { 357 *phFuncAddr = NULL; 358 FreeLibrary(lib); 359 } 360 } 361 else 362 { 363 /* Unload the library, the caller doesn't want 364 * to unload it when the return value is NULL. 365 */ 366 FreeLibrary(lib); 367 } 368 } 369 } 370 else 371 SetLastError(rc); 372 CryptMemFree(dllName); 373 } 374 } 375 else 376 SetLastError(rc); 377 if (funcName != szFuncName) 378 CryptMemFree((char *)funcName); 379 RegCloseKey(key); 380 } 381 else 382 SetLastError(rc); 383 CryptMemFree(keyName); 384 return ret; 385 } 386 387 BOOL WINAPI CryptGetOIDFunctionAddress(HCRYPTOIDFUNCSET hFuncSet, 388 DWORD dwEncodingType, LPCSTR pszOID, DWORD dwFlags, void **ppvFuncAddr, 389 HCRYPTOIDFUNCADDR *phFuncAddr) 390 { 391 BOOL ret = FALSE; 392 struct OIDFunctionSet *set = hFuncSet; 393 394 TRACE("(%p, %d, %s, %08x, %p, %p)\n", hFuncSet, dwEncodingType, 395 debugstr_a(pszOID), dwFlags, ppvFuncAddr, phFuncAddr); 396 397 *ppvFuncAddr = NULL; 398 if (!(dwFlags & CRYPT_GET_INSTALLED_OID_FUNC_FLAG)) 399 { 400 struct OIDFunction *function; 401 402 EnterCriticalSection(&set->cs); 403 LIST_FOR_EACH_ENTRY(function, &set->functions, struct OIDFunction, next) 404 { 405 if (function->encoding == GET_CERT_ENCODING_TYPE(dwEncodingType)) 406 { 407 if (!IS_INTOID(pszOID)) 408 { 409 if (!IS_INTOID(function->entry.pszOID) && 410 !strcasecmp(function->entry.pszOID, pszOID)) 411 { 412 *ppvFuncAddr = function->entry.pvFuncAddr; 413 *phFuncAddr = NULL; /* FIXME: what should it be? */ 414 ret = TRUE; 415 break; 416 } 417 } 418 else if (function->entry.pszOID == pszOID) 419 { 420 *ppvFuncAddr = function->entry.pvFuncAddr; 421 *phFuncAddr = NULL; /* FIXME: what should it be? */ 422 ret = TRUE; 423 break; 424 } 425 } 426 } 427 LeaveCriticalSection(&set->cs); 428 } 429 if (!*ppvFuncAddr) 430 ret = CRYPT_GetFuncFromReg(dwEncodingType, pszOID, set->name, 431 ppvFuncAddr, phFuncAddr); 432 TRACE("returning %d\n", ret); 433 return ret; 434 } 435 436 static BOOL is_module_registered(HMODULE hModule) 437 { 438 struct OIDFunctionSet *set; 439 BOOL ret = FALSE; 440 441 EnterCriticalSection(&funcSetCS); 442 443 LIST_FOR_EACH_ENTRY(set, &funcSets, struct OIDFunctionSet, next) 444 { 445 struct OIDFunction *function; 446 447 EnterCriticalSection(&set->cs); 448 449 LIST_FOR_EACH_ENTRY(function, &set->functions, struct OIDFunction, next) 450 { 451 if (function->hModule == hModule) 452 { 453 ret = TRUE; 454 break; 455 } 456 } 457 458 LeaveCriticalSection(&set->cs); 459 460 if (ret) break; 461 } 462 463 LeaveCriticalSection(&funcSetCS); 464 465 return ret; 466 } 467 468 BOOL WINAPI CryptFreeOIDFunctionAddress(HCRYPTOIDFUNCADDR hFuncAddr, 469 DWORD dwFlags) 470 { 471 TRACE("(%p, %08x)\n", hFuncAddr, dwFlags); 472 473 /* FIXME: as MSDN states, need to check for DllCanUnloadNow in the DLL, 474 * and only unload it if it can be unloaded. Also need to implement ref 475 * counting on the functions. 476 */ 477 if (hFuncAddr) 478 { 479 struct FuncAddr *addr = hFuncAddr; 480 481 if (!is_module_registered(addr->lib)) 482 { 483 CryptMemFree(addr->dllList); 484 FreeLibrary(addr->lib); 485 CryptMemFree(addr); 486 } 487 } 488 return TRUE; 489 } 490 491 static BOOL CRYPT_GetFuncFromDll(LPCWSTR dll, LPCSTR func, HMODULE *lib, 492 void **ppvFuncAddr) 493 { 494 BOOL ret = FALSE; 495 496 *lib = LoadLibraryW(dll); 497 if (*lib) 498 { 499 *ppvFuncAddr = GetProcAddress(*lib, func); 500 if (*ppvFuncAddr) 501 ret = TRUE; 502 else 503 { 504 FreeLibrary(*lib); 505 *lib = NULL; 506 } 507 } 508 return ret; 509 } 510 511 BOOL WINAPI CryptGetDefaultOIDFunctionAddress(HCRYPTOIDFUNCSET hFuncSet, 512 DWORD dwEncodingType, LPCWSTR pwszDll, DWORD dwFlags, void **ppvFuncAddr, 513 HCRYPTOIDFUNCADDR *phFuncAddr) 514 { 515 struct OIDFunctionSet *set = hFuncSet; 516 BOOL ret = FALSE; 517 518 TRACE("(%p, %d, %s, %08x, %p, %p)\n", hFuncSet, dwEncodingType, 519 debugstr_w(pwszDll), dwFlags, ppvFuncAddr, phFuncAddr); 520 521 if (pwszDll) 522 { 523 HMODULE lib; 524 525 *phFuncAddr = NULL; 526 ret = CRYPT_GetFuncFromDll(pwszDll, set->name, &lib, ppvFuncAddr); 527 if (ret) 528 { 529 struct FuncAddr *addr = CryptMemAlloc(sizeof(struct FuncAddr)); 530 531 if (addr) 532 { 533 addr->lib = lib; 534 addr->dllList = addr->currentDll = NULL; 535 *phFuncAddr = addr; 536 } 537 else 538 { 539 FreeLibrary(lib); 540 *ppvFuncAddr = NULL; 541 SetLastError(ERROR_OUTOFMEMORY); 542 ret = FALSE; 543 } 544 } 545 else 546 SetLastError(ERROR_FILE_NOT_FOUND); 547 } 548 else 549 { 550 struct FuncAddr *addr = *phFuncAddr; 551 552 if (!addr) 553 { 554 DWORD size; 555 556 ret = CryptGetDefaultOIDDllList(hFuncSet, dwEncodingType, NULL, 557 &size); 558 if (ret) 559 { 560 LPWSTR dllList = CryptMemAlloc(size * sizeof(WCHAR)); 561 562 if (dllList) 563 { 564 ret = CryptGetDefaultOIDDllList(hFuncSet, dwEncodingType, 565 dllList, &size); 566 if (ret) 567 { 568 addr = CryptMemAlloc(sizeof(struct FuncAddr)); 569 if (addr) 570 { 571 addr->dllList = dllList; 572 addr->currentDll = dllList; 573 addr->lib = NULL; 574 *phFuncAddr = addr; 575 } 576 else 577 { 578 CryptMemFree(dllList); 579 SetLastError(ERROR_OUTOFMEMORY); 580 ret = FALSE; 581 } 582 } 583 } 584 else 585 { 586 SetLastError(ERROR_OUTOFMEMORY); 587 ret = FALSE; 588 } 589 } 590 } 591 if (addr) 592 { 593 if (!*addr->currentDll) 594 { 595 CryptFreeOIDFunctionAddress(*phFuncAddr, 0); 596 SetLastError(ERROR_FILE_NOT_FOUND); 597 *phFuncAddr = NULL; 598 ret = FALSE; 599 } 600 else 601 { 602 /* FIXME: as elsewhere, can't free until DllCanUnloadNow says 603 * it's possible, and should defer unloading for some time to 604 * avoid repeated LoadLibrary/FreeLibrary on the same dll. 605 */ 606 FreeLibrary(addr->lib); 607 ret = CRYPT_GetFuncFromDll(addr->currentDll, set->name, 608 &addr->lib, ppvFuncAddr); 609 if (ret) 610 { 611 /* Move past the current DLL */ 612 addr->currentDll += lstrlenW(addr->currentDll) + 1; 613 *phFuncAddr = addr; 614 } 615 else 616 { 617 CryptFreeOIDFunctionAddress(*phFuncAddr, 0); 618 SetLastError(ERROR_FILE_NOT_FOUND); 619 *phFuncAddr = NULL; 620 } 621 } 622 } 623 } 624 return ret; 625 } 626 627 /*********************************************************************** 628 * CryptRegisterOIDFunction (CRYPT32.@) 629 * 630 * Register the DLL and the functions it uses to cover the combination 631 * of encoding type, function name and OID. 632 * 633 * PARAMS 634 * dwEncodingType [I] Encoding type to be used. 635 * pszFuncName [I] Name of the function to be registered. 636 * pszOID [I] OID of the function (numeric or string). 637 * pwszDll [I] The DLL that is to be registered. 638 * pszOverrideFuncName [I] Name of the function in the DLL. 639 * 640 * RETURNS 641 * Success: TRUE. 642 * Failure: FALSE. (Look at GetLastError()). 643 * 644 * NOTES 645 * Registry errors are always reported via SetLastError(). 646 */ 647 BOOL WINAPI CryptRegisterOIDFunction(DWORD dwEncodingType, LPCSTR pszFuncName, 648 LPCSTR pszOID, LPCWSTR pwszDll, LPCSTR pszOverrideFuncName) 649 { 650 LONG r; 651 HKEY hKey; 652 LPSTR szKey; 653 654 TRACE("(%x, %s, %s, %s, %s)\n", dwEncodingType, debugstr_a(pszFuncName), 655 debugstr_a(pszOID), debugstr_w(pwszDll), debugstr_a(pszOverrideFuncName)); 656 657 /* Native does nothing pwszDll is NULL */ 658 if (!pwszDll) 659 return TRUE; 660 661 /* I'm not matching MS bug for bug here, because I doubt any app depends on 662 * it: native "succeeds" if pszFuncName is NULL, but the nonsensical entry 663 * it creates would never be used. 664 */ 665 if (!pszFuncName || !pszOID) 666 { 667 SetLastError(E_INVALIDARG); 668 return FALSE; 669 } 670 671 szKey = CRYPT_GetKeyName(dwEncodingType, pszFuncName, pszOID); 672 TRACE("Key name is %s\n", debugstr_a(szKey)); 673 674 if (!szKey) 675 return FALSE; 676 677 r = RegCreateKeyA(HKEY_LOCAL_MACHINE, szKey, &hKey); 678 CryptMemFree(szKey); 679 680 if (r != ERROR_SUCCESS) goto error_close_key; 681 682 /* write the values */ 683 if (pszOverrideFuncName) 684 { 685 r = RegSetValueExA(hKey, "FuncName", 0, REG_SZ, 686 (const BYTE*)pszOverrideFuncName, lstrlenA(pszOverrideFuncName) + 1); 687 if (r != ERROR_SUCCESS) goto error_close_key; 688 } 689 r = RegSetValueExW(hKey, DllW, 0, REG_SZ, (const BYTE*) pwszDll, 690 (lstrlenW(pwszDll) + 1) * sizeof (WCHAR)); 691 692 error_close_key: 693 694 RegCloseKey(hKey); 695 696 if (r != ERROR_SUCCESS) 697 { 698 SetLastError(r); 699 return FALSE; 700 } 701 702 return TRUE; 703 } 704 705 /*********************************************************************** 706 * CryptUnregisterOIDInfo (CRYPT32.@) 707 */ 708 BOOL WINAPI CryptUnregisterOIDInfo(PCCRYPT_OID_INFO info) 709 { 710 char *key_name; 711 HKEY root; 712 DWORD err; 713 714 TRACE("(%p)\n", info); 715 716 if (!info || info->cbSize != sizeof(*info) || !info->pszOID) 717 { 718 SetLastError(E_INVALIDARG); 719 return FALSE; 720 } 721 722 err = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptDllFindOIDInfo", 0, KEY_ALL_ACCESS, &root); 723 if (err != ERROR_SUCCESS) 724 { 725 SetLastError(err); 726 return FALSE; 727 } 728 729 key_name = CryptMemAlloc(strlen(info->pszOID) + 16); 730 if (key_name) 731 { 732 sprintf(key_name, "%s!%u", info->pszOID, info->dwGroupId); 733 err = RegDeleteKeyA(root, key_name); 734 } 735 else 736 err = ERROR_OUTOFMEMORY; 737 738 CryptMemFree(key_name); 739 RegCloseKey(root); 740 741 if (err) 742 SetLastError(err); 743 744 return !err; 745 } 746 747 /*********************************************************************** 748 * CryptRegisterOIDInfo (CRYPT32.@) 749 */ 750 BOOL WINAPI CryptRegisterOIDInfo(PCCRYPT_OID_INFO info, DWORD flags) 751 { 752 char *key_name; 753 HKEY root = 0, key = 0; 754 DWORD err; 755 756 TRACE("(%p, %x)\n", info, flags ); 757 758 if (!info || info->cbSize != sizeof(*info) || !info->pszOID) 759 { 760 SetLastError(E_INVALIDARG); 761 return FALSE; 762 } 763 764 if (!info->dwGroupId) return TRUE; 765 766 key_name = CryptMemAlloc(strlen(info->pszOID) + 16); 767 if (!key_name) 768 { 769 err = ERROR_OUTOFMEMORY; 770 goto done; 771 } 772 773 err = RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptDllFindOIDInfo", 774 0, NULL, 0, KEY_ALL_ACCESS, NULL, &root, NULL); 775 if (err != ERROR_SUCCESS) goto done; 776 777 sprintf(key_name, "%s!%u", info->pszOID, info->dwGroupId); 778 err = RegCreateKeyA(root, key_name, &key); 779 if (err != ERROR_SUCCESS) goto done; 780 781 if (flags) 782 { 783 err = RegSetValueExW(key, flagsW, 0, REG_DWORD, (const BYTE *)&flags, sizeof(flags)); 784 if (err != ERROR_SUCCESS) goto done; 785 } 786 787 if (info->pwszName) 788 { 789 err = RegSetValueExW(key, nameW, 0, REG_SZ, (const BYTE *)info->pwszName, (lstrlenW(info->pwszName) + 1) * sizeof(WCHAR)); 790 if (err != ERROR_SUCCESS) goto done; 791 } 792 793 if (info->u.Algid) 794 { 795 err = RegSetValueExW(key, algidW, 0, REG_DWORD, (const BYTE *)&info->u.Algid, sizeof(info->u.Algid)); 796 if (err != ERROR_SUCCESS) goto done; 797 } 798 799 if (info->ExtraInfo.cbData && info->ExtraInfo.pbData) 800 { 801 err = RegSetValueExW(key, extraW, 0, REG_BINARY, info->ExtraInfo.pbData, info->ExtraInfo.cbData); 802 if (err != ERROR_SUCCESS) goto done; 803 } 804 805 if (info->pwszCNGAlgid) 806 { 807 err = RegSetValueExW(key, cngalgidW, 0, REG_SZ, (const BYTE *)info->pwszCNGAlgid, (lstrlenW(info->pwszCNGAlgid) + 1) * sizeof(WCHAR)); 808 if (err != ERROR_SUCCESS) goto done; 809 } 810 811 if (info->pwszCNGExtraAlgid) 812 { 813 err = RegSetValueExW(key, cngextraalgidW, 0, REG_SZ, (const BYTE *)info->pwszCNGExtraAlgid, (lstrlenW(info->pwszCNGExtraAlgid) + 1) * sizeof(WCHAR)); 814 if (err != ERROR_SUCCESS) goto done; 815 } 816 817 done: 818 CryptMemFree(key_name); 819 if (key) RegCloseKey(key); 820 if (root) RegCloseKey(root); 821 822 if (err) 823 SetLastError(err); 824 825 return !err; 826 } 827 828 /*********************************************************************** 829 * CryptUnregisterOIDFunction (CRYPT32.@) 830 */ 831 BOOL WINAPI CryptUnregisterOIDFunction(DWORD dwEncodingType, LPCSTR pszFuncName, 832 LPCSTR pszOID) 833 { 834 LPSTR szKey; 835 LONG rc; 836 837 TRACE("%x %s %s\n", dwEncodingType, debugstr_a(pszFuncName), 838 debugstr_a(pszOID)); 839 840 if (!pszFuncName || !pszOID) 841 { 842 SetLastError(ERROR_INVALID_PARAMETER); 843 return FALSE; 844 } 845 846 szKey = CRYPT_GetKeyName(dwEncodingType, pszFuncName, pszOID); 847 rc = RegDeleteKeyA(HKEY_LOCAL_MACHINE, szKey); 848 CryptMemFree(szKey); 849 if (rc) 850 SetLastError(rc); 851 return !rc; 852 } 853 854 BOOL WINAPI CryptGetOIDFunctionValue(DWORD dwEncodingType, LPCSTR pszFuncName, 855 LPCSTR pszOID, LPCWSTR pwszValueName, DWORD *pdwValueType, BYTE *pbValueData, 856 DWORD *pcbValueData) 857 { 858 LPSTR szKey; 859 LONG rc; 860 HKEY hKey; 861 862 TRACE("%x %s %s %s %p %p %p\n", dwEncodingType, debugstr_a(pszFuncName), 863 debugstr_a(pszOID), debugstr_w(pwszValueName), pdwValueType, pbValueData, 864 pcbValueData); 865 866 if (!GET_CERT_ENCODING_TYPE(dwEncodingType)) 867 return TRUE; 868 869 if (!pszFuncName || !pszOID || !pwszValueName) 870 { 871 SetLastError(ERROR_INVALID_PARAMETER); 872 return FALSE; 873 } 874 875 szKey = CRYPT_GetKeyName(dwEncodingType, pszFuncName, pszOID); 876 rc = RegOpenKeyA(HKEY_LOCAL_MACHINE, szKey, &hKey); 877 CryptMemFree(szKey); 878 if (rc) 879 SetLastError(rc); 880 else 881 { 882 rc = RegQueryValueExW(hKey, pwszValueName, NULL, pdwValueType, 883 pbValueData, pcbValueData); 884 if (rc) 885 SetLastError(rc); 886 RegCloseKey(hKey); 887 } 888 return !rc; 889 } 890 891 BOOL WINAPI CryptSetOIDFunctionValue(DWORD dwEncodingType, LPCSTR pszFuncName, 892 LPCSTR pszOID, LPCWSTR pwszValueName, DWORD dwValueType, 893 const BYTE *pbValueData, DWORD cbValueData) 894 { 895 LPSTR szKey; 896 LONG rc; 897 HKEY hKey; 898 899 TRACE("%x %s %s %s %d %p %d\n", dwEncodingType, debugstr_a(pszFuncName), 900 debugstr_a(pszOID), debugstr_w(pwszValueName), dwValueType, pbValueData, 901 cbValueData); 902 903 if (!GET_CERT_ENCODING_TYPE(dwEncodingType)) 904 return TRUE; 905 906 if (!pszFuncName || !pszOID || !pwszValueName) 907 { 908 SetLastError(ERROR_INVALID_PARAMETER); 909 return FALSE; 910 } 911 912 szKey = CRYPT_GetKeyName(dwEncodingType, pszFuncName, pszOID); 913 rc = RegOpenKeyA(HKEY_LOCAL_MACHINE, szKey, &hKey); 914 CryptMemFree(szKey); 915 if (rc) 916 SetLastError(rc); 917 else 918 { 919 rc = RegSetValueExW(hKey, pwszValueName, 0, dwValueType, pbValueData, 920 cbValueData); 921 if (rc) 922 SetLastError(rc); 923 RegCloseKey(hKey); 924 } 925 return !rc; 926 } 927 928 static LPCWSTR CRYPT_FindStringInMultiString(LPCWSTR multi, LPCWSTR toFind) 929 { 930 LPCWSTR ret = NULL, ptr; 931 932 for (ptr = multi; ptr && *ptr && !ret; ptr += lstrlenW(ptr) + 1) 933 { 934 if (!lstrcmpiW(ptr, toFind)) 935 ret = ptr; 936 } 937 return ret; 938 } 939 940 static DWORD CRYPT_GetMultiStringCharacterLen(LPCWSTR multi) 941 { 942 DWORD ret; 943 944 if (multi) 945 { 946 LPCWSTR ptr; 947 948 /* Count terminating empty string */ 949 ret = 1; 950 for (ptr = multi; *ptr; ptr += lstrlenW(ptr) + 1) 951 ret += lstrlenW(ptr) + 1; 952 } 953 else 954 ret = 0; 955 return ret; 956 } 957 958 static LPWSTR CRYPT_AddStringToMultiString(LPWSTR multi, LPCWSTR toAdd, 959 DWORD index) 960 { 961 LPWSTR ret; 962 963 if (!multi) 964 { 965 /* FIXME: ignoring index, is that okay? */ 966 ret = CryptMemAlloc((lstrlenW(toAdd) + 2) * sizeof(WCHAR)); 967 if (ret) 968 { 969 /* copy string, including NULL terminator */ 970 memcpy(ret, toAdd, (lstrlenW(toAdd) + 1) * sizeof(WCHAR)); 971 /* add terminating empty string */ 972 *(ret + lstrlenW(toAdd) + 1) = 0; 973 } 974 } 975 else 976 { 977 DWORD len = CRYPT_GetMultiStringCharacterLen(multi); 978 979 ret = CryptMemRealloc(multi, (len + lstrlenW(toAdd) + 1) * 980 sizeof(WCHAR)); 981 if (ret) 982 { 983 LPWSTR spotToAdd; 984 985 if (index == CRYPT_REGISTER_LAST_INDEX) 986 spotToAdd = ret + len - 1; 987 else 988 { 989 DWORD i; 990 991 /* FIXME: if index is too large for the string, toAdd is 992 * added to the end. Is that okay? 993 */ 994 for (i = 0, spotToAdd = ret; i < index && *spotToAdd; 995 spotToAdd += lstrlenW(spotToAdd) + 1) 996 ; 997 } 998 if (spotToAdd) 999 { 1000 /* Copy existing string "right" */ 1001 memmove(spotToAdd + lstrlenW(toAdd) + 1, spotToAdd, 1002 (len - (spotToAdd - ret)) * sizeof(WCHAR)); 1003 /* Copy new string */ 1004 memcpy(spotToAdd, toAdd, (lstrlenW(toAdd) + 1) * sizeof(WCHAR)); 1005 } 1006 else 1007 { 1008 CryptMemFree(ret); 1009 ret = NULL; 1010 } 1011 } 1012 } 1013 return ret; 1014 } 1015 1016 static BOOL CRYPT_RemoveStringFromMultiString(LPWSTR multi, LPCWSTR toRemove) 1017 { 1018 LPWSTR spotToRemove = (LPWSTR)CRYPT_FindStringInMultiString(multi, 1019 toRemove); 1020 BOOL ret; 1021 1022 if (spotToRemove) 1023 { 1024 DWORD len = CRYPT_GetMultiStringCharacterLen(multi); 1025 1026 if (spotToRemove + lstrlenW(toRemove) + 2 >= multi + len) 1027 { 1028 /* Removing last string in list, terminate multi string directly */ 1029 *spotToRemove = 0; 1030 *(spotToRemove + 1) = 0; 1031 } 1032 else 1033 { 1034 LPCWSTR nextStr = spotToRemove + lstrlenW(toRemove) + 1; 1035 1036 /* Copy remainder of string "left" */ 1037 memmove(spotToRemove, nextStr, 1038 (len - (nextStr - multi)) * sizeof(WCHAR)); 1039 } 1040 ret = TRUE; 1041 } 1042 else 1043 { 1044 SetLastError(ERROR_FILE_NOT_FOUND); 1045 ret = FALSE; 1046 } 1047 return ret; 1048 } 1049 1050 static BOOL CRYPT_GetDefaultOIDKey(DWORD dwEncodingType, LPCSTR pszFuncName, 1051 PHKEY key) 1052 { 1053 LPSTR keyName; 1054 LONG r; 1055 1056 keyName = CRYPT_GetKeyName(dwEncodingType, pszFuncName, "DEFAULT"); 1057 TRACE("Key name is %s\n", debugstr_a(keyName)); 1058 1059 if (!keyName) 1060 return FALSE; 1061 1062 r = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keyName, 0, NULL, 0, KEY_ALL_ACCESS, 1063 NULL, key, NULL); 1064 CryptMemFree(keyName); 1065 if (r != ERROR_SUCCESS) 1066 { 1067 SetLastError(r); 1068 return FALSE; 1069 } 1070 return TRUE; 1071 } 1072 1073 static LPWSTR CRYPT_GetDefaultOIDDlls(HKEY key) 1074 { 1075 LONG r; 1076 DWORD type, size; 1077 LPWSTR dlls; 1078 1079 r = RegQueryValueExW(key, DllW, NULL, &type, NULL, &size); 1080 if (r == ERROR_SUCCESS && type == REG_MULTI_SZ) 1081 { 1082 dlls = CryptMemAlloc(size); 1083 r = RegQueryValueExW(key, DllW, NULL, &type, (LPBYTE)dlls, &size); 1084 if (r != ERROR_SUCCESS) 1085 { 1086 CryptMemFree(dlls); 1087 dlls = NULL; 1088 } 1089 } 1090 else 1091 dlls = NULL; 1092 return dlls; 1093 } 1094 1095 static inline BOOL CRYPT_SetDefaultOIDDlls(HKEY key, LPCWSTR dlls) 1096 { 1097 DWORD len = CRYPT_GetMultiStringCharacterLen(dlls); 1098 LONG r; 1099 1100 if ((r = RegSetValueExW(key, DllW, 0, REG_MULTI_SZ, (const BYTE *)dlls, 1101 len * sizeof (WCHAR)))) 1102 SetLastError(r); 1103 return r == ERROR_SUCCESS; 1104 } 1105 1106 /*********************************************************************** 1107 * CryptRegisterDefaultOIDFunction (CRYPT32.@) 1108 */ 1109 BOOL WINAPI CryptRegisterDefaultOIDFunction(DWORD dwEncodingType, 1110 LPCSTR pszFuncName, DWORD dwIndex, LPCWSTR pwszDll) 1111 { 1112 HKEY key; 1113 LPWSTR dlls; 1114 BOOL ret = FALSE; 1115 1116 TRACE("(%x, %s, %d, %s)\n", dwEncodingType, debugstr_a(pszFuncName), 1117 dwIndex, debugstr_w(pwszDll)); 1118 1119 if (!pwszDll) 1120 { 1121 SetLastError(E_INVALIDARG); 1122 return FALSE; 1123 } 1124 1125 if (!CRYPT_GetDefaultOIDKey(dwEncodingType, pszFuncName, &key)) 1126 return FALSE; 1127 1128 dlls = CRYPT_GetDefaultOIDDlls(key); 1129 if (CRYPT_FindStringInMultiString(dlls, pwszDll)) 1130 SetLastError(ERROR_FILE_EXISTS); 1131 else 1132 { 1133 dlls = CRYPT_AddStringToMultiString(dlls, pwszDll, dwIndex); 1134 if (dlls) 1135 ret = CRYPT_SetDefaultOIDDlls(key, dlls); 1136 } 1137 CryptMemFree(dlls); 1138 RegCloseKey(key); 1139 return ret; 1140 } 1141 1142 BOOL WINAPI CryptUnregisterDefaultOIDFunction(DWORD dwEncodingType, 1143 LPCSTR pszFuncName, LPCWSTR pwszDll) 1144 { 1145 HKEY key; 1146 LPWSTR dlls; 1147 BOOL ret; 1148 1149 TRACE("(%x, %s, %s)\n", dwEncodingType, debugstr_a(pszFuncName), 1150 debugstr_w(pwszDll)); 1151 1152 if (!pwszDll) 1153 { 1154 SetLastError(E_INVALIDARG); 1155 return FALSE; 1156 } 1157 1158 if (!CRYPT_GetDefaultOIDKey(dwEncodingType, pszFuncName, &key)) 1159 return FALSE; 1160 1161 dlls = CRYPT_GetDefaultOIDDlls(key); 1162 if ((ret = CRYPT_RemoveStringFromMultiString(dlls, pwszDll))) 1163 ret = CRYPT_SetDefaultOIDDlls(key, dlls); 1164 CryptMemFree(dlls); 1165 RegCloseKey(key); 1166 return ret; 1167 } 1168 1169 static void oid_init_localizednames(void) 1170 { 1171 unsigned int i; 1172 1173 for(i = 0; i < ARRAY_SIZE(LocalizedKeys); i++) 1174 { 1175 LoadStringW(hInstance, IDS_LOCALIZEDNAME_ROOT+i, LocalizedNames[i], 256); 1176 } 1177 } 1178 1179 /******************************************************************** 1180 * CryptFindLocalizedName (CRYPT32.@) 1181 */ 1182 LPCWSTR WINAPI CryptFindLocalizedName(LPCWSTR pwszCryptName) 1183 { 1184 unsigned int i; 1185 1186 for(i = 0; i < ARRAY_SIZE(LocalizedKeys); i++) 1187 { 1188 if(!lstrcmpiW(LocalizedKeys[i], pwszCryptName)) 1189 { 1190 return LocalizedNames[i]; 1191 } 1192 } 1193 1194 FIXME("No name for: %s - stub\n",debugstr_w(pwszCryptName)); 1195 return NULL; 1196 } 1197 1198 static CRITICAL_SECTION oidInfoCS; 1199 static CRITICAL_SECTION_DEBUG oidInfoCSDebug = 1200 { 1201 0, 0, &oidInfoCS, 1202 { &oidInfoCSDebug.ProcessLocksList, &oidInfoCSDebug.ProcessLocksList }, 1203 0, 0, { (DWORD_PTR)(__FILE__ ": oidInfoCS") } 1204 }; 1205 static CRITICAL_SECTION oidInfoCS = { &oidInfoCSDebug, -1, 0, 0, 0, 0 }; 1206 static struct list oidInfo = { &oidInfo, &oidInfo }; 1207 1208 static const WCHAR tripledes[] = { '3','d','e','s',0 }; 1209 static const WCHAR cms3deswrap[] = { 'C','M','S','3','D','E','S','w','r','a', 1210 'p',0 }; 1211 static const WCHAR cmsrc2wrap[] = { 'C','M','S','R','C','2','w','r','a','p',0 }; 1212 static const WCHAR des[] = { 'd','e','s',0 }; 1213 static const WCHAR md2[] = { 'm','d','2',0 }; 1214 static const WCHAR md4[] = { 'm','d','4',0 }; 1215 static const WCHAR md5[] = { 'm','d','5',0 }; 1216 static const WCHAR rc2[] = { 'r','c','2',0 }; 1217 static const WCHAR rc4[] = { 'r','c','4',0 }; 1218 static const WCHAR sha[] = { 's','h','a',0 }; 1219 static const WCHAR sha1[] = { 's','h','a','1',0 }; 1220 static const WCHAR sha256[] = { 's','h','a','2','5','6',0 }; 1221 static const WCHAR sha384[] = { 's','h','a','3','8','4',0 }; 1222 static const WCHAR sha512[] = { 's','h','a','5','1','2',0 }; 1223 static const WCHAR RSA[] = { 'R','S','A',0 }; 1224 static const WCHAR RSA_KEYX[] = { 'R','S','A','_','K','E','Y','X',0 }; 1225 static const WCHAR RSA_SIGN[] = { 'R','S','A','_','S','I','G','N',0 }; 1226 static const WCHAR DSA[] = { 'D','S','A',0 }; 1227 static const WCHAR DSA_SIGN[] = { 'D','S','A','_','S','I','G','N',0 }; 1228 static const WCHAR DH[] = { 'D','H',0 }; 1229 static const WCHAR DSS[] = { 'D','S','S',0 }; 1230 static const WCHAR mosaicKMandUpdSig[] = 1231 { 'm','o','s','a','i','c','K','M','a','n','d','U','p','d','S','i','g',0 }; 1232 static const WCHAR ESDH[] = { 'E','S','D','H',0 }; 1233 static const WCHAR NO_SIGN[] = { 'N','O','S','I','G','N',0 }; 1234 static const WCHAR dsaSHA1[] = { 'd','s','a','S','H','A','1',0 }; 1235 static const WCHAR md2RSA[] = { 'm','d','2','R','S','A',0 }; 1236 static const WCHAR md4RSA[] = { 'm','d','4','R','S','A',0 }; 1237 static const WCHAR md5RSA[] = { 'm','d','5','R','S','A',0 }; 1238 static const WCHAR shaDSA[] = { 's','h','a','D','S','A',0 }; 1239 static const WCHAR sha1DSA[] = { 's','h','a','1','D','S','A',0 }; 1240 static const WCHAR shaRSA[] = { 's','h','a','R','S','A',0 }; 1241 static const WCHAR sha1RSA[] = { 's','h','a','1','R','S','A',0 }; 1242 static const WCHAR sha256RSA[] = { 's','h','a','2','5','6','R','S','A',0 }; 1243 static const WCHAR sha384RSA[] = { 's','h','a','3','8','4','R','S','A',0 }; 1244 static const WCHAR sha512RSA[] = { 's','h','a','5','1','2','R','S','A',0 }; 1245 static const WCHAR mosaicUpdatedSig[] = 1246 { 'm','o','s','a','i','c','U','p','d','a','t','e','d','S','i','g',0 }; 1247 static const WCHAR sha256ECDSA[] = { 's','h','a','2','5','6','E','C','D','S','A',0 }; 1248 static const WCHAR sha384ECDSA[] = { 's','h','a','3','8','4','E','C','D','S','A',0 }; 1249 static const WCHAR CN[] = { 'C','N',0 }; 1250 static const WCHAR L[] = { 'L',0 }; 1251 static const WCHAR O[] = { 'O',0 }; 1252 static const WCHAR OU[] = { 'O','U',0 }; 1253 static const WCHAR E[] = { 'E',0 }; 1254 static const WCHAR C[] = { 'C',0 }; 1255 static const WCHAR S[] = { 'S',0 }; 1256 static const WCHAR ST[] = { 'S','T',0 }; 1257 static const WCHAR STREET[] = { 'S','T','R','E','E','T',0 }; 1258 static const WCHAR T[] = { 'T',0 }; 1259 static const WCHAR Title[] = { 'T','i','t','l','e',0 }; 1260 static const WCHAR G[] = { 'G',0 }; 1261 static const WCHAR GivenName[] = { 'G','i','v','e','n','N','a','m','e',0 }; 1262 static const WCHAR I[] = { 'I',0 }; 1263 static const WCHAR Initials[] = { 'I','n','i','t','i','a','l','s',0 }; 1264 static const WCHAR SN[] = { 'S','N',0 }; 1265 static const WCHAR DC[] = { 'D','C',0 }; 1266 static const WCHAR Description[] = 1267 { 'D','e','s','c','r','i','p','t','i','o','n',0 }; 1268 static const WCHAR PostalCode[] = { 'P','o','s','t','a','l','C','o','d','e',0 }; 1269 static const WCHAR POBox[] = { 'P','O','B','o','x',0 }; 1270 static const WCHAR Phone[] = { 'P','h','o','n','e',0 }; 1271 static const WCHAR X21Address[] = { 'X','2','1','A','d','d','r','e','s','s',0 }; 1272 static const WCHAR dnQualifier[] = 1273 { 'd','n','Q','u','a','l','i','f','i','e','r',0 }; 1274 static const WCHAR SpcSpAgencyInfo[] = { 'S','p','c','S','p','A','g','e','n','c','y','I','n','f','o',0 }; 1275 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 }; 1276 static const WCHAR SpcMinimalCriteria[] = { 'S','p','c','M','i','n','i','m','a','l','C','r','i','t','e','r','i','a',0 }; 1277 static const WCHAR Email[] = { 'E','m','a','i','l',0 }; 1278 static const WCHAR GN[] = { 'G','N',0 }; 1279 static const WCHAR SERIALNUMBER[] = { 'S','E','R','I','A','L','N','U','M','B','E','R',0 }; 1280 1281 static const DWORD noNullFlag = CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG; 1282 static const DWORD mosaicFlags = CRYPT_OID_INHIBIT_SIGNATURE_FORMAT_FLAG | 1283 CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG; 1284 static const CRYPT_DATA_BLOB noNullBlob = { sizeof(noNullFlag), 1285 (LPBYTE)&noNullFlag }; 1286 static const CRYPT_DATA_BLOB mosaicFlagsBlob = { sizeof(mosaicFlags), 1287 (LPBYTE)&mosaicFlags }; 1288 1289 static const DWORD rsaSign = CALG_RSA_SIGN; 1290 static const DWORD dssSign[2] = { CALG_DSS_SIGN, 1291 CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG }; 1292 static const DWORD mosaicSign[2] = { CALG_DSS_SIGN, 1293 CRYPT_OID_INHIBIT_SIGNATURE_FORMAT_FLAG | 1294 CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG }; 1295 static const DWORD ecdsaSign[2] = { CALG_OID_INFO_PARAMETERS, CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG }; 1296 static const CRYPT_DATA_BLOB rsaSignBlob = { sizeof(rsaSign), 1297 (LPBYTE)&rsaSign }; 1298 static const CRYPT_DATA_BLOB dssSignBlob = { sizeof(dssSign), 1299 (LPBYTE)dssSign }; 1300 static const CRYPT_DATA_BLOB mosaicSignBlob = { sizeof(mosaicSign), 1301 (LPBYTE)mosaicSign }; 1302 static const CRYPT_DATA_BLOB ecdsaSignBlob = { sizeof(ecdsaSign), (BYTE *)ecdsaSign }; 1303 1304 static const DWORD ia5String[] = { CERT_RDN_IA5_STRING, 0 }; 1305 static const DWORD numericString[] = { CERT_RDN_NUMERIC_STRING, 0 }; 1306 static const DWORD printableString[] = { CERT_RDN_PRINTABLE_STRING, 0 }; 1307 static const DWORD domainCompTypes[] = { CERT_RDN_IA5_STRING, 1308 CERT_RDN_UTF8_STRING, 0 }; 1309 static const CRYPT_DATA_BLOB ia5StringBlob = { sizeof(ia5String), 1310 (LPBYTE)ia5String }; 1311 static const CRYPT_DATA_BLOB numericStringBlob = { sizeof(numericString), 1312 (LPBYTE)numericString }; 1313 static const CRYPT_DATA_BLOB printableStringBlob = { sizeof(printableString), 1314 (LPBYTE)printableString }; 1315 static const CRYPT_DATA_BLOB domainCompTypesBlob = { sizeof(domainCompTypes), 1316 (LPBYTE)domainCompTypes }; 1317 1318 static const struct OIDInfoConstructor { 1319 DWORD dwGroupId; 1320 LPCSTR pszOID; 1321 UINT Algid; 1322 LPCWSTR pwszName; 1323 const CRYPT_DATA_BLOB *blob; 1324 const WCHAR *pwszCNGAlgid; 1325 const WCHAR *pwszCNGExtraAlgid; 1326 } oidInfoConstructors[] = { 1327 { 1, szOID_OIWSEC_sha1, CALG_SHA1, sha1, NULL }, 1328 { 1, szOID_OIWSEC_sha1, CALG_SHA1, sha, NULL }, 1329 { 1, szOID_OIWSEC_sha, CALG_SHA, sha, NULL }, 1330 { 1, szOID_RSA_MD5, CALG_MD5, md5, NULL }, 1331 { 1, szOID_RSA_MD4, CALG_MD4, md4, NULL }, 1332 { 1, szOID_RSA_MD2, CALG_MD2, md2, NULL }, 1333 /* NOTE: Windows Vista+ uses -1 instead of CALG_SHA_* following SHA entries. */ 1334 { 1, szOID_NIST_sha256, CALG_SHA_256, sha256, NULL }, 1335 { 1, szOID_NIST_sha384, CALG_SHA_384, sha384, NULL }, 1336 { 1, szOID_NIST_sha512, CALG_SHA_512, sha512, NULL }, 1337 1338 { 2, szOID_OIWSEC_desCBC, CALG_DES, des, NULL }, 1339 { 2, szOID_RSA_DES_EDE3_CBC, CALG_3DES, tripledes, NULL }, 1340 { 2, szOID_RSA_RC2CBC, CALG_RC2, rc2, NULL }, 1341 { 2, szOID_RSA_RC4, CALG_RC4, rc4, NULL }, 1342 { 2, szOID_RSA_SMIMEalgCMS3DESwrap, CALG_3DES, cms3deswrap, NULL }, 1343 { 2, szOID_RSA_SMIMEalgCMSRC2wrap, CALG_RC2, cmsrc2wrap, NULL }, 1344 1345 { 3, szOID_RSA_RSA, CALG_RSA_KEYX, RSA, NULL }, 1346 { 3, szOID_X957_DSA, CALG_DSS_SIGN, DSA, &noNullBlob }, 1347 { 3, szOID_ANSI_X942_DH, CALG_DH_SF, DH, &noNullBlob }, 1348 { 3, szOID_RSA_RSA, CALG_RSA_KEYX, RSA_KEYX, NULL }, 1349 { 3, szOID_RSA_RSA, CALG_RSA_SIGN, RSA, NULL }, 1350 { 3, szOID_RSA_RSA, CALG_RSA_SIGN, RSA_SIGN, NULL }, 1351 { 3, szOID_OIWSEC_dsa, CALG_DSS_SIGN, DSA, &noNullBlob }, 1352 { 3, szOID_OIWSEC_dsa, CALG_DSS_SIGN, DSS, &noNullBlob }, 1353 { 3, szOID_OIWSEC_dsa, CALG_DSS_SIGN, DSA_SIGN, &noNullBlob }, 1354 { 3, szOID_RSA_DH, CALG_DH_SF, DH, &noNullBlob }, 1355 { 3, szOID_OIWSEC_rsaXchg, CALG_RSA_KEYX, RSA_KEYX, NULL }, 1356 { 3, szOID_INFOSEC_mosaicKMandUpdSig, CALG_DSS_SIGN, mosaicKMandUpdSig, 1357 &mosaicFlagsBlob }, 1358 { 3, szOID_RSA_SMIMEalgESDH, CALG_DH_EPHEM, ESDH, &noNullBlob }, 1359 { 3, szOID_PKIX_NO_SIGNATURE, CALG_NO_SIGN, NO_SIGN, NULL }, 1360 1361 { 4, szOID_RSA_SHA1RSA, CALG_SHA1, sha1RSA, &rsaSignBlob }, 1362 { 4, szOID_RSA_SHA256RSA, CALG_SHA_256, sha256RSA, &rsaSignBlob }, 1363 { 4, szOID_RSA_SHA384RSA, CALG_SHA_384, sha384RSA, &rsaSignBlob }, 1364 { 4, szOID_RSA_SHA512RSA, CALG_SHA_512, sha512RSA, &rsaSignBlob }, 1365 { 4, szOID_RSA_MD5RSA, CALG_MD5, md5RSA, &rsaSignBlob }, 1366 { 4, szOID_X957_SHA1DSA, CALG_SHA1, sha1DSA, &dssSignBlob }, 1367 { 4, szOID_OIWSEC_sha1RSASign, CALG_SHA1, sha1RSA, &rsaSignBlob }, 1368 { 4, szOID_OIWSEC_sha1RSASign, CALG_SHA1, shaRSA, &rsaSignBlob }, 1369 { 4, szOID_OIWSEC_shaRSA, CALG_SHA1, shaRSA, &rsaSignBlob }, 1370 { 4, szOID_OIWSEC_md5RSA, CALG_MD5, md5RSA, &rsaSignBlob }, 1371 { 4, szOID_RSA_MD2RSA, CALG_MD2, md2RSA, &rsaSignBlob }, 1372 { 4, szOID_RSA_MD4RSA, CALG_MD4, md4RSA, &rsaSignBlob }, 1373 { 4, szOID_OIWSEC_md4RSA, CALG_MD4, md4RSA, &rsaSignBlob }, 1374 { 4, szOID_OIWSEC_md4RSA2, CALG_MD4, md4RSA, &rsaSignBlob }, 1375 { 4, szOID_OIWDIR_md2RSA, CALG_MD2, md2RSA, &rsaSignBlob }, 1376 { 4, szOID_OIWSEC_shaDSA, CALG_SHA1, sha1DSA, &dssSignBlob }, 1377 { 4, szOID_OIWSEC_shaDSA, CALG_SHA1, shaDSA, &dssSignBlob }, 1378 { 4, szOID_OIWSEC_dsaSHA1, CALG_SHA1, dsaSHA1, &dssSignBlob }, 1379 { 4, szOID_INFOSEC_mosaicUpdatedSig, CALG_SHA1, mosaicUpdatedSig, 1380 &mosaicSignBlob }, 1381 { 4, szOID_ECDSA_SHA256, CALG_OID_INFO_CNG_ONLY, sha256ECDSA, &ecdsaSignBlob, 1382 BCRYPT_SHA256_ALGORITHM, CRYPT_OID_INFO_ECC_PARAMETERS_ALGORITHM }, 1383 { 4, szOID_ECDSA_SHA384, CALG_OID_INFO_CNG_ONLY, sha384ECDSA, &ecdsaSignBlob, 1384 BCRYPT_SHA384_ALGORITHM, CRYPT_OID_INFO_ECC_PARAMETERS_ALGORITHM }, 1385 1386 { 5, szOID_COMMON_NAME, 0, CN, NULL }, 1387 { 5, szOID_LOCALITY_NAME, 0, L, NULL }, 1388 { 5, szOID_ORGANIZATION_NAME, 0, O, NULL }, 1389 { 5, szOID_ORGANIZATIONAL_UNIT_NAME, 0, OU, NULL }, 1390 { 5, szOID_RSA_emailAddr, 0, E, &ia5StringBlob }, 1391 { 5, szOID_RSA_emailAddr, 0, Email, &ia5StringBlob }, 1392 { 5, szOID_COUNTRY_NAME, 0, C, &printableStringBlob }, 1393 { 5, szOID_STATE_OR_PROVINCE_NAME, 0, S, NULL }, 1394 { 5, szOID_STATE_OR_PROVINCE_NAME, 0, ST, NULL }, 1395 { 5, szOID_STREET_ADDRESS, 0, STREET, NULL }, 1396 { 5, szOID_TITLE, 0, T, NULL }, 1397 { 5, szOID_TITLE, 0, Title, NULL }, 1398 { 5, szOID_GIVEN_NAME, 0, G, NULL }, 1399 { 5, szOID_GIVEN_NAME, 0, GN, NULL }, 1400 { 5, szOID_GIVEN_NAME, 0, GivenName, NULL }, 1401 { 5, szOID_INITIALS, 0, I, NULL }, 1402 { 5, szOID_INITIALS, 0, Initials, NULL }, 1403 { 5, szOID_SUR_NAME, 0, SN, NULL }, 1404 { 5, szOID_DOMAIN_COMPONENT, 0, DC, &domainCompTypesBlob }, 1405 { 5, szOID_DESCRIPTION, 0, Description, NULL }, 1406 { 5, szOID_POSTAL_CODE, 0, PostalCode, NULL }, 1407 { 5, szOID_POST_OFFICE_BOX, 0, POBox, NULL }, 1408 { 5, szOID_TELEPHONE_NUMBER, 0, Phone, &printableStringBlob }, 1409 { 5, szOID_X21_ADDRESS, 0, X21Address, &numericStringBlob }, 1410 { 5, szOID_DN_QUALIFIER, 0, dnQualifier, NULL }, 1411 { 5, szOID_DEVICE_SERIAL_NUMBER, 0, SERIALNUMBER, NULL }, 1412 1413 { 6, szOID_AUTHORITY_KEY_IDENTIFIER2, 0, (LPCWSTR)IDS_AUTHORITY_KEY_ID, NULL }, 1414 { 6, szOID_AUTHORITY_KEY_IDENTIFIER, 0, (LPCWSTR)IDS_AUTHORITY_KEY_ID, NULL }, 1415 { 6, szOID_KEY_ATTRIBUTES, 0, (LPCWSTR)IDS_KEY_ATTRIBUTES, NULL }, 1416 { 6, szOID_KEY_USAGE_RESTRICTION, 0, (LPCWSTR)IDS_KEY_USAGE_RESTRICTION, NULL }, 1417 { 6, szOID_SUBJECT_ALT_NAME2, 0, (LPCWSTR)IDS_SUBJECT_ALT_NAME, NULL }, 1418 { 6, szOID_SUBJECT_ALT_NAME, 0, (LPCWSTR)IDS_SUBJECT_ALT_NAME, NULL }, 1419 { 6, szOID_ISSUER_ALT_NAME2, 0, (LPCWSTR)IDS_ISSUER_ALT_NAME, NULL }, 1420 { 6, szOID_ISSUER_ALT_NAME2, 0, (LPCWSTR)IDS_ISSUER_ALT_NAME, NULL }, 1421 { 6, szOID_BASIC_CONSTRAINTS2, 0, (LPCWSTR)IDS_BASIC_CONSTRAINTS, NULL }, 1422 { 6, szOID_BASIC_CONSTRAINTS, 0, (LPCWSTR)IDS_BASIC_CONSTRAINTS, NULL }, 1423 { 6, szOID_KEY_USAGE, 0, (LPCWSTR)IDS_KEY_USAGE, NULL }, 1424 { 6, szOID_CERT_POLICIES, 0, (LPCWSTR)IDS_CERT_POLICIES, NULL }, 1425 { 6, szOID_SUBJECT_KEY_IDENTIFIER, 0, (LPCWSTR)IDS_SUBJECT_KEY_IDENTIFIER, NULL }, 1426 { 6, szOID_CRL_REASON_CODE, 0, (LPCWSTR)IDS_CRL_REASON_CODE, NULL }, 1427 { 6, szOID_CRL_DIST_POINTS, 0, (LPCWSTR)IDS_CRL_DIST_POINTS, NULL }, 1428 { 6, szOID_ENHANCED_KEY_USAGE, 0, (LPCWSTR)IDS_ENHANCED_KEY_USAGE, NULL }, 1429 { 6, szOID_AUTHORITY_INFO_ACCESS, 0, (LPCWSTR)IDS_AUTHORITY_INFO_ACCESS, NULL }, 1430 { 6, szOID_CERT_EXTENSIONS, 0, (LPCWSTR)IDS_CERT_EXTENSIONS, NULL }, 1431 { 6, szOID_RSA_certExtensions, 0, (LPCWSTR)IDS_CERT_EXTENSIONS, NULL }, 1432 { 6, szOID_NEXT_UPDATE_LOCATION, 0, (LPCWSTR)IDS_NEXT_UPDATE_LOCATION, NULL }, 1433 { 6, szOID_YESNO_TRUST_ATTR, 0, (LPCWSTR)IDS_YES_OR_NO_TRUST, NULL }, 1434 { 6, szOID_RSA_emailAddr, 0, (LPCWSTR)IDS_EMAIL_ADDRESS, NULL }, 1435 { 6, szOID_RSA_unstructName, 0, (LPCWSTR)IDS_UNSTRUCTURED_NAME, NULL }, 1436 { 6, szOID_RSA_contentType, 0, (LPCWSTR)IDS_CONTENT_TYPE, NULL }, 1437 { 6, szOID_RSA_messageDigest, 0, (LPCWSTR)IDS_MESSAGE_DIGEST, NULL }, 1438 { 6, szOID_RSA_signingTime, 0, (LPCWSTR)IDS_SIGNING_TIME, NULL }, 1439 { 6, szOID_RSA_counterSign, 0, (LPCWSTR)IDS_COUNTER_SIGN, NULL }, 1440 { 6, szOID_RSA_challengePwd, 0, (LPCWSTR)IDS_CHALLENGE_PASSWORD, NULL }, 1441 { 6, szOID_RSA_unstructAddr, 0, (LPCWSTR)IDS_UNSTRUCTURED_ADDRESS, NULL }, 1442 { 6, szOID_RSA_SMIMECapabilities, 0, (LPCWSTR)IDS_SMIME_CAPABILITIES, NULL }, 1443 { 6, szOID_RSA_preferSignedData, 0, (LPCWSTR)IDS_PREFER_SIGNED_DATA, NULL }, 1444 { 6, szOID_PKIX_POLICY_QUALIFIER_CPS, 0, (LPCWSTR)IDS_CPS, NULL }, 1445 { 6, szOID_PKIX_POLICY_QUALIFIER_USERNOTICE, 0, (LPCWSTR)IDS_USER_NOTICE, NULL }, 1446 { 6, szOID_PKIX_OCSP, 0, (LPCWSTR)IDS_OCSP, NULL }, 1447 { 6, szOID_PKIX_CA_ISSUERS, 0, (LPCWSTR)IDS_CA_ISSUER, NULL }, 1448 { 6, szOID_ENROLL_CERTTYPE_EXTENSION, 0, (LPCWSTR)IDS_CERT_TEMPLATE_NAME, NULL }, 1449 { 6, szOID_ENROLL_CERTTYPE_EXTENSION, 0, (LPCWSTR)IDS_CERT_TYPE, NULL }, 1450 { 6, szOID_CERT_MANIFOLD, 0, (LPCWSTR)IDS_CERT_MANIFOLD, NULL }, 1451 { 6, szOID_NETSCAPE_CERT_TYPE, 0, (LPCWSTR)IDS_NETSCAPE_CERT_TYPE, NULL }, 1452 { 6, szOID_NETSCAPE_BASE_URL, 0, (LPCWSTR)IDS_NETSCAPE_BASE_URL, NULL }, 1453 { 6, szOID_NETSCAPE_REVOCATION_URL, 0, (LPCWSTR)IDS_NETSCAPE_REVOCATION_URL, NULL }, 1454 { 6, szOID_NETSCAPE_CA_REVOCATION_URL, 0, (LPCWSTR)IDS_NETSCAPE_CA_REVOCATION_URL, NULL }, 1455 { 6, szOID_NETSCAPE_CERT_RENEWAL_URL, 0, (LPCWSTR)IDS_NETSCAPE_CERT_RENEWAL_URL, NULL }, 1456 { 6, szOID_NETSCAPE_CA_POLICY_URL, 0, (LPCWSTR)IDS_NETSCAPE_CA_POLICY_URL, NULL }, 1457 { 6, szOID_NETSCAPE_SSL_SERVER_NAME, 0, (LPCWSTR)IDS_NETSCAPE_SSL_SERVER_NAME, NULL }, 1458 { 6, szOID_NETSCAPE_COMMENT, 0, (LPCWSTR)IDS_NETSCAPE_COMMENT, NULL }, 1459 { 6, "1.3.6.1.4.1.311.2.1.10", 0, SpcSpAgencyInfo, NULL }, 1460 { 6, "1.3.6.1.4.1.311.2.1.27", 0, SpcFinancialCriteria, NULL }, 1461 { 6, "1.3.6.1.4.1.311.2.1.26", 0, SpcMinimalCriteria, NULL }, 1462 { 6, szOID_COUNTRY_NAME, 0, (LPCWSTR)IDS_COUNTRY, NULL }, 1463 { 6, szOID_ORGANIZATION_NAME, 0, (LPCWSTR)IDS_ORGANIZATION, NULL }, 1464 { 6, szOID_ORGANIZATIONAL_UNIT_NAME, 0, (LPCWSTR)IDS_ORGANIZATIONAL_UNIT, NULL }, 1465 { 6, szOID_COMMON_NAME, 0, (LPCWSTR)IDS_COMMON_NAME, NULL }, 1466 { 6, szOID_LOCALITY_NAME, 0, (LPCWSTR)IDS_LOCALITY, NULL }, 1467 { 6, szOID_STATE_OR_PROVINCE_NAME, 0, (LPCWSTR)IDS_STATE_OR_PROVINCE, NULL }, 1468 { 6, szOID_TITLE, 0, (LPCWSTR)IDS_TITLE, NULL }, 1469 { 6, szOID_GIVEN_NAME, 0, (LPCWSTR)IDS_GIVEN_NAME, NULL }, 1470 { 6, szOID_INITIALS, 0, (LPCWSTR)IDS_INITIALS, NULL }, 1471 { 6, szOID_SUR_NAME, 0, (LPCWSTR)IDS_SUR_NAME, NULL }, 1472 { 6, szOID_DOMAIN_COMPONENT, 0, (LPCWSTR)IDS_DOMAIN_COMPONENT, NULL }, 1473 { 6, szOID_STREET_ADDRESS, 0, (LPCWSTR)IDS_STREET_ADDRESS, NULL }, 1474 { 6, szOID_DEVICE_SERIAL_NUMBER, 0, (LPCWSTR)IDS_SERIAL_NUMBER, NULL }, 1475 { 6, szOID_CERTSRV_CA_VERSION, 0, (LPCWSTR)IDS_CA_VERSION, NULL }, 1476 { 6, szOID_CERTSRV_CROSSCA_VERSION, 0, (LPCWSTR)IDS_CROSS_CA_VERSION, NULL }, 1477 { 6, szOID_SERIALIZED, 0, (LPCWSTR)IDS_SERIALIZED_SIG_SERIAL_NUMBER, NULL }, 1478 { 6, szOID_NT_PRINCIPAL_NAME, 0, (LPCWSTR)IDS_PRINCIPAL_NAME, NULL }, 1479 { 6, szOID_PRODUCT_UPDATE, 0, (LPCWSTR)IDS_WINDOWS_PRODUCT_UPDATE, NULL }, 1480 { 6, szOID_ENROLLMENT_NAME_VALUE_PAIR, 0, (LPCWSTR)IDS_ENROLLMENT_NAME_VALUE_PAIR, NULL }, 1481 { 6, szOID_OS_VERSION, 0, (LPCWSTR)IDS_OS_VERSION, NULL }, 1482 { 6, szOID_ENROLLMENT_CSP_PROVIDER, 0, (LPCWSTR)IDS_ENROLLMENT_CSP, NULL }, 1483 { 6, szOID_CRL_NUMBER, 0, (LPCWSTR)IDS_CRL_NUMBER, NULL }, 1484 { 6, szOID_DELTA_CRL_INDICATOR, 0, (LPCWSTR)IDS_DELTA_CRL_INDICATOR, NULL }, 1485 { 6, szOID_ISSUING_DIST_POINT, 0, (LPCWSTR)IDS_ISSUING_DIST_POINT, NULL }, 1486 { 6, szOID_FRESHEST_CRL, 0, (LPCWSTR)IDS_FRESHEST_CRL, NULL }, 1487 { 6, szOID_NAME_CONSTRAINTS, 0, (LPCWSTR)IDS_NAME_CONSTRAINTS, NULL }, 1488 { 6, szOID_POLICY_MAPPINGS, 0, (LPCWSTR)IDS_POLICY_MAPPINGS, NULL }, 1489 { 6, szOID_LEGACY_POLICY_MAPPINGS, 0, (LPCWSTR)IDS_POLICY_MAPPINGS, NULL }, 1490 { 6, szOID_POLICY_CONSTRAINTS, 0, (LPCWSTR)IDS_POLICY_CONSTRAINTS, NULL }, 1491 { 6, szOID_CROSS_CERT_DIST_POINTS, 0, (LPCWSTR)IDS_CROSS_CERT_DIST_POINTS, NULL }, 1492 { 6, szOID_APPLICATION_CERT_POLICIES, 0, (LPCWSTR)IDS_APPLICATION_POLICIES, NULL }, 1493 { 6, szOID_APPLICATION_POLICY_MAPPINGS, 0, (LPCWSTR)IDS_APPLICATION_POLICY_MAPPINGS, NULL }, 1494 { 6, szOID_APPLICATION_POLICY_CONSTRAINTS, 0, (LPCWSTR)IDS_APPLICATION_POLICY_CONSTRAINTS, NULL }, 1495 { 6, szOID_CT_PKI_DATA, 0, (LPCWSTR)IDS_CMC_DATA, NULL }, 1496 { 6, szOID_CT_PKI_RESPONSE, 0, (LPCWSTR)IDS_CMC_RESPONSE, NULL }, 1497 { 6, szOID_CMC, 0, (LPCWSTR)IDS_UNSIGNED_CMC_REQUEST, NULL }, 1498 { 6, szOID_CMC_STATUS_INFO, 0, (LPCWSTR)IDS_CMC_STATUS_INFO, NULL }, 1499 { 6, szOID_CMC_ADD_EXTENSIONS, 0, (LPCWSTR)IDS_CMC_EXTENSIONS, NULL }, 1500 { 6, szOID_CTL, 0, (LPCWSTR)IDS_CMC_ATTRIBUTES, NULL }, 1501 { 6, szOID_RSA_data, 0, (LPCWSTR)IDS_PKCS_7_DATA, NULL }, 1502 { 6, szOID_RSA_signedData, 0, (LPCWSTR)IDS_PKCS_7_SIGNED, NULL }, 1503 { 6, szOID_RSA_envelopedData, 0, (LPCWSTR)IDS_PKCS_7_ENVELOPED, NULL }, 1504 { 6, szOID_RSA_signEnvData, 0, (LPCWSTR)IDS_PKCS_7_SIGNED_ENVELOPED, NULL }, 1505 { 6, szOID_RSA_digestedData, 0, (LPCWSTR)IDS_PKCS_7_DIGESTED, NULL }, 1506 { 6, szOID_RSA_encryptedData, 0, (LPCWSTR)IDS_PKCS_7_ENCRYPTED, NULL }, 1507 { 6, szOID_CERTSRV_PREVIOUS_CERT_HASH, 0, (LPCWSTR)IDS_PREVIOUS_CA_CERT_HASH, NULL }, 1508 { 6, szOID_CRL_VIRTUAL_BASE, 0, (LPCWSTR)IDS_CRL_VIRTUAL_BASE, NULL }, 1509 { 6, szOID_CRL_NEXT_PUBLISH, 0, (LPCWSTR)IDS_CRL_NEXT_PUBLISH, NULL }, 1510 { 6, szOID_KP_CA_EXCHANGE, 0, (LPCWSTR)IDS_CA_EXCHANGE, NULL }, 1511 { 6, szOID_KP_KEY_RECOVERY_AGENT, 0, (LPCWSTR)IDS_KEY_RECOVERY_AGENT, NULL }, 1512 { 6, szOID_CERTIFICATE_TEMPLATE, 0, (LPCWSTR)IDS_CERTIFICATE_TEMPLATE, NULL }, 1513 { 6, szOID_ENTERPRISE_OID_ROOT, 0, (LPCWSTR)IDS_ENTERPRISE_ROOT_OID, NULL }, 1514 { 6, szOID_RDN_DUMMY_SIGNER, 0, (LPCWSTR)IDS_RDN_DUMMY_SIGNER, NULL }, 1515 { 6, szOID_ARCHIVED_KEY_ATTR, 0, (LPCWSTR)IDS_ARCHIVED_KEY_ATTR, NULL }, 1516 { 6, szOID_CRL_SELF_CDP, 0, (LPCWSTR)IDS_CRL_SELF_CDP, NULL }, 1517 { 6, szOID_REQUIRE_CERT_CHAIN_POLICY, 0, (LPCWSTR)IDS_REQUIRE_CERT_CHAIN_POLICY, NULL }, 1518 { 6, szOID_CMC_TRANSACTION_ID, 0, (LPCWSTR)IDS_TRANSACTION_ID, NULL }, 1519 { 6, szOID_CMC_SENDER_NONCE, 0, (LPCWSTR)IDS_SENDER_NONCE, NULL }, 1520 { 6, szOID_CMC_RECIPIENT_NONCE, 0, (LPCWSTR)IDS_RECIPIENT_NONCE, NULL }, 1521 { 6, szOID_CMC_REG_INFO, 0, (LPCWSTR)IDS_REG_INFO, NULL }, 1522 { 6, szOID_CMC_GET_CERT, 0, (LPCWSTR)IDS_GET_CERTIFICATE, NULL }, 1523 { 6, szOID_CMC_GET_CRL, 0, (LPCWSTR)IDS_GET_CRL, NULL }, 1524 { 6, szOID_CMC_REVOKE_REQUEST, 0, (LPCWSTR)IDS_REVOKE_REQUEST, NULL }, 1525 { 6, szOID_CMC_QUERY_PENDING, 0, (LPCWSTR)IDS_QUERY_PENDING, NULL }, 1526 { 6, szOID_SORTED_CTL, 0, (LPCWSTR)IDS_SORTED_CTL, NULL }, 1527 { 6, szOID_ARCHIVED_KEY_CERT_HASH, 0, (LPCWSTR)IDS_ARCHIVED_KEY_CERT_HASH, NULL }, 1528 { 6, szOID_PRIVATEKEY_USAGE_PERIOD, 0, (LPCWSTR)IDS_PRIVATE_KEY_USAGE_PERIOD, NULL }, 1529 { 6, szOID_REQUEST_CLIENT_INFO, 0, (LPCWSTR)IDS_CLIENT_INFORMATION, NULL }, 1530 1531 { 7, szOID_PKIX_KP_SERVER_AUTH, 0, (LPCWSTR)IDS_SERVER_AUTHENTICATION, NULL }, 1532 { 7, szOID_PKIX_KP_CLIENT_AUTH, 0, (LPCWSTR)IDS_CLIENT_AUTHENTICATION, NULL }, 1533 { 7, szOID_PKIX_KP_CODE_SIGNING, 0, (LPCWSTR)IDS_CODE_SIGNING, NULL }, 1534 { 7, szOID_PKIX_KP_EMAIL_PROTECTION, 0, (LPCWSTR)IDS_SECURE_EMAIL, NULL }, 1535 { 7, szOID_PKIX_KP_TIMESTAMP_SIGNING, 0, (LPCWSTR)IDS_TIME_STAMPING, NULL }, 1536 { 7, szOID_KP_CTL_USAGE_SIGNING, 0, (LPCWSTR)IDS_MICROSOFT_TRUST_LIST_SIGNING, NULL }, 1537 { 7, szOID_KP_TIME_STAMP_SIGNING, 0, (LPCWSTR)IDS_MICROSOFT_TIME_STAMPING, NULL }, 1538 { 7, szOID_PKIX_KP_IPSEC_END_SYSTEM, 0, (LPCWSTR)IDS_IPSEC_END_SYSTEM, NULL }, 1539 { 7, szOID_PKIX_KP_IPSEC_TUNNEL, 0, (LPCWSTR)IDS_IPSEC_TUNNEL, NULL }, 1540 { 7, szOID_PKIX_KP_IPSEC_USER, 0, (LPCWSTR)IDS_IPSEC_USER, NULL }, 1541 { 7, szOID_KP_EFS, 0, (LPCWSTR)IDS_EFS, NULL }, 1542 { 7, szOID_WHQL_CRYPTO, 0, (LPCWSTR)IDS_WHQL_CRYPTO, NULL }, 1543 { 7, szOID_NT5_CRYPTO, 0, (LPCWSTR)IDS_NT5_CRYPTO, NULL }, 1544 { 7, szOID_OEM_WHQL_CRYPTO, 0, (LPCWSTR)IDS_OEM_WHQL_CRYPTO, NULL }, 1545 { 7, szOID_EMBEDDED_NT_CRYPTO, 0, (LPCWSTR)IDS_EMBEDDED_NT_CRYPTO, NULL }, 1546 { 7, szOID_LICENSES, 0, (LPCWSTR)IDS_KEY_PACK_LICENSES, NULL }, 1547 { 7, szOID_LICENSE_SERVER, 0, (LPCWSTR)IDS_LICENSE_SERVER, NULL }, 1548 { 7, szOID_KP_SMARTCARD_LOGON, 0, (LPCWSTR)IDS_SMART_CARD_LOGON, NULL }, 1549 { 7, szOID_DRM, 0, (LPCWSTR)IDS_DIGITAL_RIGHTS, NULL }, 1550 { 7, szOID_KP_QUALIFIED_SUBORDINATION, 0, (LPCWSTR)IDS_QUALIFIED_SUBORDINATION, NULL }, 1551 { 7, szOID_KP_KEY_RECOVERY, 0, (LPCWSTR)IDS_KEY_RECOVERY, NULL }, 1552 { 7, szOID_KP_DOCUMENT_SIGNING, 0, (LPCWSTR)IDS_DOCUMENT_SIGNING, NULL }, 1553 { 7, szOID_IPSEC_KP_IKE_INTERMEDIATE, 0, (LPCWSTR)IDS_IPSEC_IKE_INTERMEDIATE, NULL }, 1554 { 7, szOID_EFS_RECOVERY, 0, (LPCWSTR)IDS_FILE_RECOVERY, NULL }, 1555 { 7, szOID_ROOT_LIST_SIGNER, 0, (LPCWSTR)IDS_ROOT_LIST_SIGNER, NULL }, 1556 { 7, szOID_ANY_APPLICATION_POLICY, 0, (LPCWSTR)IDS_ANY_APPLICATION_POLICIES, NULL }, 1557 { 7, szOID_DS_EMAIL_REPLICATION, 0, (LPCWSTR)IDS_DS_EMAIL_REPLICATION, NULL }, 1558 { 7, szOID_ENROLLMENT_AGENT, 0, (LPCWSTR)IDS_ENROLLMENT_AGENT, NULL }, 1559 { 7, szOID_KP_KEY_RECOVERY_AGENT, 0, (LPCWSTR)IDS_KEY_RECOVERY_AGENT, NULL }, 1560 { 7, szOID_KP_CA_EXCHANGE, 0, (LPCWSTR)IDS_CA_EXCHANGE, NULL }, 1561 { 7, szOID_KP_LIFETIME_SIGNING, 0, (LPCWSTR)IDS_LIFETIME_SIGNING, NULL }, 1562 1563 { 8, szOID_ANY_CERT_POLICY, 0, (LPCWSTR)IDS_ANY_CERT_POLICY, NULL }, 1564 }; 1565 1566 struct OIDInfo { 1567 CRYPT_OID_INFO info; 1568 struct list entry; 1569 }; 1570 1571 static struct OIDInfo *read_oid_info(HKEY root, char *key_name, DWORD *flags) 1572 { 1573 HKEY key; 1574 DWORD len, oid_len, name_len = 0, extra_len = 0, cngalgid_len = 0, cngextra_len = 0, group_id = 0; 1575 struct OIDInfo *info; 1576 char *p; 1577 1578 if (RegOpenKeyExA(root, key_name, 0, KEY_READ, &key)) 1579 return NULL; 1580 1581 p = strchr(key_name, '!'); 1582 if (p) 1583 { 1584 group_id = strtol(p + 1, NULL, 10); 1585 *p = 0; 1586 } 1587 1588 oid_len = strlen(key_name) + 1; 1589 1590 RegQueryValueExW(key, nameW, NULL, NULL, NULL, &name_len); 1591 RegQueryValueExW(key, extraW, NULL, NULL, NULL, &extra_len); 1592 RegQueryValueExW(key, cngalgidW, NULL, NULL, NULL, &cngalgid_len); 1593 RegQueryValueExW(key, cngextraalgidW, NULL, NULL, NULL, &cngextra_len); 1594 1595 info = CryptMemAlloc(sizeof(*info) + oid_len + name_len + extra_len + cngalgid_len + cngextra_len); 1596 if (info) 1597 { 1598 *flags = 0; 1599 len = sizeof(*flags); 1600 RegQueryValueExW(key, flagsW, NULL, NULL, (BYTE *)flags, &len); 1601 1602 memset(info, 0, sizeof(*info)); 1603 info->info.cbSize = sizeof(info->info); 1604 1605 p = (char *)(info + 1); 1606 1607 info->info.pszOID = p; 1608 strcpy((char *)info->info.pszOID, key_name); 1609 p += oid_len; 1610 1611 if (name_len) 1612 { 1613 info->info.pwszName = (WCHAR *)p; 1614 RegQueryValueExW(key, nameW, NULL, NULL, (BYTE *)info->info.pwszName, &name_len); 1615 p += name_len; 1616 } 1617 1618 info->info.dwGroupId = group_id; 1619 1620 len = sizeof(info->info.u.Algid); 1621 RegQueryValueExW(key, algidW, NULL, NULL, (BYTE *)&info->info.u.Algid, &len); 1622 1623 if (extra_len) 1624 { 1625 info->info.ExtraInfo.cbData = extra_len; 1626 info->info.ExtraInfo.pbData = (BYTE *)p; 1627 RegQueryValueExW(key, extraW, NULL, NULL, info->info.ExtraInfo.pbData, &extra_len); 1628 p += extra_len; 1629 } 1630 1631 if (cngalgid_len) 1632 { 1633 info->info.pwszCNGAlgid = (WCHAR *)p; 1634 RegQueryValueExW(key, cngalgidW, NULL, NULL, (BYTE *)info->info.pwszCNGAlgid, &cngalgid_len); 1635 p += cngalgid_len; 1636 } 1637 1638 if (cngextra_len) 1639 { 1640 info->info.pwszCNGExtraAlgid = (WCHAR *)p; 1641 RegQueryValueExW(key, cngextraalgidW, NULL, NULL, (BYTE *)info->info.pwszCNGExtraAlgid, &cngalgid_len); 1642 } 1643 } 1644 1645 RegCloseKey(key); 1646 1647 return info; 1648 } 1649 1650 static void init_registered_oid_info(void) 1651 { 1652 DWORD err, idx; 1653 HKEY root; 1654 1655 err = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptDllFindOIDInfo", 1656 0, KEY_ALL_ACCESS, &root); 1657 if (err != ERROR_SUCCESS) return; 1658 1659 idx = 0; 1660 for (;;) 1661 { 1662 char key_name[MAX_PATH]; 1663 struct OIDInfo *info; 1664 DWORD flags; 1665 1666 err = RegEnumKeyA(root, idx++, key_name, MAX_PATH); 1667 if (err == ERROR_NO_MORE_ITEMS) 1668 break; 1669 1670 if (err == ERROR_SUCCESS) 1671 { 1672 if ((info = read_oid_info(root, key_name, &flags))) 1673 { 1674 TRACE("adding oid %s, name %s, groupid %u, algid %u, extra %u, CNG algid %s, CNG extra %s\n", 1675 debugstr_a(info->info.pszOID), debugstr_w(info->info.pwszName), 1676 info->info.dwGroupId, info->info.u.Algid, info->info.ExtraInfo.cbData, 1677 debugstr_w(info->info.pwszCNGAlgid), debugstr_w(info->info.pwszCNGExtraAlgid)); 1678 1679 if (flags & CRYPT_INSTALL_OID_INFO_BEFORE_FLAG) 1680 list_add_head(&oidInfo, &info->entry); 1681 else 1682 list_add_tail(&oidInfo, &info->entry); 1683 } 1684 } 1685 } 1686 1687 RegCloseKey(root); 1688 } 1689 1690 static void init_oid_info(void) 1691 { 1692 DWORD i; 1693 1694 oid_init_localizednames(); 1695 for (i = 0; i < ARRAY_SIZE(oidInfoConstructors); i++) 1696 { 1697 if (!IS_INTRESOURCE(oidInfoConstructors[i].pwszName)) 1698 { 1699 struct OIDInfo *info; 1700 1701 /* The name is a static string, so just use the same pointer */ 1702 info = CryptMemAlloc(sizeof(struct OIDInfo)); 1703 if (info) 1704 { 1705 memset(info, 0, sizeof(*info)); 1706 info->info.cbSize = sizeof(CRYPT_OID_INFO); 1707 info->info.pszOID = oidInfoConstructors[i].pszOID; 1708 info->info.pwszName = oidInfoConstructors[i].pwszName; 1709 info->info.dwGroupId = oidInfoConstructors[i].dwGroupId; 1710 info->info.u.Algid = oidInfoConstructors[i].Algid; 1711 if (oidInfoConstructors[i].blob) 1712 { 1713 info->info.ExtraInfo.cbData = 1714 oidInfoConstructors[i].blob->cbData; 1715 info->info.ExtraInfo.pbData = 1716 oidInfoConstructors[i].blob->pbData; 1717 } 1718 info->info.pwszCNGAlgid = oidInfoConstructors[i].pwszCNGAlgid; 1719 info->info.pwszCNGExtraAlgid = oidInfoConstructors[i].pwszCNGExtraAlgid; 1720 list_add_tail(&oidInfo, &info->entry); 1721 } 1722 } 1723 else 1724 { 1725 LPCWSTR stringresource; 1726 int len = LoadStringW(hInstance, 1727 (UINT_PTR)oidInfoConstructors[i].pwszName, 1728 (LPWSTR)&stringresource, 0); 1729 1730 if (len) 1731 { 1732 struct OIDInfo *info = CryptMemAlloc(sizeof(struct OIDInfo) + 1733 (len + 1) * sizeof(WCHAR)); 1734 1735 if (info) 1736 { 1737 memset(info, 0, sizeof(*info)); 1738 info->info.cbSize = sizeof(CRYPT_OID_INFO); 1739 info->info.pszOID = oidInfoConstructors[i].pszOID; 1740 info->info.pwszName = (LPWSTR)(info + 1); 1741 info->info.dwGroupId = oidInfoConstructors[i].dwGroupId; 1742 info->info.u.Algid = oidInfoConstructors[i].Algid; 1743 memcpy(info + 1, stringresource, len*sizeof(WCHAR)); 1744 ((LPWSTR)(info + 1))[len] = 0; 1745 if (oidInfoConstructors[i].blob) 1746 { 1747 info->info.ExtraInfo.cbData = 1748 oidInfoConstructors[i].blob->cbData; 1749 info->info.ExtraInfo.pbData = 1750 oidInfoConstructors[i].blob->pbData; 1751 } 1752 info->info.pwszCNGAlgid = oidInfoConstructors[i].pwszCNGAlgid; 1753 info->info.pwszCNGExtraAlgid = oidInfoConstructors[i].pwszCNGExtraAlgid; 1754 list_add_tail(&oidInfo, &info->entry); 1755 } 1756 } 1757 } 1758 } 1759 } 1760 1761 static void free_oid_info(void) 1762 { 1763 struct OIDInfo *info, *next; 1764 1765 LIST_FOR_EACH_ENTRY_SAFE(info, next, &oidInfo, struct OIDInfo, entry) 1766 { 1767 list_remove(&info->entry); 1768 CryptMemFree(info); 1769 } 1770 DeleteCriticalSection(&oidInfoCS); 1771 } 1772 1773 /*********************************************************************** 1774 * CryptEnumOIDInfo (CRYPT32.@) 1775 */ 1776 BOOL WINAPI CryptEnumOIDInfo(DWORD dwGroupId, DWORD dwFlags, void *pvArg, 1777 PFN_CRYPT_ENUM_OID_INFO pfnEnumOIDInfo) 1778 { 1779 BOOL ret = TRUE; 1780 struct OIDInfo *info; 1781 1782 TRACE("(%d, %08x, %p, %p)\n", dwGroupId, dwFlags, pvArg, 1783 pfnEnumOIDInfo); 1784 1785 EnterCriticalSection(&oidInfoCS); 1786 LIST_FOR_EACH_ENTRY(info, &oidInfo, struct OIDInfo, entry) 1787 { 1788 if (!dwGroupId || dwGroupId == info->info.dwGroupId) 1789 { 1790 ret = pfnEnumOIDInfo(&info->info, pvArg); 1791 if (!ret) 1792 break; 1793 } 1794 } 1795 LeaveCriticalSection(&oidInfoCS); 1796 return ret; 1797 } 1798 1799 PCCRYPT_OID_INFO WINAPI CryptFindOIDInfo(DWORD dwKeyType, void *pvKey, 1800 DWORD dwGroupId) 1801 { 1802 PCCRYPT_OID_INFO ret = NULL; 1803 1804 TRACE("(%d, %p, %d)\n", dwKeyType, pvKey, dwGroupId); 1805 1806 switch(dwKeyType) 1807 { 1808 case CRYPT_OID_INFO_ALGID_KEY: 1809 { 1810 struct OIDInfo *info; 1811 1812 TRACE("CRYPT_OID_INFO_ALGID_KEY: %d\n", *(DWORD *)pvKey); 1813 EnterCriticalSection(&oidInfoCS); 1814 LIST_FOR_EACH_ENTRY(info, &oidInfo, struct OIDInfo, entry) 1815 { 1816 if (info->info.u.Algid == *(DWORD *)pvKey && 1817 (!dwGroupId || info->info.dwGroupId == dwGroupId)) 1818 { 1819 ret = &info->info; 1820 break; 1821 } 1822 } 1823 LeaveCriticalSection(&oidInfoCS); 1824 break; 1825 } 1826 case CRYPT_OID_INFO_NAME_KEY: 1827 { 1828 struct OIDInfo *info; 1829 1830 TRACE("CRYPT_OID_INFO_NAME_KEY: %s\n", debugstr_w(pvKey)); 1831 EnterCriticalSection(&oidInfoCS); 1832 LIST_FOR_EACH_ENTRY(info, &oidInfo, struct OIDInfo, entry) 1833 { 1834 if (!lstrcmpW(info->info.pwszName, pvKey) && 1835 (!dwGroupId || info->info.dwGroupId == dwGroupId)) 1836 { 1837 ret = &info->info; 1838 break; 1839 } 1840 } 1841 LeaveCriticalSection(&oidInfoCS); 1842 break; 1843 } 1844 case CRYPT_OID_INFO_OID_KEY: 1845 { 1846 struct OIDInfo *info; 1847 LPSTR oid = pvKey; 1848 1849 TRACE("CRYPT_OID_INFO_OID_KEY: %s\n", debugstr_a(oid)); 1850 EnterCriticalSection(&oidInfoCS); 1851 LIST_FOR_EACH_ENTRY(info, &oidInfo, struct OIDInfo, entry) 1852 { 1853 if (!lstrcmpA(info->info.pszOID, oid) && 1854 (!dwGroupId || info->info.dwGroupId == dwGroupId)) 1855 { 1856 ret = &info->info; 1857 break; 1858 } 1859 } 1860 LeaveCriticalSection(&oidInfoCS); 1861 break; 1862 } 1863 case CRYPT_OID_INFO_SIGN_KEY: 1864 { 1865 struct OIDInfo *info; 1866 1867 TRACE("CRYPT_OID_INFO_SIGN_KEY: %d\n", *(DWORD *)pvKey); 1868 EnterCriticalSection(&oidInfoCS); 1869 LIST_FOR_EACH_ENTRY(info, &oidInfo, struct OIDInfo, entry) 1870 { 1871 if (info->info.u.Algid == *(DWORD *)pvKey && 1872 info->info.ExtraInfo.cbData >= sizeof(DWORD) && 1873 *(DWORD *)info->info.ExtraInfo.pbData == 1874 *(DWORD *)((LPBYTE)pvKey + sizeof(DWORD)) && 1875 (!dwGroupId || info->info.dwGroupId == dwGroupId)) 1876 { 1877 ret = &info->info; 1878 break; 1879 } 1880 } 1881 LeaveCriticalSection(&oidInfoCS); 1882 break; 1883 } 1884 } 1885 return ret; 1886 } 1887 1888 LPCSTR WINAPI CertAlgIdToOID(DWORD dwAlgId) 1889 { 1890 LPCSTR ret; 1891 PCCRYPT_OID_INFO info = CryptFindOIDInfo(CRYPT_OID_INFO_ALGID_KEY, 1892 &dwAlgId, 0); 1893 1894 if (info) 1895 ret = info->pszOID; 1896 else 1897 ret = NULL; 1898 return ret; 1899 } 1900 1901 DWORD WINAPI CertOIDToAlgId(LPCSTR pszObjId) 1902 { 1903 DWORD ret; 1904 PCCRYPT_OID_INFO info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, 1905 (void *)pszObjId, 0); 1906 1907 if (info) 1908 ret = info->u.Algid; 1909 else 1910 ret = 0; 1911 return ret; 1912 } 1913 1914 void crypt_oid_init(void) 1915 { 1916 init_oid_info(); 1917 init_registered_oid_info(); 1918 } 1919 1920 void crypt_oid_free(void) 1921 { 1922 free_function_sets(); 1923 free_oid_info(); 1924 } 1925