Skip to content

Commit

Permalink
NCryptEnumKeys returns ERROR_NO_MORE_ITEMS and is positive error code
Browse files Browse the repository at this point in the history
IB-8341

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma committed Jan 10, 2025
1 parent c28a0a5 commit 0578616
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions client/QCNG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,14 @@ QList<TokenData> QCNG::tokens() const
return data;
};
auto enumKeys = [&result, &prop](const QString &provider, QString reader = {}) {
if(provider == u"SafeCert Key Storage Provider"_s)
{
qCWarning(CNG) << "Skip: Crashes on NCryptEnumKeys";
return;
}
QString scope = uR"(\\.\%1\)"_s.arg(reader);
SCOPE<NCRYPT_PROV_HANDLE> h;
SECURITY_STATUS err = NCryptOpenStorageProvider(&h, LPCWSTR(provider.utf16()), 0);
NCryptKeyName *keyname{};
PVOID pos {};
BCRYPT_PSS_PADDING_INFO rsaPSS { NCRYPT_SHA256_ALGORITHM, 32 };
DWORD size {};
while(SUCCEEDED(NCryptEnumKeys(h, reader.isEmpty() ? nullptr : LPCWSTR(scope.utf16()), &keyname, &pos, NCRYPT_SILENT_FLAG)))
while(NCryptEnumKeys(h, reader.isEmpty() ? nullptr : LPCWSTR(scope.utf16()), &keyname, &pos, NCRYPT_SILENT_FLAG) == ERROR_SUCCESS)
{
SCOPE<NCryptKeyName*,decltype(NCryptFreeBuffer)> keyname_scope{keyname};
SCOPE<NCRYPT_KEY_HANDLE> key;
Expand Down

0 comments on commit 0578616

Please sign in to comment.