CC: | NEELY [...] cpan.org, MAKAMAKA [...] cpan.org |
Subject: | Does not downgrade when UTF-8 flag is set |
This bug was discovered during smoke testing of Data::Serializer.
I'm trying to CC Neil so he finally gets an explanation for all the
failing tests I sent to cpan testers.
The bug is that Crypt::CBC does not deal well with data that have the
UTF8 bit on. Demonstrated in this test case:
perl -le '
use Crypt::CBC;print $Crypt::CBC::VERSION;
my $secret = "test";
my $cipher = "Blowfish";
my $digest = qq{deadbeef};
$digest .= chr(256); chop $digest;
my $cipher_obj = Crypt::CBC->new($secret,$cipher);
print length $cipher_obj->encrypt($digest)==32 ? "ok\n" : "not ok\n";
'
2.28
input must be 8 bytes long at
/home/src/perl/repoperls/installed-perls/perl/pSMD0sR/perl-5.9.1@23966/lib/site_perl/5.9.2/i686-linux-64int/Crypt/Blowfish.pm
line 56.
This fails on all perls since bleadperl@23966. That patch made unpack
encoding neutral which means that a simple ascii string that comes in
with the UTF-8 bit set get that bit through unpack. Older perls lost it
during the unpack. It needed then the new JSON 2.0 that serializes with
UTF-8 bit set correctly. And it needed another few months to discover
this problem because Data::Serializer most of the time skips tests when
JSON is not installed.
I'm pretty sure you can blame perl that it handles
$iv ^ $asciistring
differently when the UTF8 bit is set on $asciistring. But I think it is
sufficiently underdocumented to draw a conclusion.
Thanks,