bcrypt: Validate key size when importing RSA public key.
Signed-off-by: Santino Mazza <mazzasantino1206@gmail.com> Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
9799fa8009
commit
83bb9eb9aa
|
@ -1413,6 +1413,7 @@ static NTSTATUS key_import_pair( struct algorithm *alg, const WCHAR *type, BCRYP
|
|||
return STATUS_NOT_SUPPORTED;
|
||||
|
||||
size = sizeof(*rsa_blob) + rsa_blob->cbPublicExp + rsa_blob->cbModulus;
|
||||
if (size != input_len) return NTE_BAD_DATA;
|
||||
return key_asymmetric_create( (struct key **)ret_key, alg, rsa_blob->BitLength, (BYTE *)rsa_blob, size );
|
||||
}
|
||||
else if (!wcscmp( type, BCRYPT_RSAPRIVATE_BLOB ) || !wcscmp( type, BCRYPT_RSAFULLPRIVATE_BLOB ))
|
||||
|
|
|
@ -2122,11 +2122,9 @@ static void test_RSA(void)
|
|||
ret = BCryptDestroyKey(key);
|
||||
ok(!ret, "got %#lx\n", ret);
|
||||
|
||||
todo_wine
|
||||
{
|
||||
ret = BCryptImportKeyPair(alg, NULL, BCRYPT_RSAPUBLIC_BLOB, &key, rsaPublicBlobWithInvalidPublicExpSize, sizeof(rsaPublicBlobWithInvalidPublicExpSize), 0);
|
||||
ret = BCryptImportKeyPair(alg, NULL, BCRYPT_RSAPUBLIC_BLOB, &key, rsaPublicBlobWithInvalidPublicExpSize,
|
||||
sizeof(rsaPublicBlobWithInvalidPublicExpSize), 0);
|
||||
ok(ret == NTE_BAD_DATA, "got %#lx\n", ret);
|
||||
}
|
||||
|
||||
ret = BCryptImportKeyPair(alg, NULL, BCRYPT_RSAPUBLIC_BLOB, &key, buf, size, 0);
|
||||
ok(ret == STATUS_SUCCESS, "got %#lx\n", ret);
|
||||
|
|
Loading…
Reference in New Issue