Commit e705dfc2 authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

rsaenh: Don't import a public key to a key container.

parent b6ca6825
......@@ -2822,15 +2822,14 @@ static BOOL import_private_key(HCRYPTPROV hProv, const BYTE *pbData, DWORD dwDat
/******************************************************************************
* import_public_key [Internal]
*
* Import a BLOB'ed public key into a key container.
* Import a BLOB'ed public key.
*
* PARAMS
* hProv [I] Key container into which the public key is to be imported.
* hProv [I] A CSP.
* pbData [I] Pointer to a buffer which holds the public key BLOB.
* dwDataLen [I] Length of data in buffer at pbData.
* dwFlags [I] One of:
* CRYPT_EXPORTABLE: the imported key is marked exportable
* fStoreKey [I] If TRUE, the imported key is stored to the registry.
* phKey [O] Handle to the imported key.
*
*
......@@ -2843,9 +2842,8 @@ static BOOL import_private_key(HCRYPTPROV hProv, const BYTE *pbData, DWORD dwDat
* Failure: FALSE.
*/
static BOOL import_public_key(HCRYPTPROV hProv, const BYTE *pbData, DWORD dwDataLen,
DWORD dwFlags, BOOL fStoreKey, HCRYPTKEY *phKey)
DWORD dwFlags, HCRYPTKEY *phKey)
{
KEYCONTAINER *pKeyContainer;
CRYPTKEY *pCryptKey;
const BLOBHEADER *pBlobHeader = (const BLOBHEADER*)pbData;
const RSAPUBKEY *pRSAPubKey = (const RSAPUBKEY*)(pBlobHeader+1);
......@@ -2858,8 +2856,6 @@ static BOOL import_public_key(HCRYPTPROV hProv, const BYTE *pbData, DWORD dwData
SetLastError(NTE_BAD_FLAGS);
return FALSE;
}
if (!(pKeyContainer = get_key_container(hProv)))
return FALSE;
if ((dwDataLen < sizeof(BLOBHEADER) + sizeof(RSAPUBKEY)) ||
(pRSAPubKey->magic != RSAENH_MAGIC_RSA1) ||
......@@ -2881,15 +2877,6 @@ static BOOL import_public_key(HCRYPTPROV hProv, const BYTE *pbData, DWORD dwData
if (ret) {
if (dwFlags & CRYPT_EXPORTABLE)
pCryptKey->dwPermissions |= CRYPT_EXPORT;
switch (pBlobHeader->aiKeyAlg)
{
case AT_KEYEXCHANGE:
case CALG_RSA_KEYX:
TRACE("installing public key\n");
release_and_install_key(hProv, *phKey, &pKeyContainer->hKeyExchangeKeyPair,
fStoreKey);
break;
}
}
return ret;
}
......@@ -3103,7 +3090,7 @@ static BOOL import_key(HCRYPTPROV hProv, const BYTE *pbData, DWORD dwDataLen, HC
case PUBLICKEYBLOB:
return import_public_key(hProv, pbData, dwDataLen, dwFlags,
fStoreKey, phKey);
phKey);
case SIMPLEBLOB:
return import_symmetric_key(hProv, pbData, dwDataLen, hPubKey,
......
......@@ -2642,7 +2642,7 @@ static void test_import_export(void)
CryptDestroyKey(hPrivKey);
result = !memcmp(exported_key, exported_key2, dwDataLen);
todo_wine ok(result, "unexpected value\n");
ok(result, "unexpected value\n");
if (!result && winetest_debug > 1) {
trace("Expected public key (%u):\n", dwDataLen);
trace_hex(exported_key, dwDataLen);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment