lib/Crypt/Perl/ECDSA/NIST.pm

filter: Statementstmt 94.1% 32 / 34 Branchbran 70.0% 7 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 2 totaltotal 87.2% 48 / 55 CC 7 SCAR 10.4
CC
7
Cov
89%
get_curve_name_for_nist
5.1
get_nist_for_curve_name
3.3
BEGIN
1.0
CRAP 2.8
« blib/lib/Crypt/Perl/Ed25519/Parse.pm ↑ Summary blib/lib/Crypt/Perl/X509/Extension/nameConstraints.pm »
1 package Crypt::Perl::ECDSA::NIST;
2  
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 7 ▶use Symbol::Get ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 7 ▶use Crypt::Perl::X ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 7 ▶use constant JWK_CURVE_prime256v1 => 'P-256';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 7 ▶use constant JWK_CURVE_secp384r1 => 'P-384';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 7 ▶use constant JWK_CURVE_secp521r1 => 'P-521';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub get_nist_for_curve_name {
15 5 ▶ my ($curve_name) = @_;
Subroutine get_nist_for_curve_name: called CC=3 SCAR=12.0
Pod undocumented
16  
17 5 ▶ die Crypt::Perl::X::create('Generic', 'Need curve name!') if !length $curve_name;
Branch: 1 branch
BranchTrueFalseTotal
unless length $curve_name 0 5 5
18  
19 5 ▶ my $cr = __PACKAGE__->can("JWK_CURVE_$curve_name") or do {
Branch: 1 branch
BranchTrueFalseTotal
my $cr = __PACKAGE__->can("JWK_CURVE_$curve_name") or do { die Crypt::Perl::X::create("ECDSA::NoCurveForName", {"name", $curve_name}) } 0 5 5
20 0 die Crypt::Perl::X::create('ECDSA::NoCurveForName', { name => $curve_name });
21 };
22  
23 5 return $cr->();
24 }
25  
26 sub get_curve_name_for_nist {
27 4 ▶ my ($nist_name) = @_;
Subroutine get_curve_name_for_nist: called CC=5 SCAR=16.3
Pod undocumented
28  
29 4 ▶ die Crypt::Perl::X::create('Generic', 'Need NIST curve name!') if !length $nist_name;
Branch: 1 branch
BranchTrueFalseTotal
unless length $nist_name 0 4 4
30  
31 4 for my $node ( Symbol::Get::get_names() ) {
32 14 ▶ next if $node !~ m<\AJWK_CURVE_(.+)>;
Branch: 1 branch
BranchTrueFalseTotal
unless $node =~ /\AJWK_CURVE_(.+)/ 6 8 14
33  
34 8 my $nist = __PACKAGE__->can($node)->();
35 8 ▶ return $1 if $nist eq $nist_name;
Branch: 1 branch
BranchTrueFalseTotal
if $nist eq $nist_name 4 4 8
36 }
37  
38 0 die Crypt::Perl::X::create('ECDSA::NoCurveForNISTName', { name => $nist_name });
39 }
40  
41 7 1;
« blib/lib/Crypt/Perl/Ed25519/Parse.pm ↑ Summary blib/lib/Crypt/Perl/X509/Extension/nameConstraints.pm »