bcrypt: Return correct error from key_asymmetric_encrypt() if key is missing.

This commit is contained in:
Paul Gofman 2022-12-15 09:25:40 -06:00 committed by Alexandre Julliard
parent a7efc770f7
commit 6f455e10af
2 changed files with 3 additions and 1 deletions

View file

@ -2205,6 +2205,8 @@ static NTSTATUS key_asymmetric_encrypt( void *args )
NTSTATUS status = STATUS_SUCCESS;
int ret;
if (!key_data(params->key)->a.pubkey) return STATUS_INVALID_HANDLE;
d.data = params->input;
d.size = params->input_len;
if ((ret = pgnutls_pubkey_encrypt_data(key_data(params->key)->a.pubkey, 0, &d, &e)))

View file

@ -2284,12 +2284,12 @@ static void test_rsa_encrypt(void)
ret = BCryptGenerateKeyPair(rsa, &key, 512, 0);
ok(ret == STATUS_SUCCESS, "got %lx\n", ret);
todo_wine {
/* Not finalized key */
ret = BCryptEncrypt(key, input, sizeof(input), NULL, NULL, 0, NULL, 0, &encrypted_size, 0);
ok(ret == STATUS_INVALID_HANDLE, "got %lx\n", ret);
BCryptFinalizeKeyPair(key, 0);
todo_wine {
/* No padding */
memset(input_no_padding, 0, sizeof(input_no_padding));
strcpy((char *)input_no_padding, "Hello World");