File Coverage

blib/lib/Mail/DKIM/ARC/MessageSignature.pm
Criterion Covered Total %
statement 37 37 100.0
branch 14 18 77.7
condition 3 5 60.0
subroutine 7 7 100.0
pod 2 3 66.6
total 63 70 90.0


line stmt bran cond sub pod time code
1             package Mail::DKIM::ARC::MessageSignature;
2 3     3   24 use strict;
  3         7  
  3         130  
3 3     3   19 use warnings;
  3         13  
  3         256  
4             our $VERSION = '1.20240923'; # VERSION
5             # ABSTRACT: Subclass of Mail::DKIM::Signature which represents a ARC-Message-Signature header
6              
7             # Copyright 2017 FastMail Pty Ltd. All Rights Reserved.
8             # Bron Gondwana
9              
10             # This program is free software; you can redistribute it and/or
11             # modify it under the same terms as Perl itself.
12              
13 3     3   20 use base 'Mail::DKIM::Signature';
  3         23  
  3         2213  
14 3     3   26 use Carp;
  3         8  
  3         1409  
15              
16              
17             sub new {
18 386     386 1 834 my $class = shift;
19 386         1259 my %prms = @_;
20 386         901 my $self = {};
21 386         874 bless $self, $class;
22              
23 386 100       1373 $self->instance( $prms{'Instance'} ) if exists $prms{'Instance'};
24 386   100     2558 $self->algorithm( $prms{'Algorithm'} || 'rsa-sha256' );
25 386         2016 $self->signature( $prms{'Signature'} );
26 386 100       1710 $self->canonicalization( $prms{'Method'} ) if exists $prms{'Method'};
27 386         1833 $self->domain( $prms{'Domain'} );
28 386         2075 $self->headerlist( $prms{'Headers'} );
29 386 50       1392 $self->protocol( $prms{'Query'} ) if exists $prms{'Query'};
30 386         1957 $self->selector( $prms{'Selector'} );
31 386 100       1358 $self->timestamp( $prms{'Timestamp'} ) if defined $prms{'Timestamp'};
32 386 50       1115 $self->expiration( $prms{'Expiration'} ) if defined $prms{'Expiration'};
33 386 50       1168 $self->tags( $prms{'Tags'} ) if defined $prms{'Tags'};
34 386 100       1126 $self->key( $prms{'Key'} ) if defined $prms{'Key'};
35              
36 386         1346 return $self;
37             }
38              
39             sub DEFAULT_PREFIX {
40 443     443 0 1501 return 'ARC-Message-Signature:';
41             }
42              
43              
44             sub instance {
45 756     756 1 1349 my $self = shift;
46              
47             # ARC identities must be a number
48 756 100       5323 if (@_) {
49 38         94 my $val = int(shift);
50 38 50 33     238 die "INVALID instance $val" unless ( $val > 0 and $val < 1025 );
51 38         215 $self->set_tag( 'i', $val );
52             }
53              
54 756         2185 my $i = $self->get_tag('i');
55 756         3091 return $i;
56             }
57              
58              
59             1;
60              
61             __END__