File Coverage

blib/lib/Algorithm/IRCSRP2/Exchange.pm
Criterion Covered Total %
statement 2 4 50.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 4 6 66.6


line stmt bran cond sub pod time code
1             package Algorithm::IRCSRP2::Exchange;
2              
3             BEGIN {
4 1     1   1442 $Algorithm::IRCSRP2::Exchange::VERSION = '0.501';
5             }
6              
7             # ABSTRACT: utility functions
8              
9 1     1   522 use Moose::Role;
  0            
  0            
10              
11             # core
12             use Scalar::Util qw(blessed);
13              
14             foreach my $k (qw(I x a A b B S u K1 K2 M1 M2 P s v)) {
15             has $k => (
16             'isa' => 'Any',
17             'is' => 'rw',
18             'default' => undef,
19             'trigger' => sub {
20             my ($self, $new, $old) = @_;
21              
22             my $str = "Changing IRCSRP exchange $k from %s to %s";
23              
24             my ($oldstr, $newstr);
25              
26             my $formatstr = sub {
27             my ($string) = @_;
28              
29             my $retstr;
30              
31             if (blessed($string)) {
32             $retstr = (blessed($string) eq 'Math::BigInt') ? $string->bstr : $retstr;
33             }
34             elsif (!defined($string)) {
35             $retstr = 'undef';
36             }
37             else {
38             if ($string =~ /[[:^ascii:]]/) {
39             $retstr = Algorithm::IRCSRP2::bytes2int($string);
40             }
41             else {
42             $retstr = $string;
43             }
44             }
45             return $retstr;
46             };
47              
48             $self->debug_cb->(sprintf($str, $formatstr->($old), $formatstr->($new)));
49             }
50             );
51             }
52              
53             has 'cipher' => (
54             'isa' => 'Crypt::OpenSSL::AES',
55             'is' => 'rw',
56             );
57              
58             has 'session_key' => (
59             'isa' => 'Str',
60             'is' => 'rw',
61             );
62              
63             has 'mac_key' => (
64             'isa' => 'Str',
65             'is' => 'rw',
66             );
67              
68             no Moose::Role;
69              
70             1;
71              
72             __END__
73              
74             =pod
75              
76             =head1 NAME
77              
78             Algorithm::IRCSRP2::Exchange - utility functions
79              
80             =head1 VERSION
81              
82             version 0.501
83              
84             =head1 DESCRIPTION
85              
86             Role for all the member variables. See
87             L<http://www.bjrn.se/ircsrp/ircsrp.2.0.txt> for their meaning.
88              
89             =head1 AUTHOR
90              
91             Adam Flott <adam@npjh.com>
92              
93             =head1 COPYRIGHT AND LICENSE
94              
95             This software is copyright (c) 2011 by Adam Flott.
96              
97             This is free software; you can redistribute it and/or modify it under
98             the same terms as the Perl 5 programming language system itself.
99              
100             =cut