CC: | projekt-wlan [...] fem.tu-ilmenau.de |
Subject: | output of PBKDF2_hex broken |
Date: | Tue, 09 Jun 2015 12:22:15 +0200 |
To: | bug-Crypt-PBKDF2 [...] rt.cpan.org |
From: | michael-dev <michael-dev [...] fami-braun.de> |
Dear maintainer,
I'm using Crypt::PBKDF2 to derive WPA PSK from WPA passphrases [1].
I need the PSK in hex encoding, as the target application (hostapd)
needs it that way.
But when using PBKDF2_hex, this will work only most of the time. This is
because PBKDF2_hex
calls "unpack 'A*'" before doing hex encode ("unpack 'H*'"), which
removes trailing newlines
from the binary key string before converting to hex. As a result, the
returned data length
does not match the output_len given.
This can be worked around by not using PBKDF2_hex and instead doing the
hex encoding manually
outside of Crypt::PBKDF2.
I would expect PBKDF2_hex to match its description, which reads
Show quoted text
> As the PBKDF2 method, only the output is encoded in hexadecimal.
This can be fixed by applying:
--- /usr/share/perl5/Crypt/PBKDF2.pm.orig 2015-06-09
12:20:27.569859994 +0200
+++ /usr/share/perl5/Crypt/PBKDF2.pm 2015-06-09 12:20:37.441790751
+0200
@@ -182,7 +182,7 @@ sub PBKDF2_base64 {
sub PBKDF2_hex {
my $self = shift;
- return unpack "H*", unpack "A*", $self->PBKDF2(@_);
+ return unpack "H*", $self->PBKDF2(@_);
}
sub _PBKDF2_F {
Thanks,
M. Braun
[1]
http://subversion.fem.tu-ilmenau.de/websvn/wsvn/fem-wlan/configs/controller/etc/raddb.fem/wpa-password-hash.pl