Re: 3DES Freeware C-library available?!?

From: Robin de Krijger (robindekrijger_at_hotmail.com)
Date: 12/06/04


Date: Mon, 6 Dec 2004 14:13:47 +0100


"Arnaud Carré" <arnaud.carreNOSPAM@freesurf.fr> wrote in message
news:41b44088$0$15687$636a15ce@news.free.fr...

Thanx Arnaud!

Much closer now, but not finished yet... Here's my issue:

The manual says: "encrypt S with TDES key Kenc"

I have S, 32 bytes, to fit in the program, defined as:

static unsigned char S[4][8]={
 {0x78,0x17,0x23,0x86,0x0C,0x06,0xC2,0x26},
 {0x46,0x08,0xF9,0x19,0x88,0x70,0x22,0x12},
 {0x0B,0x79,0x52,0x40,0xCB,0x70,0x49,0xB0},
 {0x1C,0x19,0xB3,0x3E,0x32,0x80,0x4F,0x0B}};

I have Kenc, 2 bytes, defined as:

static unsigned char Kenc[2][8]={
 {0xAB,0x94,0xFD,0xEC,0xF2,0x67,0x4F,0xDF},
 {0xB9,0xB3,0x91,0xF8,0x5D,0x7F,0x76,0xF2}};

Now, the manual says: "use Kenc keys in CBC mode with zero IV. No padding
for
the input data is used"

>From your advice i made this:

des3_context ctx3;
unsigned char buf[4][8];

des3_set_3keys(&ctx3,Kenc[0],Kenc[1],Kenc[0]);
des3_encrypt(&ctx3,S[0],buf[0]);
des3_encrypt(&ctx3,S[1],buf[1]);
des3_encrypt(&ctx3,S[2],buf[2]);
des3_encrypt(&ctx3,S[3],buf[3]);

I have what the result SHOULD be (buf[0] buf[1] buf[2] buf[3]):
72 C2 9C 23 71 CC 9B DB
65 B7 79 B8 E8 D3 7B 29
EC C1 54 AA 56 A8 79 9F
AE 2F 49 8F 76 ED 92 F2

The code above produces:
72 C2 9C 23 71 CC 9B DB
46 B9 34 2A 41 39 6C D7
FD 86 91 6A 8D 7E 8F D4
16 F4 1A 0C 10 B4 67 CB

So, THE FIRST LINE is perfect... The rest is not...
What could be wrong?!? Any ideas?!?


Quantcast