Skip Menu |

This queue is for tickets about the Crypt-ECB-1.1 CPAN distribution.

Report information
The Basics
Id: 80456
Status: resolved
Priority: 0/
Queue: Crypt-ECB-1.1

People
Owner: Nobody in particular
Requestors: mario [...] toursprung.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Patch to add support for NULL (\0) padding
Hi, An issue with the mcrypt support in PHP made me add NULL (\0) padding support in the module. Attached you will find a patch / diff for it. regards
Subject: ECB.diff
17c17 < @EXPORT = qw(PADDING_NONE PADDING_AUTO PADDING_NULL); --- > @EXPORT = qw(PADDING_NONE PADDING_AUTO); 23d22 < use constant PADDING_NULL => 2; 349,352d347 < elsif ($padstyle == PADDING_NULL) < { < $result =~ s/\0*$//s; < } 390,393d384 < elsif ($padstyle == PADDING_NULL) < { < $data .= pack("C*", (0) x ($bs-(length($data) % $bs))); < } 589,593c580 < when decrypting) the same way Crypt::CBC does, namely using the < PKCS#5 / PKCS#7 method (RFC 5652). When set to PADDING_NULL the ECB < module padds (and truncates when decrypting) with zero (null) characters. < PADDING_NULL should not be used when encrypting binaries. < More info on padding here: http://www.di-mgt.com.au/cryptopad.html --- > when decrypting) the same way Crypt::CBC does. 693c680 < The three constants naming the padding styles are exported by default: --- > The two constants naming the padding styles are exported by default: 697d683 < PADDING_NULL => 2
From: mario [...] toursprung.com
Here is also a unified diff patch. On Sun Oct 28 18:30:22 2012, marstreme wrote: Show quoted text
> Hi, > An issue with the mcrypt support in PHP made me add NULL (\0) padding > support in the module. Attached you will find a patch / diff for it. > > regards
Subject: ECB.patch
--- 5.10.0/Crypt/ECB.pm 2012-10-28 23:11:53.933422965 +0100 +++ 5.10.0/Crypt/ECB.pm-orig 2012-10-28 22:40:15.906336221 +0100 @@ -14,13 +14,12 @@ require Exporter; @ISA = qw(Exporter); -@EXPORT = qw(PADDING_NONE PADDING_AUTO PADDING_NULL); +@EXPORT = qw(PADDING_NONE PADDING_AUTO); @EXPORT_OK = qw(encrypt decrypt encrypt_hex decrypt_hex); $VERSION = '1.45'; use constant PADDING_NONE => 0; use constant PADDING_AUTO => 1; -use constant PADDING_NULL => 2; ######################################## @@ -346,10 +345,6 @@ { substr($result,-unpack("C",substr($result,-1))) = ''; } - elsif ($padstyle == PADDING_NULL) - { - $result =~ s/\0*$//s; - } # some more for the future? else @@ -387,10 +382,6 @@ { $data .= pack("C*",($bs-length($data))x($bs-length($data))); } - elsif ($padstyle == PADDING_NULL) - { - $data .= pack("C*", (0) x ($bs-(length($data) % $bs))); - } # some more for the future? else @@ -586,11 +577,7 @@ PADDING_NONE, no padding is done. You then have to take care of correct padding (and truncating) yourself. When set to PADDING_AUTO, the ECB module handles padding (and truncating -when decrypting) the same way Crypt::CBC does, namely using the -PKCS#5 / PKCS#7 method (RFC 5652). When set to PADDING_NULL the ECB -module padds (and truncates when decrypting) with zero (null) characters. -PADDING_NULL should not be used when encrypting binaries. -More info on padding here: http://www.di-mgt.com.au/cryptopad.html +when decrypting) the same way Crypt::CBC does. By default the padding style is set to PADDING_NONE. This means if you don't bother and your data has not the correct length, the module will @@ -690,11 +677,10 @@ =head1 CONSTANTS -The three constants naming the padding styles are exported by default: +The two constants naming the padding styles are exported by default: PADDING_NONE => 0 PADDING_AUTO => 1 - PADDING_NULL => 2 =head1 FUNCTIONS