rsaenh: Reorder padding code to avoid unnecessary comparison.

This commit is contained in:
Juan Lang 2007-09-10 15:04:39 -07:00 committed by Alexandre Julliard
parent 57dee443f5
commit 16c40d9112
1 changed files with 7 additions and 7 deletions

View File

@ -1907,16 +1907,16 @@ BOOL WINAPI RSAENH_CPEncrypt(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTHASH hHash,
*pdwDataLen = dwEncryptedLen; *pdwDataLen = dwEncryptedLen;
return TRUE; return TRUE;
} }
else if (dwEncryptedLen > dwBufLen) {
for (i=*pdwDataLen; i<dwEncryptedLen && i<dwBufLen; i++) pbData[i] = dwEncryptedLen - *pdwDataLen;
*pdwDataLen = dwEncryptedLen; *pdwDataLen = dwEncryptedLen;
if (*pdwDataLen > dwBufLen)
{
SetLastError(ERROR_MORE_DATA); SetLastError(ERROR_MORE_DATA);
return FALSE; return FALSE;
} }
/* Pad final block with length bytes */
for (i=*pdwDataLen; i<dwEncryptedLen; i++) pbData[i] = dwEncryptedLen - *pdwDataLen;
*pdwDataLen = dwEncryptedLen;
for (i=0, in=pbData; i<*pdwDataLen; i+=pCryptKey->dwBlockLen, in+=pCryptKey->dwBlockLen) { for (i=0, in=pbData; i<*pdwDataLen; i+=pCryptKey->dwBlockLen, in+=pCryptKey->dwBlockLen) {
switch (pCryptKey->dwMode) { switch (pCryptKey->dwMode) {
case CRYPT_MODE_ECB: case CRYPT_MODE_ECB: