lib/Net/SSLeay/CA/Util.pm untested

filter: Statementstmt 0.0% 0 / 72 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 101 CC 1 SCAR 6.9
CC
1
Cov
0%
user_faux_mail
2.0
localuser
2.0
hostfqdn
2.0
CRAP 2.0
1 use Object::Pad ':experimental(:all)';
2  
3 package Net::SSLeay::CA::Util;
4  
5 class Net::SSLeay::CA::Util : does(Net::SSLeay::CA::Base);
6  
7 use utf8;
8 use v5.40;
9  
10 use parent 'Exporter';
11 use vars '@EXPORT_OK';
12  
13 @EXPORT_OK = qw(hostfqdn domainname localuser);
14  
15 use List::Util 'first';
16 use Net::Domain;
17  
18 sub user_faux_mail {
19 first { /\.[^.]+$/ } @Net::Domain::{qw(hostfqdn domainname make_anonymous)};
20 }
21  
22 sub localuser {
23 getpwent;
24 }
25  
26 sub hostfqdn {
27 Net::Domain::__SUB__->(@_);
28 }
29  
30 sub domainname {
31 Net::Domain::__SUB__->(@_);
32 }
33  
34 method adsf {
35 dmsg( { $self->cliopts->%{qw(config cmd extra-cmd verbose debug catop)} } );
36 }
37  
38 sub valid_timespan {
39  
40 }
41  
42 sub rc4 : prototype($$;$) ( $message, $key, $skip = undef ) {
43 my @s = 0 .. 255;
44 my @k = unpack 'C*', $key;
45 my @message = unpack 'C*', $message;
46  
47 #my ( $x, $y );
48 $skip = 256 unless ( defined $skip );
49  
50 my $y = 0;
51  
52 for my $x ( 0 .. 255 ) {
53 @s[ $x, $y ] = @s[ $y, $x ];
54 }
55  
56 my $x = 0;
57 $y = 0;
58  
59 for my $i ( 1 .. $skip ) {
60 $x = ( $x + 1 ) % 256;
61 $y = ( $y + $s[$x] ) % 256;
62 @s[ $x, $y ] = @s[ $y, $x ];
63 }
64  
65 for my $msg (@message) {
66 $x = ( $x + 1 ) % 256;
67 $y = ( $y + $s[$x] ) % 256;
68 @s[ $x, $y ] = @s[ $y, $x ];
69 $msg ^= $s[ ( $s[$x] + $s[$y] ) % 256 ];
70 }
71  
72 pack 'C*', @message;
73 }
74  
75 sub hide_data : prototype($$$$;$)
76 ( $data, $bytes, $key, $secret, $base64 = undef ) {
77 my $crypt =
78 rc4( null_string($bytes), make_key( $key, $secret, 32 ) . $data );
79  
80 return encode_base64( $crypt, "" ) if $base64;
81 return $crypt;
82 }
83  
84 method cfg_expand : common : prototype($%) ( $str, %grammar ) {
85 my $expanded = $str =~ s/%(\w+)%/
86 my @expansions=@{$grammar{$1}};
87 $class->cfg_expand($expansions[rand @expansions],%grammar);
88 /rxge;
89  
90 $expanded;
91 }
92  
93 method make_anonymous : common ( $salt = __PACKAGE__->epoch ) {
94 my $string = hostfqdn() // domainname();
95 $string .= ",$salt";
96  
97 srand unpack "N",
98 hide_data( $string, 3, "silly",
99 Net::SSLeay::SHA512( Net::SSLeay::gen_random(32) ) );
100  
101 $class->cfg_expand(
102 "%G% %W%",
103 W => [
104 "%B%%V%%M%%I%%V%%F%", "%B%%V%%M%%E%",
105 "%O%%E%", "%B%%V%%M%%I%%V%%F%",
106 "%B%%V%%M%%E%", "%O%%E%",
107 "%B%%V%%M%%I%%V%%F%", "%B%%V%%M%%E%"
108 ],
109 B => [
110 "B", "B", "C", "D", "D", "F", "F", "G", "G", "H",
111 "H", "M", "N", "P", "P", "S", "S", "W", "Ch", "Br",
112 "Cr", "Dr", "Bl", "Cl", "S"
113 ],
114 I => [
115 "b", "d", "f", "h", "k", "l", "m", "n",
116 "p", "s", "t", "w", "ch", "st"
117 ],
118 V => [ "a", "e", "i", "o", "u" ],
119 M => [
120 "ving", "zzle", "ndle", "ddle", "ller", "rring",
121 "tting", "nning", "ssle", "mmer", "bber", "bble",
122 "nger", "nner", "sh", "ffing", "nder", "pper",
123 "mmle", "lly", "bling", "nkin", "dge", "ckle",
124 "ggle", "mble", "ckle", "rry"
125 ],
126 F => [
127 "t", "ck", "tch", "d", "g", "n",
128 "t", "t", "ck", "tch", "dge", "re",
129 "rk", "dge", "re", "ne", "dging"
130 ],
131 O => [
132 "Small", "Snod", "Bard", "Billing",
133 "Black", "Shake", "Tilling", "Good",
134 "Worthing", "Blythe", "Green", "Duck",
135 "Pitt", "Grand", "Brook", "Blather",
136 "Bun", "Buzz", "Clay", "Fan",
137 "Dart", "Grim", "Honey", "Light",
138 "Murd", "Nickle", "Pick", "Pock",
139 "Trot", "Toot", "Turvey"
140 ],
141 E => [
142 "shaw", "man", "stone", "son", "ham", "gold",
143 "banks", "foot", "worth", "way", "hall", "dock",
144 "ford", "well", "bury", "stock", "field", "lock",
145 "dale", "water", "hood", "ridge", "ville", "spear",
146 "forth", "will"
147 ],
148 G => [
149 "Albert", "Alice", "Angus", "Archie",
150 "Augustus", "Barnaby", "Basil", "Beatrice",
151 "Betsy", "Caroline", "Cedric", "Charles",
152 "Charlotte", "Clara", "Cornelius", "Cyril",
153 "David", "Doris", "Ebenezer", "Edward",
154 "Edwin", "Eliza", "Emma", "Ernest",
155 "Esther", "Eugene", "Fanny", "Frederick",
156 "George", "Graham", "Hamilton", "Hannah",
157 "Hedda", "Henry", "Hugh", "Ian",
158 "Isabella", "Jack", "James", "Jarvis",
159 "Jenny", "John", "Lillian", "Lydia",
160 "Martha", "Martin", "Matilda", "Molly",
161 "Nathaniel", "Nell", "Nicholas", "Nigel",
162 "Oliver", "Phineas", "Phoebe", "Phyllis",
163 "Polly", "Priscilla", "Rebecca", "Reuben",
164 "Samuel", "Sidney", "Simon", "Sophie",
165 "Thomas", "Walter", "Wesley", "William"
166 ],
167 );
168 }
169  
170 method __pkgfn__ : common ($pkgname = undef) {
171 $pkgname //= $class;
172 "$pkgname.pm" =~ s/::/\//rg;
173 }