OAuth/SignatureMethod/HMAC_SHA256.pm

filter: Statementstmt 100% 27 / 27 Branchbran 50.0% 1 / 2 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 2 totaltotal 88.1% 37 / 42 CC 3 SCAR 4.9
CC
3
Cov
94%
sign
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.6
« OAuth/SignatureMethod/HMAC_SHA1.pm ↑ Summary OAuth/Request.pm »
1 package Net::OAuth::SignatureMethod::HMAC_SHA256;
2  
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use base 'Net::OAuth::SignatureMethod';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Digest::SHA ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use MIME::Base64 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 ▶sub sign {
Subroutine sign: called CC=3 SCAR=11.3
Pod undocumented
13 2 my $self = shift;
14 2 my $request = shift;
15 2 ▶ croak "Cannot use a blank signature_key" unless length( $request->signature_key || "" ) > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless length($request->signature_key || "") > 0 0 2 2
Condition50%1/2
$request->signature_key || ''
l!l
20
MC/DC0%0/1
$request->signature_key || ''
$request->signature_key
Truth table50%1/2
A
A= $request->signature_key
Aresult
11
00
16 2 my $hmac_digest = Digest::SHA::hmac_sha256(
17 $request->signature_base_string, $request->signature_key
18 );
19 2 return MIME::Base64::encode_base64($hmac_digest, '');
20 }
21  
22 1 ▶sub verify {
Subroutine verify: called CC=1 SCAR=0.0
Pod undocumented
23 1 my $self = shift;
24 1 my $request = shift;
25 1 return $self->secure_compare( $request->signature, $self->sign($request) );
26 }
27  
28 =head1 NAME
29  
30 Net::OAuth::SignatureMethod::HMAC_SHA256 - HMAC_SHA256 Signature Method for OAuth protocol
31  
32 =head1 SEE ALSO
33  
34 L<Net::OAuth>, L<http://oauth.net>
35  
36 =head1 AUTHOR
37  
38 Originally by Keith Grennan <foss@nearlyfree.org>
39  
40 Currently maintained by Robert Rothenberg <perl@rhizomnic.com>
41  
42 =head1 COPYRIGHT & LICENSE
43  
44 Copyright 2007-2012, 2024-2026 Keith Grennan
45  
46 This program is free software; you can redistribute it and/or modify it
47 under the same terms as Perl itself.
48  
49 =cut
50  
51 1 1;
« OAuth/SignatureMethod/HMAC_SHA1.pm ↑ Summary OAuth/Request.pm »