Commit e7b85bc4 authored by Dr. Stephen Henson's avatar Dr. Stephen Henson
Browse files

PR: 2880

Submitted by: "Florian Rüchel" <florian.ruechel@ruhr-uni-bochum.de>

Correctly handle local machine keys in the capi ENGINE.
parent 07eaaab2
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -78,6 +78,11 @@ static int bind_gost (ENGINE *e,const char *id)
	{
	int ret = 0;
	if (id && strcmp(id, engine_gost_id)) return 0;
	if (ameth_GostR3410_94)
		{
		printf("GOST engine already loaded\n");
		goto end;
		}

	if (!ENGINE_set_id(e, engine_gost_id)) 
		{
+4 −1
Original line number Diff line number Diff line
@@ -1432,10 +1432,13 @@ static PCCERT_CONTEXT capi_find_cert(CAPI_CTX *ctx, const char *id, HCERTSTORE h
static CAPI_KEY *capi_get_key(CAPI_CTX *ctx, const char *contname, char *provname, DWORD ptype, DWORD keyspec)
	{
	CAPI_KEY *key;
    DWORD dwFlags = 0; 
	key = OPENSSL_malloc(sizeof(CAPI_KEY));
	CAPI_trace(ctx, "capi_get_key, contname=%s, provname=%s, type=%d\n", 
						contname, provname, ptype);
	if (!CryptAcquireContextA(&key->hprov, contname, provname, ptype, 0))
    if(ctx->store_flags & CERT_SYSTEM_STORE_LOCAL_MACHINE)
        dwFlags = CRYPT_MACHINE_KEYSET;
    if (!CryptAcquireContextA(&key->hprov, contname, provname, ptype, dwFlags)) 
		{
		CAPIerr(CAPI_F_CAPI_GET_KEY, CAPI_R_CRYPTACQUIRECONTEXT_ERROR);
		capi_addlasterror();