| 1 | package JSON::WebToken::Crypt::HMAC; | ||||||||||
| 2 | |||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 4 | ▶ | use parent 'JSON::WebToken::Crypt'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 4 | ▶ | use Digest::SHA (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 4 | our $ALGORITHM2SIGNING_METHOD_MAP = { | |||||||||
| 10 | HS256 => \&Digest::SHA::hmac_sha256, | ||||||||||
| 11 | HS384 => \&Digest::SHA::hmac_sha384, | ||||||||||
| 12 | HS512 => \&Digest::SHA::hmac_sha512, | ||||||||||
| 13 | }; | ||||||||||
| 14 | |||||||||||
| 15 | sub sign { | ||||||||||
| 16 | 20 | ▶ | my ($class, $algorithm, $message, $key) = @_; | ||||||||
|
Subroutine
sign: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 17 | |||||||||||
| 18 | 20 | my $sign = ''; | |||||||||
| 19 | 20 | my $method = $ALGORITHM2SIGNING_METHOD_MAP->{$algorithm}; | |||||||||
| 20 | 20 | return $method->($message, $key); | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | sub verify { | ||||||||||
| 24 | 9 | ▶ | my ($class, $algorithm, $message, $key, $signature) = @_; | ||||||||
|
Subroutine
verify: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 25 | 9 | my $sign = $class->sign($algorithm, $message, $key); | |||||||||
| 26 | 9 | ▶ | return $sign eq $signature ? 1 : 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 4 | 1; | |||||||||
| 30 | __END__ | ||||||||||