hcrypto WinCNG backend: don't leak handles on crypto reinit
Similar fix to a88d0066
, but for the WinCNG EVP backend. However this
is just a fix for leaking handles if the same EVP context is used with
a new key; there is no functionality issue as cipherstate is maintained
directly in the EVP context, not internally by WinCNG.
This commit is contained in:
@@ -196,6 +196,11 @@ wincng_key_init(EVP_CIPHER_CTX *ctx,
|
|||||||
if (ctx->cipher->app_data == NULL)
|
if (ctx->cipher->app_data == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (cng->hKey) {
|
||||||
|
BCryptDestroyKey(cng->hKey); /* allow reinitialization */
|
||||||
|
cng->hKey = (BCRYPT_KEY_HANDLE)0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note: ctx->key_len not EVP_CIPHER_CTX_key_length() for
|
* Note: ctx->key_len not EVP_CIPHER_CTX_key_length() for
|
||||||
* variable length key support.
|
* variable length key support.
|
||||||
|
Reference in New Issue
Block a user