blib/lib/Net/DNS/SEC/ECCGOST.pm

filter: Statementstmt 88.8% 16 / 18 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 91.6% 22 / 24 CC 1 SCAR 0.5
CC
1
Cov
89%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Net/DNS/SEC/ECDSA.pm ↑ Summary SEC.xs »
1 package Net::DNS::SEC::ECCGOST;
2  
3 #
4 # $Id: ECCGOST.pm 1677 2018-05-22 11:59:10Z willem $
5 #
6 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 $VERSION = (qw$LastChangedRevision: 1677 $)[1];
8  
9  
10 =head1 NAME
11  
12 Net::DNS::SEC::ECCGOST - DNSSEC ECC-GOST digital signature algorithm
13  
14  
15 =head1 SYNOPSIS
16  
17 require Net::DNS::SEC::ECCGOST;
18  
19 $validated = Net::DNS::SEC::ECCGOST->verify( $sigdata, $keyrr, $sigbin );
20  
21  
22 =head1 DESCRIPTION
23  
24 Implementation of GOST R 34.10-2001 elliptic curve digital signature
25 verification procedure.
26  
27 =head2 sign
28  
29 Signature generation is not implemented.
30  
31 =head2 verify
32  
33 $validated = Net::DNS::SEC::ECCGOST->verify( $sigdata, $keyrr, $sigbin );
34  
35 Verifies the signature over the binary sigdata using the specified
36 public key resource record.
37  
38 =cut
39  
40  
41 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 1 ▶use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
45  
46 1 ▶use Digest::GOST 0.06;
Subroutine BEGIN: called CC=1 SCAR=2.6
47 use Digest::GOST::CryptoPro;
48  
49  
50 my %parameters = ( 12 => [840, 'Digest::GOST::CryptoPro'] );
51  
52  
53 sub sign {
54 croak 'Russian Federation standard GOST R 34.10-2001 now obsolete';
55 }
56  
57  
58 sub verify {
59 my ( $class, $sigdata, $keyrr, $sigbin ) = @_;
60  
61 my $algorithm = $keyrr->algorithm;
62 my ( $nid, $object ) = @{$parameters{$algorithm} || []};
63 croak 'public key not ECC-GOST' unless $nid;
64 my $hash = $object->new();
65 $hash->add($sigdata);
66 my $H = reverse $hash->digest;
67  
68 return unless $sigbin;
69  
70 my $eckey = Net::DNS::SEC::libcrypto::EC_KEY_new_ECCGOST();
71 my ( $y, $x ) = unpack 'a32 a32', reverse $keyrr->keybin; # public key
72 Net::DNS::SEC::libcrypto::EC_KEY_set_public_key_affine_coordinates( $eckey, $x, $y );
73  
74 my ( $s, $r ) = unpack 'a32 a32', $sigbin; # RFC5933, RFC4490
75 Net::DNS::SEC::libcrypto::ECCGOST_verify( $H, $r, $s, $eckey );
76 }
77  
78  
79 1;
80  
81 __END__
« blib/lib/Net/DNS/SEC/ECDSA.pm ↑ Summary SEC.xs »