| 1 | package Mail::DKIM::ARC::Sealscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/; |
| 2 | use strictscip-perl cpan Mail-DKIM 1.20240923 strict/; |
| 3 | use warningsscip-perl cpan Mail-DKIM 1.20240923 warnings/; |
| 4 | our $VERSIONscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/$VERSION. = '1.20240923'; # VERSION |
| 5 | # ABSTRACT: represents a ARC-Seal header |
| 6 | |
| 7 | # Copyright 2017 FastMail Pty Ltd. All Rights Reserved. |
| 8 | # Bron Gondwana <[email protected]> |
| 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 | use basescip-perl cpan Mail-DKIM 1.20240923 base/ 'Mail::DKIM::ARC::MessageSignature'; |
| 14 | |
| 15 | |
| 16 | sub newscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/new(). { |
| 17 | my $class = shiftscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/shift().; |
| 18 | my %prms = @_scip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/`@_`.; |
| 19 | my $self = {}; |
| 20 | blessscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/bless(). $self, $class; |
| 21 | |
| 22 | $self->instancescip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/instance().( $prms{'Instance'} ) if existsscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/exists(). $prms{'Instance'}; |
| 23 | $self->algorithmscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/algorithm().( $prms{'Algorithm'} || 'rsa-sha256' ); |
| 24 | $self->signaturescip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/signature().( $prms{'Signature'} ); |
| 25 | $self->canonicalizationscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/canonicalization().( $prms{'Method'} ) if existsscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/exists(). $prms{'Method'}; |
| 26 | $self->chainscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/chain().( $prms{'Chain'} || 'none' ); |
| 27 | $self->domainscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/domain().( $prms{'Domain'} ); |
| 28 | $self->selectorscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/selector().( $prms{'Selector'} ); |
| 29 | $self->timestampscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/timestamp().( |
| 30 | definedscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/defined(). $prms{'Timestamp'} ? $prms{'Timestamp'} : timescip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/time().() ); |
| 31 | $self->expirationscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/expiration().( $prms{'Expiration'} ) if definedscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/defined(). $prms{'Expiration'}; |
| 32 | $self->tagsscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/tags().( $prms{'Tags'} ) if definedscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/defined(). $prms{'Tags'}; |
| 33 | $self->keyscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/key().( $prms{'Key'} ) if definedscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/defined(). $prms{'Key'}; |
| 34 | |
| 35 | return $self; |
| 36 | } |
| 37 | |
| 38 | sub body_hashscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/body_hash(). { |
| 39 | |
| 40 | # Not defined for ARC-Seal |
| 41 | return; |
| 42 | } |
| 43 | |
| 44 | sub DEFAULT_PREFIXscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/DEFAULT_PREFIX(). { |
| 45 | return 'ARC-Seal:'; |
| 46 | } |
| 47 | |
| 48 | |
| 49 | sub chainscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/chain(). { |
| 50 | my $self = shiftscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/shift().; |
| 51 | if (@_scip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/`@_`.) { |
| 52 | my $cv = shiftscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/shift().; |
| 53 | diescip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/die(). "INVALID chain value $cv" |
| 54 | unless grepscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/grep(). { $cv eq $_scip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/$_. } qw(none fail pass); |
| 55 | $self->set_tagscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/set_tag().( 'cv', $cv ); |
| 56 | } |
| 57 | return $self->get_tagscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/get_tag().('cv'); |
| 58 | } |
| 59 | |
| 60 | |
| 61 | sub canonicalizationscip-perl cpan Mail-DKIM 1.20240923 Mail/DKIM/ARC/Seal/canonicalization(). { |
| 62 | return ( 'seal', 'seal' ); |
| 63 | } |
| 64 | |
| 65 | |
| 66 | 1; |
| 67 | |
| 68 | __END__ |
| 69 | |
| 70 | =pod |
| 71 | |
| 72 | =encoding UTF-8 |
| 73 | |
| 74 | =head1 NAME |
| 75 | |
| 76 | Mail::DKIM::ARC::Seal - represents a ARC-Seal header |
| 77 | |
| 78 | =head1 VERSION |
| 79 | |
| 80 | version 1.20240923 |
| 81 | |
| 82 | =head1 CONSTRUCTORS |
| 83 | |
| 84 | =head2 new() - create a new signature from parameters |
| 85 | |
| 86 | my $signature = Mail::DKIM::ARC::Seal->new( |
| 87 | [ Algorithm => 'rsa-sha256', ] |
| 88 | [ Signature => $base64, ] |
| 89 | [ Domain => 'example.org', ] |
| 90 | [ Instance => 1, ] |
| 91 | [ Chain => 'none', ] # none|fail|pass |
| 92 | [ Query => 'dns', ] |
| 93 | [ Selector => 'alpha', ] |
| 94 | [ Timestamp => time(), ] |
| 95 | [ Expiration => time() + 86400, ] |
| 96 | ); |
| 97 | |
| 98 | The ARC-Seal is similar to a DKIM signature but with the following changes: |
| 99 | |
| 100 | https://tools.ietf.org/html/draft-ietf-dmarc-arc-protocol-06 |
| 101 | |
| 102 | 5.1.1.1. Tags in the ARC-Seal Header Field Value |
| 103 | |
| 104 | The following tags are the only supported tags for an ARC-Seal field. |
| 105 | All of them MUST be present. Unknown tags MUST be ignored and do not |
| 106 | affect the validity of the header. |
| 107 | |
| 108 | o a = hash algorithm; syntax is the same as the "a=" tag defined in |
| 109 | Section 3.5 of [RFC6376]; |
| 110 | |
| 111 | o b = digital signature; syntax is the same as the "b=" tag defined |
| 112 | in Section 3.5 of [RFC6376]; |
| 113 | |
| 114 | o cv = chain validation status: valid values: |
| 115 | |
| 116 | * 'none' = no pre-existing chain; |
| 117 | |
| 118 | * 'fail' = the chain as received does not or can not validate; or |
| 119 | |
| 120 | * 'pass' = valid chain received. |
| 121 | |
| 122 | o d = domain for key; syntax is the same as the "d=" tag defined in |
| 123 | Section 3.5 of [RFC6376]; |
| 124 | |
| 125 | o i = "instance" or sequence number; monotonically increasing at |
| 126 | each "sealing" entity, beginning with '1', see Section 5.1.1.1.1 |
| 127 | regarding the valid range |
| 128 | |
| 129 | o s = selector for key; syntax is the same as the "s=" tag defined |
| 130 | in Section 3.5 of [RFC6376]; |
| 131 | |
| 132 | o t = timestamp; syntax is the same as the "t=" tag defined in |
| 133 | Section 3.5 of [RFC6376]. |
| 134 | |
| 135 | =head2 chain() - get or set the chain parameter (cv=) field |
| 136 | |
| 137 | This must be one of "pass", "fail" or "none". For a chain to be valid, |
| 138 | the very first (i=1) seal MUST be cv=none, and all further seals MUST be |
| 139 | cv=pass. |
| 140 | |
| 141 | =head2 instance() - get or set the signing instance (i=) field |
| 142 | |
| 143 | my $i = $signature->instance; |
| 144 | |
| 145 | Instances must be integers less than 1024 according to the spec. |
| 146 | |
| 147 | =head1 SEE ALSO |
| 148 | |
| 149 | L<Mail::DKIM::Signature> for DKIM-Signature headers |
| 150 | |
| 151 | L<Mail::DKIM::ARC::MessageSignature> for ARC-Message-Signature headers |
| 152 | |
| 153 | =head1 AUTHORS |
| 154 | |
| 155 | =over 4 |
| 156 | |
| 157 | =item * |
| 158 | |
| 159 | Jason Long <[email protected]> |
| 160 | |
| 161 | =item * |
| 162 | |
| 163 | Marc Bradshaw <[email protected]> |
| 164 | |
| 165 | =item * |
| 166 | |
| 167 | Bron Gondwana <[email protected]> (ARC) |
| 168 | |
| 169 | =back |
| 170 | |
| 171 | =head1 THANKS |
| 172 | |
| 173 | Work on ensuring that this module passes the ARC test suite was |
| 174 | generously sponsored by Valimail (https://www.valimail.com/) |
| 175 | |
| 176 | =head1 COPYRIGHT AND LICENSE |
| 177 | |
| 178 | =over 4 |
| 179 | |
| 180 | =item * |
| 181 | |
| 182 | Copyright (C) 2013 by Messiah College |
| 183 | |
| 184 | =item * |
| 185 | |
| 186 | Copyright (C) 2010 by Jason Long |
| 187 | |
| 188 | =item * |
| 189 | |
| 190 | Copyright (C) 2017 by Standcore LLC |
| 191 | |
| 192 | =item * |
| 193 | |
| 194 | Copyright (C) 2020 by FastMail Pty Ltd |
| 195 | |
| 196 | =back |
| 197 | |
| 198 | This library is free software; you can redistribute it and/or modify |
| 199 | it under the same terms as Perl itself, either Perl version 5.8.6 or, |
| 200 | at your option, any later version of Perl 5 you may have available. |
| 201 | |
| 202 | =cut |