Skip Menu |

This queue is for tickets about the Digest-HMAC CPAN distribution.

Report information
The Basics
Id: 100700
Status: new
Priority: 0/
Queue: Digest-HMAC

People
Owner: Nobody in particular
Requestors: zefram [...] fysh.org
Cc:
AdminCc:

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



Subject: numeric key breaks xor
Date: Thu, 4 Dec 2014 11:38:22 +0000
To: bug-Digest-HMAC [...] rt.cpan.org
From: Zefram <zefram [...] fysh.org>
$ perl -MDigest::HMAC -MDigest::MD5 -lwe 'print +Digest::HMAC->new("1", "Digest::MD5")->hexdigest' db9409c5b03f0a3b327438744001d7dd $ perl -MDigest::HMAC -MDigest::MD5 -lwe 'print +Digest::HMAC->new(1, "Digest::MD5")->hexdigest' Argument "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\..." isn't numeric in bitwise xor (^) at /opt/perl-5.18.2/lib/site_perl/5.18.2/Digest/HMAC.pm line 16. 970b9decb3bba4b681ecee5b41e77ebb Passing in the key as a numeric scalar breaks the computation, because Digest::HMAC is internally passing the key scalar to Perl's native xor op, which does different things depending on the scalar type. It's one of the few places where the usual coercion of number to string isn't applied. Digest::HMAC should stringify the supplied key to make sure the operands for xor are always pure strings. -zefram