rsaenh: Reorder padding code to avoid unnecessary comparison.
This commit is contained in:
parent
57dee443f5
commit
16c40d9112
|
@ -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:
|
||||||
|
|
Loading…
Reference in New Issue