Commit 0da8a521 authored by Michael Jung's avatar Michael Jung Committed by Alexandre Julliard

Adhere to const'ness of the input data in encrypt_block_impl.

parent 6971e1d7
...@@ -259,6 +259,8 @@ BOOL encrypt_block_impl(ALG_ID aiAlgid, KEY_CONTEXT *pKeyContext, CONST BYTE *in ...@@ -259,6 +259,8 @@ BOOL encrypt_block_impl(ALG_ID aiAlgid, KEY_CONTEXT *pKeyContext, CONST BYTE *in
DWORD enc) DWORD enc)
{ {
unsigned long inlen, outlen; unsigned long inlen, outlen;
BYTE *in_reversed = NULL;
int key;
switch (aiAlgid) { switch (aiAlgid) {
case CALG_RC2: case CALG_RC2:
...@@ -287,36 +289,38 @@ BOOL encrypt_block_impl(ALG_ID aiAlgid, KEY_CONTEXT *pKeyContext, CONST BYTE *in ...@@ -287,36 +289,38 @@ BOOL encrypt_block_impl(ALG_ID aiAlgid, KEY_CONTEXT *pKeyContext, CONST BYTE *in
break; break;
case CALG_RSA_KEYX: case CALG_RSA_KEYX:
case CALG_RSA_SIGN:
outlen = inlen = (mp_count_bits(&pKeyContext->rsa.N)+7)/8; outlen = inlen = (mp_count_bits(&pKeyContext->rsa.N)+7)/8;
if (enc) { if (enc) {
if (rsa_exptmod(in, inlen, out, &outlen, PK_PUBLIC, &pKeyContext->rsa) != CRYPT_OK) { if (aiAlgid == CALG_RSA_SIGN) {
key = PK_PRIVATE;
} else {
key = PK_PUBLIC;
}
if (rsa_exptmod(in, inlen, out, &outlen, key, &pKeyContext->rsa) != CRYPT_OK) {
SetLastError(NTE_FAIL); SetLastError(NTE_FAIL);
return FALSE; return FALSE;
} }
reverse_bytes((BYTE*)out, outlen); reverse_bytes(out, outlen);
} else { } else {
reverse_bytes((BYTE*)in, inlen); if (aiAlgid == CALG_RSA_SIGN) {
if (rsa_exptmod(in, inlen, out, &outlen, PK_PRIVATE, &pKeyContext->rsa) != CRYPT_OK) { key = PK_PUBLIC;
SetLastError(NTE_FAIL); } else {
return FALSE; key = PK_PRIVATE;
} }
} in_reversed = HeapAlloc(GetProcessHeap(), 0, inlen);
break; if (!in_reversed) {
SetLastError(NTE_NO_MEMORY);
case CALG_RSA_SIGN:
outlen = inlen = (mp_count_bits(&pKeyContext->rsa.N)+7)/8;
if (enc) {
if (rsa_exptmod(in, inlen, out, &outlen, PK_PRIVATE, &pKeyContext->rsa) != CRYPT_OK) {
SetLastError(NTE_FAIL);
return FALSE; return FALSE;
} }
reverse_bytes((BYTE*)out, outlen); memcpy(in_reversed, in, inlen);
} else { reverse_bytes(in_reversed, inlen);
reverse_bytes((BYTE*)in, inlen); if (rsa_exptmod(in_reversed, inlen, out, &outlen, key, &pKeyContext->rsa) != CRYPT_OK) {
if (rsa_exptmod(in, inlen, out, &outlen, PK_PUBLIC, &pKeyContext->rsa) != CRYPT_OK) { HeapFree(GetProcessHeap(), 0, in_reversed);
SetLastError(NTE_FAIL); SetLastError(NTE_FAIL);
return FALSE; return FALSE;
} }
HeapFree(GetProcessHeap(), 0, in_reversed);
} }
break; break;
......
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