mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-24 22:45:17 +02:00
fix bug in cng cipher keyobject processing
KeyObject for cipher symmetric key was being allocated improperly due to an error in getting the key object size. Also added code to free keyobject in the event of a key creation failure.
This commit is contained in:
parent
fad3c4ffc6
commit
3ab9c8f055
@ -286,7 +286,7 @@ unsigned int cng_cipher_init(PSSH_CNG_CIPHER_CTX x, const unsigned char *key, un
|
||||
status = BCryptGetProperty(
|
||||
hAlg,
|
||||
BCRYPT_OBJECT_LENGTH,
|
||||
(PBYTE)cbKeyObject,
|
||||
(PBYTE)&cbKeyObject,
|
||||
sizeof(DWORD),
|
||||
&cbData,
|
||||
0);
|
||||
@ -305,11 +305,15 @@ unsigned int cng_cipher_init(PSSH_CNG_CIPHER_CTX x, const unsigned char *key, un
|
||||
}
|
||||
BCryptCloseAlgorithmProvider(hAlg, 0);
|
||||
|
||||
// if we got an error along the way, free up the iv
|
||||
// if we got an error along the way, free up the iv and key object
|
||||
if (status != S_OK && x->pbIV)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, x->pbIV);
|
||||
}
|
||||
if (status != S_OK && x->pKeyObject)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, x->pKeyObject);
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user