For Programmers: Free Programming Magazines  


Home > Archive > Tcl > August 2007 > tcllib 1.9 DES package and tcl 8.5









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author tcllib 1.9 DES package and tcl 8.5
MartinLemburg@UGS

2007-08-24, 8:10 am

Hello,

I have a problem with the tcllib 1.9 DES package used with tcl 8.5.

If I use the following, discrepancies between the orignal and the en-/
decrypted text appears:

% set microseconds [expr {wide([clock clicks -microseconds])}];
1187952939896309
% set asciiData "Hello World!"
% set encryptedData [::DES::des -mode cbc -dir encrypt -key
$microseconds $asciiData]
??+=C7my?-=AC*?+=A6$-=A6?-=E2-=A6B
% set decryptedData [::DES::des -mode cbc -dir decrypt -key
$microseconds $encryptedData]
Hello World!+=C7+=C7+=C7+=C7

Is this a known behaviour in tcl 8.5, or should I file a bug?

Best regards,

Martin Lemburg

Ron Fox

2007-08-24, 8:10 am

From the des man page:


DES is a 64-bit block cipher. This means that the data must be provided
in units that are a multiple of 8 bytes.

Add sufficient spaces. to pad this to 16 bytes from the 12 bytes you are
passing...(each of the +Ç is a byte evidently.. they
represent the 4 chars junk in the encryption buffer probably.

Note that this will be true of many modern encryption algorithms
(that they operate on fixed sized blocks, and will need explicit
padding).


Ron

MartinLemburg@UGS wrote:
> Hello,
>
> I have a problem with the tcllib 1.9 DES package used with tcl 8.5.
>
> If I use the following, discrepancies between the orignal and the en-/
> decrypted text appears:
>
> % set microseconds [expr {wide([clock clicks -microseconds])}];
> 1187952939896309
> % set asciiData "Hello World!"
> % set encryptedData [::DES::des -mode cbc -dir encrypt -key
> $microseconds $asciiData]
> ??+Çmy?-¬*?+¦$-¦?-â-¦B
> % set decryptedData [::DES::des -mode cbc -dir decrypt -key
> $microseconds $encryptedData]
> Hello World!+Ç+Ç+Ç+Ç
>
> Is this a known behaviour in tcl 8.5, or should I file a bug?
>
> Best regards,
>
> Martin Lemburg
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com