Add some of the properties of the key, like its algorithm group or the bit length.
Signed-off-by: Santino Mazza mazzasantino1206@gmail.com --- dlls/ncrypt/ncrypt_internal.h | 1 + dlls/ncrypt/ncrypt_main.c | 4 ++++ dlls/ncrypt/tests/ncrypt.c | 15 +++++++++++---- 3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/dlls/ncrypt/ncrypt_internal.h b/dlls/ncrypt/ncrypt_internal.h index a9345da3c80..16ed03d6971 100644 --- a/dlls/ncrypt/ncrypt_internal.h +++ b/dlls/ncrypt/ncrypt_internal.h @@ -42,6 +42,7 @@ enum key_algorithm_type struct ncrypt_rsa_key { enum asymmetric_key_type type; + DWORD bit_length; DWORD public_exp_size; BYTE *public_exp; DWORD modulus_size; diff --git a/dlls/ncrypt/ncrypt_main.c b/dlls/ncrypt/ncrypt_main.c index 7c6fe76338f..6ee9dc12948 100644 --- a/dlls/ncrypt/ncrypt_main.c +++ b/dlls/ncrypt/ncrypt_main.c @@ -211,6 +211,7 @@ SECURITY_STATUS WINAPI NCryptImportKey(NCRYPT_PROV_HANDLE provider, NCRYPT_KEY_H
rsakey = &rsakeyobject->object.key; rsakey->algtype = RSA; + rsakey->payload.rsa_key.bit_length = rsaheader->BitLength; rsakey->payload.rsa_key.public_exp_size = rsaheader->cbPublicExp; rsakey->payload.rsa_key.modulus_size = rsaheader->cbModulus; rsakey->payload.rsa_key.public_exp = malloc(rsaheader->cbPublicExp); @@ -231,6 +232,9 @@ SECURITY_STATUS WINAPI NCryptImportKey(NCRYPT_PROV_HANDLE provider, NCRYPT_KEY_H memcpy(rsakey->payload.rsa_key.public_exp, public_exp, rsaheader->cbPublicExp); memcpy(rsakey->payload.rsa_key.modulus, modulus, rsaheader->cbModulus);
+ set_object_property(rsakeyobject, NCRYPT_ALGORITHM_GROUP_PROPERTY, L"RSA", 8); + set_object_property(rsakeyobject, NCRYPT_LENGTH_PROPERTY, &rsakey->payload.rsa_key.bit_length, sizeof(DWORD)); + set_object_property(rsakeyobject, NCRYPT_PROVIDER_HANDLE_PROPERTY, &provider, sizeof(NCRYPT_PROV_HANDLE)); *key = (NCRYPT_KEY_HANDLE)rsakeyobject; } break; diff --git a/dlls/ncrypt/tests/ncrypt.c b/dlls/ncrypt/tests/ncrypt.c index ff4bc3be7cc..0d0570daca7 100644 --- a/dlls/ncrypt/tests/ncrypt.c +++ b/dlls/ncrypt/tests/ncrypt.c @@ -152,21 +152,28 @@ static void test_get_property(void) SECURITY_STATUS ret = NCryptOpenStorageProvider(&prov, NULL, 0); ok(ret == ERROR_SUCCESS, "got 0x%x\n", ret);
- todo_wine { NCRYPT_KEY_HANDLE key; ret = NCryptImportKey(prov, (NCRYPT_KEY_HANDLE)NULL, BCRYPT_RSAPUBLIC_BLOB, NULL, &key, rsa_key_blob, sizeof(rsa_key_blob), 0);
DWORD size; - ret = NCryptGetProperty(key, L"Algorithm Group", NULL, 0, &size, 0); + ret = NCryptGetProperty(key, NCRYPT_ALGORITHM_GROUP_PROPERTY, NULL, 0, &size, 0); ok(ret == ERROR_SUCCESS, "got 0x%x\n", ret); ok(size == 8, "got 0x%x\n", size);
WCHAR value[8]; - ret = NCryptGetProperty(key, L"Algorithm Group", value, 8, &size, 0); + ret = NCryptGetProperty(key, NCRYPT_ALGORITHM_GROUP_PROPERTY, value, 8, &size, 0); ok(ret == ERROR_SUCCESS, "got 0x%x\n", ret); ok(size == 8, "got 0x%x\n", size); ok(lstrcmpW(value, L"RSA") == 0, "The string doesn't match with 'RSA'\n"); - } + + DWORD keylength; + ret = NCryptGetProperty(key, NCRYPT_LENGTH_PROPERTY, NULL, 0, &size, 0); + ok(ret == ERROR_SUCCESS, "got 0x%x\n", ret); + ok(size == sizeof(DWORD), "got 0x%x\n", size); + + ret = NCryptGetProperty(key, NCRYPT_LENGTH_PROPERTY, &keylength, size, &size, 0); + ok(ret == ERROR_SUCCESS, "got 0x%x\n", ret); + ok(keylength == 1024, "got 0x%x\n", keylength); }
START_TEST(ncrypt)