Santino Mazza : bcrypt: Validate key size when importing RSA public key.
Alexandre Julliard
julliard at winehq.org
Mon Mar 7 16:04:55 CST 2022
Module: wine
Branch: master
Commit: 83bb9eb9aa4444c187a5f93917387e663114a960
URL: https://source.winehq.org/git/wine.git/?a=commit;h=83bb9eb9aa4444c187a5f93917387e663114a960
Author: Santino Mazza <mazzasantino1206 at gmail.com>
Date: Mon Mar 7 09:43:59 2022 +0100
bcrypt: Validate key size when importing RSA public key.
Signed-off-by: Santino Mazza <mazzasantino1206 at gmail.com>
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/bcrypt/bcrypt_main.c | 1 +
dlls/bcrypt/tests/bcrypt.c | 6 ++----
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index 0fb78ce39a5..072b7915b1e 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -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 ))
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index 5fb29a0e0ff..4d7516a55ac 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -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);
More information about the wine-cvs
mailing list