Module: wine Branch: master Commit: 54b972e2fcdc34c09387d359b5d9cc21aa20b29a URL: http://source.winehq.org/git/wine.git/?a=commit;h=54b972e2fcdc34c09387d359b5...
Author: Juan Lang juan.lang@gmail.com Date: Wed Oct 26 16:02:03 2011 -0700
rsaenh: Add error messages for failed private key imports.
---
dlls/rsaenh/rsaenh.c | 22 +++++++++++++++++++--- 1 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/dlls/rsaenh/rsaenh.c b/dlls/rsaenh/rsaenh.c index db58e44..f332cfb 100644 --- a/dlls/rsaenh/rsaenh.c +++ b/dlls/rsaenh/rsaenh.c @@ -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; }