blib/lib/Crypt/Perl/X509/Extension/ct_precert_scts.pm untested

filter: Statementstmt 0.0% 0 / 28 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 40 CC 1 SCAR 6.9
CC
1
Cov
0%
new
2.0
_encode_params
2.0
_tls_length_encode
2.0
CRAP 2.0
1 package Crypt::Perl::X509::Extension::ct_precert_scts;
2  
3 use strict;
4 use warnings;
5  
6 =encoding utf-8
7  
8 =head1 NAME
9  
10 Crypt::Perl::X509::Extension::ct_precert_scts - X.509 ct_precert_scts extension
11  
12 =head1 SYNOPSIS
13  
14 my $extn = Crypt::Perl::X509::Extension::ct_precert_scts->new(
15 {
16 log_id => ..,
17 timestamp => ..,
18 extensions => [ .. ],
19 signature_algorithm => '..',
20 },
21 # ..
22 );
23  
24 =head1 DESCRIPTION
25  
26 Instances of this class represent a C<ct_precert_scts> extension
27 of an X.509 (SSL) certificate.
28  
29 You probably don’t need to
30 instantiate this class directly; see L<Crypt::Perl::PKCS10>
31 and L<Crypt::Perl::X509> for the way this module is meant to be used.
32  
33 =head1 SEE ALSO
34  
35 =over
36  
37 =item * L<https://tools.ietf.org/html/rfc6962#section-3.3>
38  
39 =item * L<https://letsencrypt.org/2018/04/04/sct-encoding.html>
40  
41 =back
42  
43 =cut
44  
45 use parent qw(
46 Crypt::Perl::X509::Extension
47 );
48  
49 use Crypt::Perl::X509::SCT ();
50  
51 use constant OID => '1.3.6.1.4.1.11129.2.4.2';
52  
53 use constant ASN1 => <<END;
54 ct_precert_scts ::= SignedCertificateTimestampList
55  
56 SignedCertificateTimestampList ::= OCTET STRING
57 END
58  
59 sub new {
60 my ($class, @sct_hrs) = @_;
61  
62 return bless \@sct_hrs, $class;
63 }
64  
65 sub _encode_params {
66 my ($self) = @_;
67  
68 my @scts = map { Crypt::Perl::X509::SCT::encode(%$_) } @$self;
69  
70 # Prefix with length.
71 _tls_length_encode($_) for @scts;
72  
73 my $list = join( q<>, @scts );
74  
75 _tls_length_encode($list);
76 }
77  
78 sub _tls_length_encode {
79 substr( $_[0], 0, 0, pack('n', length $_[0]) );
80  
81 return $_[0];
82 }
83  
84 1;