Commit 54b972e2 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

rsaenh: Add error messages for failed private key imports.

parent ee3c0c3e
......@@ -2731,11 +2731,27 @@ static BOOL import_private_key(HCRYPTPROV hProv, CONST BYTE *pbData, DWORD dwDat
return FALSE;
}
if ((dwDataLen < sizeof(BLOBHEADER) + sizeof(RSAPUBKEY)) ||
(pRSAPubKey->magic != RSAENH_MAGIC_RSA2) ||
(dwDataLen < sizeof(BLOBHEADER) + sizeof(RSAPUBKEY) +
if ((dwDataLen < sizeof(BLOBHEADER) + sizeof(RSAPUBKEY)))
{
ERR("datalen %d not long enough for a BLOBHEADER + RSAPUBKEY\n",
dwDataLen);
SetLastError(NTE_BAD_DATA);
return FALSE;
}
if (pRSAPubKey->magic != RSAENH_MAGIC_RSA2)
{
ERR("unexpected magic %08x\n", pRSAPubKey->magic);
SetLastError(NTE_BAD_DATA);
return FALSE;
}
if ((dwDataLen < sizeof(BLOBHEADER) + sizeof(RSAPUBKEY) +
(2 * pRSAPubKey->bitlen >> 3) + (5 * ((pRSAPubKey->bitlen+8)>>4))))
{
DWORD expectedLen = sizeof(BLOBHEADER) + sizeof(RSAPUBKEY) +
(2 * pRSAPubKey->bitlen >> 3) + (5 * ((pRSAPubKey->bitlen+8)>>4));
ERR("blob too short for pub key: expect %d, got %d\n",
expectedLen, dwDataLen);
SetLastError(NTE_BAD_DATA);
return FALSE;
}
......
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