Codebase list openssl / 8ab9af5
engines/e_capi.c: slip in PROV_RSA_AES for interchangable CSP only. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3034) Andy Polyakov 7 years ago
1 changed file(s) with 15 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
397397 # endif
398398
399399 static int use_aes_csp = 0;
400 static const WCHAR rsa_aes_cspname[] =
401 L"Microsoft Enhanced RSA and AES Cryptographic Provider";
402 static const WCHAR rsa_enh_cspname[] =
403 L"Microsoft Enhanced Cryptographic Provider v1.0";
400404
401405 static int capi_init(ENGINE *e)
402406 {
471475 }
472476 # endif
473477
474 /* See if we support AES CSP */
475
476 if (CryptAcquireContextW(&hprov, NULL, NULL, PROV_RSA_AES,
478 /* See if there is RSA+AES CSP */
479 if (CryptAcquireContextW(&hprov, NULL, rsa_aes_cspname, PROV_RSA_AES,
477480 CRYPT_VERIFYCONTEXT)) {
478481 use_aes_csp = 1;
479482 CryptReleaseContext(hprov, 0);
14581461 }
14591462
14601463 static CAPI_KEY *capi_get_key(CAPI_CTX *ctx, const WCHAR *contname,
1461 WCHAR *provname, DWORD ptype, DWORD keyspec)
1464 const WCHAR *provname, DWORD ptype,
1465 DWORD keyspec)
14621466 {
14631467 DWORD dwFlags = 0;
14641468 CAPI_KEY *key = OPENSSL_malloc(sizeof(*key));
14661470 if (key == NULL)
14671471 return NULL;
14681472 /* If PROV_RSA_AES supported use it instead */
1469 if (ptype == PROV_RSA_FULL && use_aes_csp) {
1470 provname = NULL;
1473 if (ptype == PROV_RSA_FULL && use_aes_csp &&
1474 wcscmp(provname, rsa_enh_cspname) == 0) {
1475 provname = rsa_aes_cspname;
14711476 ptype = PROV_RSA_AES;
1472 CAPI_trace(ctx, "capi_get_key, contname=%s, RSA_AES_CSP\n", contname);
1473 } else if (sizeof(TCHAR) == sizeof(char)) {
1474 CAPI_trace(ctx, "capi_get_key, contname=%s, provname=%s, type=%d\n",
1475 contname, provname, ptype);
1476 } else if (ctx && ctx->debug_level >= CAPI_DBG_TRACE && ctx->debug_file) {
1477 /* above 'if' is optimization to minimize malloc-ations */
1477 }
1478 if (ctx && ctx->debug_level >= CAPI_DBG_TRACE && ctx->debug_file) {
1479 /* above 'if' is [complementary] copy from CAPI_trace and serves
1480 * as optimization to minimize [below] malloc-ations */
14781481 char *_contname = wide_to_asc(contname);
14791482 char *_provname = wide_to_asc(provname);
14801483