| 1 | # Copyright (c) 2000-2005 Graham Barr <gbarr@pobox.com>. All rights reserved. | ||||||||||||||||||||||||||||
| 2 | # This program is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||
| 3 | # modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package Convert::ASN1; | ||||||||||||||||||||||||||||
| 6 | 24 | $Convert::ASN1::VERSION = '0.36'; | |||||||||||||||||||||||||||
| 7 | 24 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 24 | ▶ | use Socket; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 24 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||
| 11 | 24 | local $SIG{__DIE__}; | |||||||||||||||||||||||||||
| 12 | 24 | ▶ | eval { require bytes } and 'bytes'->import | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | sub asn_recv { # $socket, $buffer, $flags | ||||||||||||||||||||||||||
|
Subroutine
asn_recv: called CC=20 SCAR=47.1
Pod
documented
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1 | my $peer; | |||||||||||||||||||||||||||
| 18 | my $buf; | ||||||||||||||||||||||||||||
| 19 | 1 | my $n = 128; | |||||||||||||||||||||||||||
| 20 | 1 | my $pos = 0; | |||||||||||||||||||||||||||
| 21 | 1 | my $depth = 0; | |||||||||||||||||||||||||||
| 22 | 1 | my $len = 0; | |||||||||||||||||||||||||||
| 23 | 1 | my($tmp,$tb,$lb); | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | MORE: | ||||||||||||||||||||||||||||
| 26 | 1 | ▶ | for( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | $peer = recv($_[0],$buf,$n,MSG_PEEK); | ||||||||||||||||||||||||||||
| 28 | defined $peer; | ||||||||||||||||||||||||||||
| 29 | $peer = recv($_[0],$buf,$n<<=1,MSG_PEEK) | ||||||||||||||||||||||||||||
| 30 | ) { | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 1 | ▶ | if ($depth) { # Are we searching of "\0\0" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | unless (2+$pos <= length $buf) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | next MORE if $n == length $buf; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 0 | last MORE; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | if(substr($buf,$pos,2) eq "\0\0") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | unless (--$depth) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 0 | $len = $pos + 2; | |||||||||||||||||||||||||||
| 42 | 0 | last MORE; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | # If we can decode a tag and length we can determine the length | ||||||||||||||||||||||||||||
| 48 | 1 | ($tb,$tmp) = asn_decode_tag(substr($buf,$pos)); | |||||||||||||||||||||||||||
| 49 | 1 | ▶ | unless ($tb || $pos+$tb < length $buf) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$tb or $pos + $tb < length $buf
MC/DC0%0/2
$tb or $pos + $tb < length $buf
$tb
$pos + $tb < length $buf
Truth table33%1/3
A or B
A= $tbB= $pos + $tb < length $buf
| |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | next MORE if $n == length $buf; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 0 | last MORE; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 1 | ▶ | if (unpack("C",substr($buf,$pos+$tb,1)) == 0x80) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | # indefinite length, grrr! | ||||||||||||||||||||||||||||
| 56 | 0 | $depth++; | |||||||||||||||||||||||||||
| 57 | 0 | $pos += $tb + 1; | |||||||||||||||||||||||||||
| 58 | 0 | redo MORE; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 1 | ($lb,$len) = asn_decode_length(substr($buf,$pos+$tb)); | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 1 | ▶ | if ($lb) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 1 | ▶ | if ($depth) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 0 | $pos += $tb + $lb + $len; | |||||||||||||||||||||||||||
| 66 | 0 | redo MORE; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | else { | ||||||||||||||||||||||||||||
| 69 | 1 | $len += $tb + $lb + $pos; | |||||||||||||||||||||||||||
| 70 | 1 | last MORE; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 1 | ▶ | if (defined $peer) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | 1 | ▶ | if ($len > length $buf) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 77 | # Check we can read the whole element | ||||||||||||||||||||||||||||
| 78 | goto error | ||||||||||||||||||||||||||||
| 79 | 0 | ▶ | unless defined($peer = recv($_[0],$buf,$len,MSG_PEEK)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if ($len > length $buf) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | # Cannot get whole element | ||||||||||||||||||||||||||||
| 83 | 0 | $_[1]=''; | |||||||||||||||||||||||||||
| 84 | 0 | return $peer; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | elsif ($len == 0) { | ||||||||||||||||||||||||||||
| 88 | 0 | $_[1] = ''; | |||||||||||||||||||||||||||
| 89 | 0 | return $peer; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 1 | ▶ | if ($_[2] & MSG_PEEK) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 93 | 0 | $_[1] = substr($buf,0,$len); | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | elsif (!defined($peer = recv($_[0],$_[1],$len,0))) { | ||||||||||||||||||||||||||||
| 96 | 0 | goto error; | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 1 | return $peer; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | error: | ||||||||||||||||||||||||||||
| 103 | 0 | $_[1] = undef; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 2 | ▶ | sub asn_read { # $fh, $buffer, $offset | ||||||||||||||||||||||||||
|
Subroutine
asn_read: called CC=24 SCAR=37.7
Pod
documented
| |||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | # We need to read one packet, and exactly only one packet. | ||||||||||||||||||||||||||||
| 109 | # So we have to read the first few bytes one at a time, until | ||||||||||||||||||||||||||||
| 110 | # we have enough to decode a tag and a length. We then know | ||||||||||||||||||||||||||||
| 111 | # how many more bytes to read | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 2 | ▶ | if ($_[2]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | 0 | ▶ | if ($_[2] > length $_[1]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 0 | require Carp; | |||||||||||||||||||||||||||
| 116 | 0 | Carp::carp("Offset beyond end of buffer"); | |||||||||||||||||||||||||||
| 117 | 0 | return; | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | 0 | substr($_[1],$_[2]) = ''; | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | else { | ||||||||||||||||||||||||||||
| 122 | 2 | $_[1] = ''; | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 2 | my $pos = 0; | |||||||||||||||||||||||||||
| 126 | 2 | my $need = 0; | |||||||||||||||||||||||||||
| 127 | 2 | my $depth = 0; | |||||||||||||||||||||||||||
| 128 | 2 | my $ch; | |||||||||||||||||||||||||||
| 129 | my $n; | ||||||||||||||||||||||||||||
| 130 | 2 | my $e; | |||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 2 | while(1) { | |||||||||||||||||||||||||||
| 134 | 266 | ▶ | $need = ($pos + ($depth * 2)) || 2; | ||||||||||||||||||||||||||
|
Condition100%2/2
$pos + $depth * 2 || 2
MC/DC100%1/1
$pos + $depth * 2 || 2
$pos + $depth * 2
Truth table100%2/2
A
A= $pos + $depth * 2
| |||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 266 | ▶ | while(($n = $need - length $_[1]) > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | 196 | ▶ | $e = sysread($_[0],$_[1],$n,length $_[1]) or | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | goto READ_ERR; | ||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 266 | my $tch = unpack("C",substr($_[1],$pos++,1)); | |||||||||||||||||||||||||||
| 142 | # Tag may be multi-byte | ||||||||||||||||||||||||||||
| 143 | 266 | ▶ | if(($tch & 0x1f) == 0x1f) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | 175 | my $ch; | |||||||||||||||||||||||||||
| 145 | 175 | ▶ | do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 273 | $need++; | |||||||||||||||||||||||||||
| 147 | 273 | ▶ | while(($n = $need - length $_[1]) > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | 273 | ▶ | $e = sysread($_[0],$_[1],$n,length $_[1]) or | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | goto READ_ERR; | ||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | 273 | $ch = unpack("C",substr($_[1],$pos++,1)); | |||||||||||||||||||||||||||
| 152 | } while($ch & 0x80); | ||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 266 | $need = $pos + 1; | |||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 266 | ▶ | while(($n = $need - length $_[1]) > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 158 | 0 | ▶ | $e = sysread($_[0],$_[1],$n,length $_[1]) or | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | goto READ_ERR; | ||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 266 | my $len = unpack("C",substr($_[1],$pos++,1)); | |||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 266 | ▶ | if($len & 0x80) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 165 | 71 | ▶ | unless ($len &= 0x7f) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | 71 | $depth++; | |||||||||||||||||||||||||||
| 167 | 71 | next; | |||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | 0 | $need = $pos + $len; | |||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 0 | ▶ | while(($n = $need - length $_[1]) > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 172 | 0 | ▶ | $e = sysread($_[0],$_[1],$n,length $_[1]) or | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 173 | goto READ_ERR; | ||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 0 | $pos += $len + unpack("N", "\0" x (4 - $len) . substr($_[1],$pos,$len)); | |||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | ▶ | elsif (!$len && !$tch) { | |||||||||||||||||||||||||||
|
Condition66%2/3
$len || $tch
MC/DC50%1/2
$len || $tch
$len
$tch
Truth table66%2/3
A || B
A= $lenB= $tch
| |||||||||||||||||||||||||||||
| 179 | 71 | ▶ | die "Bad ASN PDU" unless $depth; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | 71 | ▶ | unless (--$depth) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | 1 | last; | |||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | else { | ||||||||||||||||||||||||||||
| 185 | 124 | $pos += $len; | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 194 | ▶ | last unless $depth; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 2 | ▶ | while(($n = $pos - length $_[1]) > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 192 | 1 | ▶ | $e = sysread($_[0],$_[1],$n,length $_[1]) or | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | goto READ_ERR; | ||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 2 | return length $_[1]; | |||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 0 | ▶ | READ_ERR: | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 199 | $@ = defined($e) ? "Unexpected EOF" : "I/O Error $!"; # . CORE::unpack("H*",$_[1]); | ||||||||||||||||||||||||||||
| 200 | 0 | return undef; | |||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 1 | ▶ | sub asn_send { # $sock, $buffer, $flags, $to | ||||||||||||||||||||||||||
|
Subroutine
asn_send: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 1 | ▶ | @_ == 4 | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | ? send($_[0],$_[1],$_[2],$_[3]) | ||||||||||||||||||||||||||||
| 207 | : send($_[0],$_[1],$_[2]); | ||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 2 | ▶ | sub asn_write { # $sock, $buffer | ||||||||||||||||||||||||||
|
Subroutine
asn_write: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 2 | syswrite($_[0],$_[1], length $_[1]); | |||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 2 | ▶ | sub asn_get { # $fh | ||||||||||||||||||||||||||
|
Subroutine
asn_get: called CC=11 SCAR=24.2
Pod
documented
| |||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 2 | ▶ | my $fh = ref($_[0]) ? $_[0] : \($_[0]); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 218 | 2 | my $href = \%{*$fh}; | |||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 2 | ▶ | $href->{'asn_buffer'} = '' unless exists $href->{'asn_buffer'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 2 | ▶ | my $need = delete $href->{'asn_need'} || 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
delete $href->{'asn_need'} || 0
MC/DC100%1/1
delete $href->{'asn_need'} || 0
delete $href->{'asn_need'}
Truth table100%2/2
A
A= delete $href->{'asn_need'}
| |||||||||||||||||||||||||||||
| 223 | 2 | while(1) { | |||||||||||||||||||||||||||
| 224 | 3 | ▶ | next if $need; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 225 | 2 | ▶ | my($tb,$tag) = asn_decode_tag($href->{'asn_buffer'}) or next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | 1 | ▶ | my($lb,$len) = asn_decode_length(substr($href->{'asn_buffer'},$tb,8)) or next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | 1 | $need = $tb + $lb + $len; | |||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||
| 229 | continue { | ||||||||||||||||||||||||||||
| 230 | 3 | ▶ | if ($need && $need <= length $href->{'asn_buffer'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$need and $need <= length $href->{"asn_buffer"}
MC/DC50%1/2
$need and $need <= length $href->{"asn_buffer"}
$need
$need <= length $href->{"asn_buffer"}
Truth table66%2/3
A and B
A= $needB= $need <= length $href->{"asn_buffer"}
| |||||||||||||||||||||||||||||
| 231 | 2 | my $ret = substr($href->{'asn_buffer'},0,$need); | |||||||||||||||||||||||||||
| 232 | 2 | substr($href->{'asn_buffer'},0,$need) = ''; | |||||||||||||||||||||||||||
| 233 | 2 | return $ret; | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 1 | ▶ | my $get = $need > 1024 ? $need : 1024; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 1 | ▶ | sysread($_[0], $href->{'asn_buffer'}, $get, length $href->{'asn_buffer'}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 239 | or return undef; | ||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 2 | ▶ | sub asn_ready { # $fh | ||||||||||||||||||||||||||
|
Subroutine
asn_ready: called CC=6 SCAR=18.5
Pod
documented
| |||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 2 | ▶ | my $fh = ref($_[0]) ? $_[0] : \($_[0]); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 246 | 2 | my $href = \%{*$fh}; | |||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 2 | ▶ | return 0 unless exists $href->{'asn_buffer'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | return $href->{'asn_need'} <= length $href->{'asn_buffer'} | ||||||||||||||||||||||||||||
| 251 | 2 | ▶ | if exists $href->{'asn_need'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | 2 | ▶ | my($tb,$tag) = asn_decode_tag($href->{'asn_buffer'}) or return 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 254 | 1 | ▶ | my($lb,$len) = asn_decode_length(substr($href->{'asn_buffer'},$tb,8)) or return 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 1 | $href->{'asn_need'} = $tb + $lb + $len; | |||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 1 | $href->{'asn_need'} <= length $href->{'asn_buffer'}; | |||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | 24 | 1; | |||||||||||||||||||||||||||