| 1 | package Net::DNS::SEC; | ||
| 2 | |||
| 3 | # | ||
| 4 | # $Id: SEC.pm 1684 2018-06-04 09:03:04Z willem $ | ||
| 5 | # | ||
| 6 | our $VERSION; | ||
| 7 | $VERSION = '1.09'; | ||
| 8 | our $SVNVERSION = (qw$LastChangedRevision: 1684 $)[1]; | ||
| 9 | our $XS_VERSION = $VERSION; | ||
| 10 | $VERSION = eval($VERSION); | ||
| 11 | |||
| 12 | |||
| 13 | =head1 NAME | ||
| 14 | |||
| 15 | Net::DNS::SEC - DNSSEC extensions to Net::DNS | ||
| 16 | |||
| 17 | =head1 SYNOPSIS | ||
| 18 | |||
| 19 | use Net::DNS::SEC; | ||
| 20 | |||
| 21 | =head1 DESCRIPTION | ||
| 22 | |||
| 23 | The Net::DNS::SEC suite provides additional packages required to support | ||
| 24 | DNSSEC as described in RFC4033, RFC4034, RFC4035 and subsequent related | ||
| 25 | documents. | ||
| 26 | |||
| 27 | It also provides support for SIG0 which is useful for dynamic updates | ||
| 28 | using key-pairs. | ||
| 29 | |||
| 30 | RSA, DSA and elliptic curve crypto algorithms are supported. | ||
| 31 | |||
| 32 | Net::DNS::SEC is installed as an extension to an existing Net::DNS | ||
| 33 | installation. | ||
| 34 | |||
| 35 | The extended features are made available by replacing Net::DNS by | ||
| 36 | Net::DNS::SEC in the use declaration. | ||
| 37 | |||
| 38 | =cut | ||
| 39 | |||
| 40 | |||
| 41 | use strict; | ||
| 42 | use base qw(Exporter DynaLoader); | ||
| 43 | |||
| 44 | use Net::DNS 1.01 qw(:DEFAULT); | ||
| 45 | |||
| 46 | our @EXPORT = ( @Net::DNS::EXPORT, qw(algorithm digtype key_difference) ); | ||
| 47 | |||
| 48 | |||
| 49 | use integer; | ||
| 50 | use warnings; | ||
| 51 | use Carp; | ||
| 52 | |||
| 53 | |||
| 54 | =head1 UTILITY FUNCTIONS | ||
| 55 | |||
| 56 | =head2 algorithm | ||
| 57 | |||
| 58 | $mnemonic = algorithm( 5 ); | ||
| 59 | $numeric = algorithm( 'RSA-SHA1' ); | ||
| 60 | print "algorithm mnemonic\t", $mnemonic, "\n"; | ||
| 61 | print "algorithm number:\t", $numeric, "\n"; | ||
| 62 | |||
| 63 | algorithm() provides conversions between an algorithm code number and | ||
| 64 | the corresponding mnemonic. | ||
| 65 | |||
| 66 | =cut | ||
| 67 | |||
| 68 | sub algorithm { &Net::DNS::RR::DS::algorithm; } | ||
| 69 | |||
| 70 | |||
| 71 | =head2 digtype | ||
| 72 | |||
| 73 | $mnemonic = digtype( 2 ); | ||
| 74 | $numeric = digtype( 'SHA-256' ); | ||
| 75 | print "digest type mnemonic\t", $mnemonic, "\n"; | ||
| 76 | print "digest type number:\t", $numeric, "\n"; | ||
| 77 | |||
| 78 | digtype() provides conversions between a digest type number and the | ||
| 79 | corresponding mnemonic. | ||
| 80 | |||
| 81 | =cut | ||
| 82 | |||
| 83 | sub digtype { &Net::DNS::RR::DS::digtype; } | ||
| 84 | |||
| 85 | |||
| 86 | =head2 key_difference | ||
| 87 | |||
| 88 | @result = key_difference( \@a, \@b ); | ||
| 89 | |||
| 90 | Fills @result with all keys in array @a that are not in array @b. | ||
| 91 | |||
| 92 | =cut | ||
| 93 | |||
| 94 | sub key_difference { | ||
| 95 | my $a = shift; | ||
| 96 | my $b = shift; | ||
| 97 | my $r = shift || []; ## 0.17 interface | ||
| 98 | |||
| 99 | eval { | ||
| 100 | local $SIG{__DIE__}; | ||
| 101 | my ($x) = grep !$_->isa('Net::DNS::RR::DNSKEY'), @$a, @$b; | ||
| 102 | die sprintf 'unexpected %s object in key list', ref($x) if $x; | ||
| 103 | |||
| 104 | my %index = map { ( $_->privatekeyname => 1 ) } @$b; | ||
| 105 | @$r = grep !$index{$_->privatekeyname}, @$a; | ||
| 106 | 1; | ||
| 107 | } || do { | ||
| 108 | croak($@) if wantarray; | ||
| 109 | }; | ||
| 110 | |||
| 111 | return wantarray ? (@$r) : $@; | ||
| 112 | } | ||
| 113 | |||
| 114 | |||
| 115 | ######################################## | ||
| 116 | |||
| 117 | eval { Net::DNS::SEC->bootstrap($XS_VERSION) } || warn; | ||
| 118 | |||
| 119 | |||
| 120 | foreach (qw(CDS DS DLV RRSIG SIG)) { | ||
| 121 | new Net::DNS::RR( type => $_ ); # pre-load to access class methods | ||
| 122 | } | ||
| 123 | |||
| 124 | |||
| 125 | 1; | ||
| 126 | __END__ |