From: t on
Hi

How to Decrypt Message using algoritm Triple-DES CBC IV in VC++
7.1

Message (string representation of bytes):
5a b3 85 98 f5 dc 85 dc ef d0 dd 5d b8 19 92 f8 b6 28 ed 20 41 2b 6b ed b4
79 46 48 6f 2a e1 ef 40 ef 89 ef 1c e2 d2 ef 0f 3a 4e c2 76 4c 99 46 dd f8
5d e0 98 98 c1 92 94 52 e0 d6 57 b6 c4 d4

DesKey = (rkey)01 02 03 04 05 06 07 08 09 10 11 12 13 14 ^ (ckey)71 97
13 64 6d 8a e9 1f 8b ec 29 ac 58 45


somewhere in Message is string 'test' how to Dectypt it


sory - my question is dificult but I've spend several weeks and nothing
if someone have novledge please help
Thanks.
t.




As I know

DesKey is generated as:
(for (int i=0; i<(int)sizeof(tmpkey); i++) { DesKey[i]=rkey[i]^ckey[i]; })


Oryginal function for Decrypt is in linux but I need it in VC++ 7.1 how to
convert it:
#include <rpc/des_crypt.h>
int des_decrypt(HCRYPTPROV hProv, uint8 *buffer, int len, uint8 *deskey)
{
char ivec[8];
char nextIvec[8];
unsigned char tmp[1024];
int i;
uint8 checksum = 0;
if (!deskey) return len;
if ((len-2) % 8 || (len-2) < 16) return -1;
len -= 8;
memcpy(nextIvec, buffer+len, 8);
for (i = 2; i < len; i += 8)
{
memcpy(ivec, nextIvec, 8);
memcpy(nextIvec, buffer+i, 8);
ecb_crypt(deskey , (char *) buffer+i, 8, DES_DECRYPT);
ecb_crypt(deskey+8, (char *) buffer+i, 8, DES_ENCRYPT);
cbc_crypt(deskey , (char *) buffer+i, 8, DES_DECRYPT, ivec);
}
for (i = 2; i < len; i++) checksum ^= buffer[i];
if (checksum) return -1;
return len;
}


From: nico on
t wrote:
> Hi
>
> How to Decrypt Message using algoritm Triple-DES CBC IV in VC++
> 7.1
>

Have you tried with Win32 Crypto API (CALG_3DES) ?