| 1 | package Crypt::DSA::Signature; | ||||||||||||||||||
| 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 | 7 | ▶ | use Carp qw( croak ); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 6 | |||||||||||||||||||
| 7 | 7 | our $VERSION = '1.24'; #VERSION | |||||||||||||||||
| 8 | # | ||||||||||||||||||
| 9 | 7 | ▶ | use vars qw{$VERSION}; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 10 | |||||||||||||||||||
| 11 | 4 | ▶ | sub new { | ||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 12 | 4 | my $class = shift; | |||||||||||||||||
| 13 | 4 | my %param = @_; | |||||||||||||||||
| 14 | 4 | my $sig = bless { }, $class; | |||||||||||||||||
| 15 | 4 | ▶ | if ($param{Content}) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 16 | 3 | return $sig->deserialize(%param); | |||||||||||||||||
| 17 | } | ||||||||||||||||||
| 18 | 1 | $sig; | |||||||||||||||||
| 19 | } | ||||||||||||||||||
| 20 | |||||||||||||||||||
| 21 | 7 | ▶ | BEGIN { | ||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.9
| |||||||||||||||||||
| 22 | 7 | ▶ | no strict 'refs'; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 23 | 7 | for my $meth (qw( r s )) { | |||||||||||||||||
| 24 | 19 | ▶ | *$meth = sub { | ||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=24.5
| |||||||||||||||||||
| 25 | 19 | my($key, $value) = @_; | |||||||||||||||||
| 26 | 19 | ▶ | if (ref $value eq 'Math::Pari') { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 27 | 0 | $key->{$meth} = Math::Pari::pari2pv($value); | |||||||||||||||||
| 28 | } | ||||||||||||||||||
| 29 | elsif (ref $value) { | ||||||||||||||||||
| 30 | 8 | $key->{$meth} = "$value"; | |||||||||||||||||
| 31 | } | ||||||||||||||||||
| 32 | elsif ($value) { | ||||||||||||||||||
| 33 | 0 | ▶ | if ($value =~ /^0x/) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 34 | 0 | $key->{$meth} = Math::BigInt->new($value)->bstr; | |||||||||||||||||
| 35 | } | ||||||||||||||||||
| 36 | else { | ||||||||||||||||||
| 37 | 0 | $key->{$meth} = $value; | |||||||||||||||||
| 38 | } | ||||||||||||||||||
| 39 | } | ||||||||||||||||||
| 40 | 19 | ▶ | my $ret = $key->{$meth} || ""; | ||||||||||||||||
|
Condition50%1/2
$key->{$meth} || ''
MC/DC0%0/1
$key->{$meth} || ''
$key->{$meth}
Truth table50%1/2
A
A= $key->{$meth}
| |||||||||||||||||||
| 41 | 19 | ▶ | $ret = Math::BigInt->new("$ret") if $ret =~ /^\d+$/; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 42 | 19 | $ret; | |||||||||||||||||
| 43 | 14 | }; | |||||||||||||||||
| 44 | } | ||||||||||||||||||
| 45 | } | ||||||||||||||||||
| 46 | |||||||||||||||||||
| 47 | 4 | ▶ | sub asn { | ||||||||||||||||
|
Subroutine
asn: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||
| 48 | 4 | require Convert::ASN1; | |||||||||||||||||
| 49 | 4 | my $asn = Convert::ASN1->new; | |||||||||||||||||
| 50 | 4 | ▶ | $asn->prepare('SEQUENCE { r INTEGER, s INTEGER }') or croak $asn->{error}; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 51 | 4 | $asn; | |||||||||||||||||
| 52 | } | ||||||||||||||||||
| 53 | |||||||||||||||||||
| 54 | 3 | ▶ | sub deserialize { | ||||||||||||||||
|
Subroutine
deserialize: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||
| 55 | 3 | my $sig = shift; | |||||||||||||||||
| 56 | 3 | my %param = @_; | |||||||||||||||||
| 57 | 3 | my $asn = __PACKAGE__->asn; | |||||||||||||||||
| 58 | 3 | my $ref; | |||||||||||||||||
| 59 | 3 | require MIME::Base64; | |||||||||||||||||
| 60 | ## Turn off warnings, because we're attempting to base64-decode content | ||||||||||||||||||
| 61 | ## that may not be base64-encoded. | ||||||||||||||||||
| 62 | 3 | local $^W = 0; | |||||||||||||||||
| 63 | 3 | for ($param{Content}, MIME::Base64::decode_base64($param{Content})) { | |||||||||||||||||
| 64 | 4 | my $out = $asn->decode($_); | |||||||||||||||||
| 65 | 4 | ▶ | $ref = $out, last if $out; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 66 | } | ||||||||||||||||||
| 67 | 3 | ▶ | croak "Invalid Content" unless $ref; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 68 | 3 | $sig->s($ref->{s}); | |||||||||||||||||
| 69 | 3 | $sig->r($ref->{r}); | |||||||||||||||||
| 70 | 3 | $sig; | |||||||||||||||||
| 71 | } | ||||||||||||||||||
| 72 | |||||||||||||||||||
| 73 | 1 | ▶ | sub serialize { | ||||||||||||||||
|
Subroutine
serialize: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||
| 74 | 1 | my $sig = shift; | |||||||||||||||||
| 75 | 1 | my %param = @_; | |||||||||||||||||
| 76 | 1 | my $asn = __PACKAGE__->asn; | |||||||||||||||||
| 77 | my $buf = $asn->encode({ s => $sig->s, r => $sig->r }) | ||||||||||||||||||
| 78 | 1 | ▶ | or croak $asn->{error}; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 79 | 1 | $buf; | |||||||||||||||||
| 80 | } | ||||||||||||||||||
| 81 | |||||||||||||||||||
| 82 | 7 | 1; | |||||||||||||||||
| 83 | __END__ | ||||||||||||||||||