File Coverage

blib/lib/Net/DNS/RR/OPENPGPKEY.pm
Criterion Covered Total %
statement 34 34 100.0
branch 2 2 100.0
path n/a
condition 2 2 100.0
subroutine 11 11 100.0
pod 2 2 100.0
total 51 51 100.0


line stmt bran path cond sub pod time code
1               package Net::DNS::RR::OPENPGPKEY;
2                
3 1       1   6 use strict;
  1           2  
  1           44  
4 1       1   3 use warnings;
  1           2  
  1           67  
5               our $VERSION = (qw$Id: OPENPGPKEY.pm 2003 2025-01-21 12:06:06Z willem $)[2];
6                
7 1       1   5 use base qw(Net::DNS::RR);
  1           1  
  1           87  
8                
9                
10               =head1 NAME
11                
12               Net::DNS::RR::OPENPGPKEY - DNS OPENPGPKEY resource record
13                
14               =cut
15                
16 1       1   5 use integer;
  1           1  
  1           5  
17                
18 1       1   23 use MIME::Base64;
  1           2  
  1           384  
19                
20                
21               sub _decode_rdata { ## decode rdata from wire-format octet string
22 1       1   3 my ( $self, $data, $offset ) = @_;
23                
24 1           1 my $length = $self->{rdlength};
25 1           3 $self->keybin( substr $$data, $offset, $length );
26 1           3 return;
27               }
28                
29                
30               sub _encode_rdata { ## encode rdata as wire-format octet string
31 5       5   5 my $self = shift;
32                
33 5           8 return pack 'a*', $self->keybin;
34               }
35                
36                
37               sub _format_rdata { ## format rdata portion of RR string.
38 3       3   19 my $self = shift;
39                
40 3           5 my @base64 = split /\s+/, encode_base64( $self->keybin );
41 3           11 return @base64;
42               }
43                
44                
45               sub _parse_rdata { ## populate RR from rdata in argument list
46 2       2   4 my ( $self, @argument ) = @_;
47                
48 2           4 $self->key(@argument);
49 2           4 return;
50               }
51                
52                
53               sub key {
54 5       5 1 11 my ( $self, @value ) = @_;
55 5 100         11 return MIME::Base64::encode( $self->keybin(), "" ) unless scalar @value;
56 3           13 return $self->keybin( MIME::Base64::decode( join "", @value ) );
57               }
58                
59                
60               sub keybin {
61 16       16 1 599 my ( $self, @value ) = @_;
62 16           696 for (@value) { $self->{keybin} = $_ }
  4           6  
63 16     100     76 return $self->{keybin} || "";
64               }
65                
66                
67               1;
68               __END__