Hi,
I am using des_ncbc_encrypt to encrypt/decrypt packages in a server/client
architecture (CBC mode). When I test encryption/decryption from within the
server I get everything decrypted OK, except the last 4 bytes. However, this
is enough for the client to reject the packet. I am using the following
code:
uchar * output;
des_key_schedule des_ks;
des_cblock des_key, des_iv;
memcpy(des_iv, iv, sizeof(des_iv));
memcpy(des_key, server_write_enc_key, sizeof(des_key));
des_set_odd_parity(&des_key);
if (des_set_key_checked(&des_key, des_ks))
{
error(0, "wtls_des: Unable to set key schedule");
return(NULL);
}
output = (uchar *)gw_malloc((len + 1)* sizeof(uchar));
des_ncbc_encrypt(data, output, len, des_ks, &des_iv, crypt);
where crypt takes the values DES_ENCRYPT or DES_DECRYPT.
<gdb>
(gdb) p data + 1640
$11 = (
unsigned char *) 0x75f700
"*ξΥΰl:=8υ\n\236\236π\006\006\006\006\006\006\006"
(gdb) p output + 1640
$15 = (uchar *) 0x75e6f0 "YyΚ6ΰ�'\216―LΊkφ\033\232’)«Ε\233"
Decrypting output through another call to the same function (everything gets
reinitialized) I get:
(gdb) p data + 1640
$22 = (unsigned char *) 0x760710 "YyΚ6ΰ�'\216―LΊkφ\033\232’)«Ε\233" (OK)
(gdb) p output + 1640
$24 = (uchar *) 0x75c6d0 "*ξΥΰl:=8υ\n\236\236π\006\006\006(VχR" (??)
Everything is fine except for the trailing "(VχR". Any ideas or pointers of
what is wrong, would be greatly appreciated.
Thanx,
Nikos Balkanas
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager majord...@openssl.org