The last 8 bytes (same as the block size) are padding.  They pad the encrypted data until it becomes an even multiple of 8.  The value of the padding bytes (they are all the same value) is the count of padding bytes.  When then the data is an even multiple of 8, then the padding still exists, but equal to 8.  8 as in binary 0x08 and not ASCII 8. 
 
When decrypting, read the final byte to determine the number of padding characters, then subtract from the data size.
 

Paul Rony
Merchantware

-----Original Message-----
From: Michael Brown [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 06, 2001 1:58 PM
To: [EMAIL PROTECTED]
Subject: DES CBC encryption

Hey folks,
 
    My progress on the PHP client for OpenSRS is close to complete. I am having one struggle with the encryption end of things, as it appears that the Perl clients implementation of the encryption is not standard CBC encryption.
 
My code, for some reason produces exactly the same encryption as Perl's module, except for the last 8 bytes (which are not present in my code). It appears that the Perl module/source is adding these 8 bytes, although I'm not sure where they come from.
 
    Can anyone shed some light on this subject?
 
    Example string from Perl: RandomIV00000000R�‡o�…��l\�N��w”�>š��‹P����\��
    My Example string:         RandomIV00000000R�‡o�…��l\�N��w”�>š��‹P
 
    As you can see, it is exactly the same, except for the extra 8 bytes in Perl's generated result.
 
 
Help please!
 
Michael Brown
[EMAIL PROTECTED]

Reply via email to