| 1 | # Convert::BER.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # Copyright (c) 1995-1999 Graham Barr <gbarr@pobox.com>. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # This program is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | package Convert::BER; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 10 | ▶ | use vars qw($VERSION @ISA); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 10 | ▶ | use Exporter (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 10 | ▶ | use vars qw($VERSION @ISA @EXPORT_OK); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 10 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=18.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 10 | ▶ | if ($] >= 5.006) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 10 | require bytes; 'bytes'->import; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 10 | $VERSION = "1.32"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 10 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 10 | @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | BER_BOOLEAN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | BER_INTEGER | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | BER_BIT_STR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | BER_OCTET_STR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | BER_NULL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | BER_OBJECT_ID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | BER_REAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | BER_SEQUENCE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | BER_SET | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | BER_UNIVERSAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | BER_APPLICATION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | BER_CONTEXT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | BER_PRIVATE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | BER_PRIMITIVE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | BER_CONSTRUCTOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | BER_LONG_LEN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | BER_EXTENSION_ID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | BER_BIT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ber_tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # 5.003 does not have UNIVERSAL::can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 10 | ▶ | unless(defined &UNIVERSAL::can) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | *UNIVERSAL::can = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=34.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my($obj,$meth) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | my $pkg = ref($obj) || $obj; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $obj || $obj
MC/DC0%0/2
ref $obj || $obj
ref $obj
$obj
Truth table0%0/3
A || B
A= ref $objB= $obj
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | my @pkg = ($pkg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my %done; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | while(@pkg) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $pkg = shift @pkg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | next if exists $done{$pkg}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $done{$pkg} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 10 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | unshift @pkg,@{$pkg . "::ISA"} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | if(@{$pkg . "::ISA"}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | return \&{$pkg . "::" . $meth} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if defined(&{$pkg . "::" . $meth}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | ## Constants | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | sub BER_BOOLEAN () { 0x01 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | sub BER_INTEGER () { 0x02 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | sub BER_BIT_STR () { 0x03 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | sub BER_OCTET_STR () { 0x04 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | sub BER_NULL () { 0x05 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | sub BER_OBJECT_ID () { 0x06 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | sub BER_REAL () { 0x09 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | sub BER_ENUMERATED () { 0x0A } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | sub BER_SEQUENCE () { 0x10 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | sub BER_SET () { 0x11 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | sub BER_PRINT_STR () { 0x13 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | sub BER_IA5_STR () { 0x16 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | sub BER_UTC_TIME () { 0x17 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | sub BER_GENERAL_TIME () { 0x18 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | sub BER_UNIVERSAL () { 0x00 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | sub BER_APPLICATION () { 0x40 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | sub BER_CONTEXT () { 0x80 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | sub BER_PRIVATE () { 0xC0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | sub BER_PRIMITIVE () { 0x00 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | sub BER_CONSTRUCTOR () { 0x20 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | sub BER_LONG_LEN () { 0x80 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | sub BER_EXTENSION_ID () { 0x1F } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | sub BER_BIT () { 0x80 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # This module is used a lot so performance matters. For that reason it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # is implemented as an ARRAY instead of a HASH. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # inlined constants for array indices | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | sub _BUFFER () { 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | sub _POS () { 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | sub _INDEX () { 2 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | sub _ERROR () { 3 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | sub _PEER () { 4 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | sub _PACKAGE () { 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | sub _TAG () { 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | sub _PACK () { 2 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | sub _PACK_ARRAY () { 3 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | sub _UNPACK () { 4 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | sub _UNPACK_ARRAY () { 5 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 10 | Convert::BER->define( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | ## Syntax operator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | [ BER => undef, undef ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | [ ANY => undef, undef ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | [ CONSTRUCTED => undef, undef ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | [ OPTIONAL => undef, undef ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | [ CHOICE => undef, undef ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | ## Primitive operators | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | [ BOOLEAN => undef, BER_UNIVERSAL | BER_PRIMITIVE | BER_BOOLEAN ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | [ INTEGER => undef, BER_UNIVERSAL | BER_PRIMITIVE | BER_INTEGER ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | [ STRING => undef, BER_UNIVERSAL | BER_PRIMITIVE | BER_OCTET_STR ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | [ NULL => undef, BER_UNIVERSAL | BER_PRIMITIVE | BER_NULL ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | [ OBJECT_ID => undef, BER_UNIVERSAL | BER_PRIMITIVE | BER_OBJECT_ID ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | [ BIT_STRING => undef, BER_UNIVERSAL | BER_PRIMITIVE | BER_BIT_STR ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | [ BIT_STRING8 => undef, BER_UNIVERSAL | BER_PRIMITIVE | BER_BIT_STR ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | [ REAL => undef, BER_UNIVERSAL | BER_PRIMITIVE | BER_REAL ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | [ SEQUENCE => undef, BER_UNIVERSAL | BER_CONSTRUCTOR | BER_SEQUENCE ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | [ SEQUENCE_OF => undef, BER_UNIVERSAL | BER_CONSTRUCTOR | BER_SEQUENCE ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | ## These variables will be defined by the above ->define() call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 10 | ▶ | use vars qw($INTEGER $SEQUENCE $STRING $SEQUENCE_OF); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 10 | Convert::BER->define( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | ## Sub-classed primitive operators | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | [ ENUM => $INTEGER, BER_UNIVERSAL | BER_PRIMITIVE | BER_ENUMERATED ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | [ SET => $SEQUENCE, BER_UNIVERSAL | BER_CONSTRUCTOR | BER_SET ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | [ SET_OF => $SEQUENCE_OF, BER_UNIVERSAL | BER_CONSTRUCTOR | BER_SET ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | [ ObjectDescriptor => $STRING, BER_UNIVERSAL | 7], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | [ UTF8String => $STRING, BER_UNIVERSAL | 12], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | [ NumericString => $STRING, BER_UNIVERSAL | 18], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | [ PrintableString => $STRING, BER_UNIVERSAL | 19], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | [ TeletexString => $STRING, BER_UNIVERSAL | 20], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | [ T61String => $STRING, BER_UNIVERSAL | 20], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | [ VideotexString => $STRING, BER_UNIVERSAL | 21], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | [ IA5String => $STRING, BER_UNIVERSAL | 22], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | [ GraphicString => $STRING, BER_UNIVERSAL | 25], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | [ VisibleString => $STRING, BER_UNIVERSAL | 26], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | [ ISO646String => $STRING, BER_UNIVERSAL | 26], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | [ GeneralString => $STRING, BER_UNIVERSAL | 27], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | [ UTCTime => $STRING, BER_UNIVERSAL | 23], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | [ GeneralizedTime => $STRING, BER_UNIVERSAL | 24], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 10 | Convert::BER->define( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | [ '_Time_generic' => $STRING, undef ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | [ TimeUZ => '_Time_generic', BER_UNIVERSAL | 23], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | [ TimeUL => '_Time_generic', BER_UNIVERSAL | 23], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | [ TimeGZ => '_Time_generic', BER_UNIVERSAL | 24], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | [ TimeGL => '_Time_generic', BER_UNIVERSAL | 24], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | # only load Carp when needed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | sub croak { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
croak: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | goto &Carp::croak; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | ## define: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | ## does all the hard work of dynamically building the BER class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | ## and BER-type classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 32 | ▶ | sub define { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
define: called CC=11 SCAR=24.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 32 | my $pkg = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 10 | ▶ | no strict 'refs'; # we do some naughty stuff here :-) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 32 | ▶ | $pkg = ref($pkg) || $pkg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $pkg || $pkg
MC/DC0%0/2
ref $pkg || $pkg
ref $pkg
$pkg
Truth table33%1/3
A || B
A= ref $pkgB= $pkg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 32 | ▶ | while(@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 376 | my($name,$isa,$tag) = @{ $_[0] }; shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 376 | my $subpkg = $pkg . "::" . $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 376 | ▶ | croak("Bad tag name '$name'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | if($name =~ /\A(?:DESTROY|VERSION)\Z/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 376 | ▶ | if(defined $isa) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 226 | ▶ | my $isapkg = $pkg->can('_' . $isa) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | croak "Unknown BER tag type '$isa'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 226 | @{$subpkg . "::ISA"} = ( &{$isapkg}()->[ _PACKAGE ] ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 226 | ▶ | unless @{$subpkg . "::ISA"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 226 | ▶ | $tag = $subpkg->tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | unless defined $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 376 | ▶ | if(defined &{$subpkg . "::tag"}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | croak "tags for '$name' do not match " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | unless $subpkg->tag == $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 376 | ▶ | *{$subpkg . "::tag"} = sub { $tag }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 376 | push(@{$pkg . "::EXPORT_OK"}, '$' . $name, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 376 | *{$pkg . "::" . $name} = \$name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | my @data = ( $subpkg, $subpkg->tag, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 376 | map { $subpkg->can($_) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | qw(pack pack_array unpack unpack_array) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 376 | my $const = $tag; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | *{$pkg . "::" . $name} = sub () { $const } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 376 | ▶ | unless defined &{$pkg . "::" . $name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 376 | ▶ | *{$pkg . "::_" . $name} = sub { \@data }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # Now we have done the naughty stuff, make sure we do no more | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 44 | ▶ | sub ber_tag { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ber_tag: called CC=6 SCAR=18.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 44 | my($t,$e) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 44 | ▶ | $e ||= 0; # unsigned; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$e ||= 0
MC/DC100%1/1
$e ||= 0
$e
Truth table100%2/2
A
A= $e
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 44 | ▶ | if($e < 30) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 9 | return (($t & 0xe0) | $e); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 35 | $t = ($t | 0x1f) & 0xff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 35 | ▶ | if ($e & 0xffe00000) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | die "Too big"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 35 | my @t = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 35 | ▶ | push(@t, ($b >> 14) | 0x80) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | if ($b = ($e & 0x001fc000)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 35 | ▶ | push(@t, ($b >> 7) | 0x80) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | if ($b = ($e & 0xffffff80)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 35 | unpack("V",pack("C4",$t,@t,$e & 0x7f,0,0)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 155 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 155 | my $package = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 155 | ▶ | my $class = ref($package) || $package; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $package || $package
MC/DC0%0/2
ref $package || $package
ref $package
$package
Truth table66%2/3
A || B
A= ref $packageB= $package
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 155 | ▶ | my $self = bless [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | @_ == 1 ? shift : "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | ref($package) ? $package->[ Convert::BER::_INDEX() ] : [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | ], $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 155 | ▶ | @_ ? $self->encode(@_) : $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | ## Some basic subs for packing/unpacking data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | ## These methods would be called by the BER-type classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 51 | ▶ | sub num_length { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
num_length: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 51 | ▶ | return 1 if ( ($_[0] & 0xff) == $_[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 5 | ▶ | return 2 if ( ($_[0] & 0xffff) == $_[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 4 | ▶ | return 3 if ( ($_[0] & 0xffffff) == $_[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | return 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | sub pos { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pos: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | my $ber = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | @_ ? ($ber->[ Convert::BER::_POS() ] = shift) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | : $ber->[ Convert::BER::_POS() ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | sub pack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | my $ber = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | $ber->[ Convert::BER::_BUFFER() ] .= $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 165 | ▶ | sub unpack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 165 | my($ber,$len) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 165 | my $pos = $ber->[ Convert::BER::_POS() ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 165 | my $npos = $pos + $len; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 165 | ▶ | die "Buffer empty" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | if ($npos > CORE::length($ber->[ Convert::BER::_BUFFER() ])); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 165 | $ber->[ Convert::BER::_POS() ] = $npos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 165 | substr($ber->[ Convert::BER::_BUFFER() ],$pos,$len); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 178 | ▶ | sub pack_tag { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack_tag: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 178 | my($ber,$tag) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | # small tag number are more common, so check $tag size in reverse order | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 178 | ▶ | unless(($tag & 0x1f) == 0x1f) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 142 | $ber->[ Convert::BER::_BUFFER() ] .= chr( $tag ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 142 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 36 | ▶ | unless($tag & ~0x7fff) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 16 | $ber->[ Convert::BER::_BUFFER() ] .= CORE::pack("v",$tag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 16 | return 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 20 | ▶ | unless($tag & ~0x7fffff) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 20 | $ber->[ Convert::BER::_BUFFER() ] .= CORE::pack("vc",$tag, ($tag >> 16)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 20 | return 3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $ber->[ Convert::BER::_BUFFER() ] .= CORE::pack("V",$tag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | return 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 199 | ▶ | sub unpack_tag { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack_tag: called CC=7 SCAR=19.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 199 | my($ber,$expect) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 199 | my $pos = $ber->[ Convert::BER::_POS() ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 199 | my $len = CORE::length($ber->[ Convert::BER::_BUFFER() ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 199 | ▶ | die "Buffer empty" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | if($pos >= $len); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 199 | my $tag = CORE::unpack("C",substr($ber->[ Convert::BER::_BUFFER() ],$pos++,1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 199 | ▶ | if(($tag & 0x1f) == 0x1f) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 65 | my $b; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 65 | my $s = 8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 65 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 100 | ▶ | die "Buffer empty" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | if($pos >= $len); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 100 | $b = CORE::unpack("C",substr($ber->[ Convert::BER::_BUFFER() ],$pos++,1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 100 | $tag |= $b << $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 100 | $s += 8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } while($b & 0x80); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 199 | ▶ | die sprintf("Expecting tag 0x%x, found 0x%x",$expect,$tag) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $expect and $tag != $expect
MC/DC0%0/2
defined $expect and $tag != $expect
defined $expect
$tag != $expect
Truth table66%2/3
A and B
A= defined $expectB= $tag != $expect
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | if(defined($expect) && ($tag != $expect)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 199 | $ber->[ Convert::BER::_POS() ] = $pos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 199 | $tag | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 178 | ▶ | sub pack_length { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack_length: called CC=2 SCAR=8.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 178 | my($ber,$len) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 178 | ▶ | if($len & ~0x7f) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | my $lenlen = num_length($len); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | $ber->[ Convert::BER::_BUFFER() ] .= CORE::pack("C", $lenlen | 0x80) . substr(CORE::pack("N",$len), 0 - $lenlen); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | return $lenlen + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 178 | $ber->[ Convert::BER::_BUFFER() ] .= CORE::pack("C", $len); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 178 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 169 | ▶ | sub unpack_length { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack_length: called CC=5 SCAR=22.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 169 | my $ber = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 169 | my $pos = $ber->[ Convert::BER::_POS() ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 169 | ▶ | die "Buffer empty" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | if($pos >= CORE::length($ber->[ Convert::BER::_BUFFER() ])); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 169 | my $len = CORE::unpack("C", substr($ber->[ Convert::BER::_BUFFER() ],$pos++,1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 169 | ▶ | if($len & 0x80) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | my $buf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | $len &= 0x7f; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | die "Buffer empty" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | if(($pos+$len) > CORE::length($ber->[ Convert::BER::_BUFFER() ])); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | my $tmp = "\0" x (4 - $len) . substr($ber->[ Convert::BER::_BUFFER() ],$pos,$len); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | $pos += $len; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | $len = $len ? CORE::unpack("N",$tmp) : -1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 169 | $ber->[ Convert::BER::_POS() ] = $pos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 169 | $len; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | ## User interface (public) method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | sub error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | my $ber = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | $ber->[ Convert::BER::_ERROR() ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 30 | ▶ | sub tag { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tag: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 30 | my $ber = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 30 | my $pos = $ber->[ Convert::BER::_POS() ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 30 | ▶ | my $tag = eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 30 | local($SIG{'__DIE__'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 30 | unpack_tag($ber) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 30 | $ber->[ Convert::BER::_POS() ] = $pos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 30 | $tag; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | sub length { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
length: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | my $ber = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | CORE::length($ber->[ Convert::BER::_BUFFER() ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 75 | ▶ | sub buffer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
buffer: called CC=2 SCAR=8.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 75 | my $ber = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 75 | ▶ | if(@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | $ber->[ Convert::BER::_POS() ] = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | $ber->[ Convert::BER::_BUFFER() ] = "" . shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 75 | $ber->[ Convert::BER::_BUFFER() ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | ## just for debug :-) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | sub _hexdump { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hexdump: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | my($fmt,$pos) = @_[1,2]; # Don't copy buffer | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | $pos ||= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$pos ||= 0
MC/DC0%0/1
$pos ||= 0
$pos
Truth table0%0/2
A
A= $pos
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | my $offset = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | my $cnt = 1 << 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | my $len = CORE::length($_[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | my $linefmt = ("%02X " x $cnt) . "%s\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | while ($offset < $len) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | my $data = substr($_[0],$offset,$cnt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | my @y = CORE::unpack("C*",$data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | printf $fmt,$pos if $fmt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | # On the last time through replace '%02X ' with '__ ' for the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | # missing values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | substr($linefmt, 5*@y,5*($cnt-@y)) = "__ " x ($cnt - @y) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | if @y != $cnt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | # Change non-printable chars to '.' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | $data =~ s/[\x00-\x1f\x7f-\xff]/./sg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | printf $linefmt, @y,$data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | $offset += $cnt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | $pos += $cnt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 10 | my %type = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | split(/[\t\n]\s*/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | q(10 SEQUENCE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 01 BOOLEAN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0A ENUM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 11 SET | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 02 INTEGER | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 03 BIT STRING | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | C0 PRIVATE [%d] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 04 STRING | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 40 APPLICATION [%d] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 05 NULL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 06 OBJECT ID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 80 CONTEXT [%d] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | sub dump { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump: not called CC=24 SCAR=64.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | my $ber = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | my $fh = @_ ? shift : \*STDERR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | my $ofh = select($fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | my $pos = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | my $indent = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | my @seqend = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | my $length = CORE::length($ber->[ Convert::BER::_BUFFER() ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | my $fmt = $length > 0xffff ? "%08X" : "%04X"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | local $ber->[ Convert::BER::_POS() ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | $ber->[ Convert::BER::_POS() ] = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | while(1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | while (@seqend && $ber->[ Convert::BER::_POS() ] >= $seqend[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@seqend and $ber->[1] >= $seqend[0]
MC/DC0%0/2
@seqend and $ber->[1] >= $seqend[0]
@seqend
$ber->[1] >= $seqend[0]
Truth table0%0/3
A and B
A= @seqendB= $ber->[1] >= $seqend[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | $indent = substr($indent,2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | shift @seqend; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | printf "$fmt : %s}\n",$ber->[ Convert::BER::_POS() ],$indent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | ▶ | last unless $ber->[ Convert::BER::_POS() ] < $length; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | my $start = $ber->[ Convert::BER::_POS() ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | my $tag = unpack_tag($ber); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | my $pos = $ber->[ Convert::BER::_POS() ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | my $len = Convert::BER::unpack_length($ber); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | ▶ | if($tag == 0 && $len == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$tag == 0 and $len == 0
MC/DC0%0/2
$tag == 0 and $len == 0
$tag == 0
$len == 0
Truth table0%0/3
A and B
A= $tag == 0B= $len == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | $seqend[0] = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | redo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | printf $fmt. " %02X %4d: %s",$start,$tag,$len,$indent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | my $label = $type{sprintf("%02X",$tag & ~0x20)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | ▶ | || $type{sprintf("%02X",$tag & 0xC0)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$type{sprintf '%02X', $tag & 18446744073709551583} || $type{sprintf '%02X', $tag & 192} || 'UNIVERSAL [%d]'
$type{sprintf "%02X", $tag & '18446744073709551583'} or $type{sprintf "%02X", $tag & 192}
MC/DC0%0/2
$type{sprintf '%02X', $tag & 18446744073709551583} || $type{sprintf '%02X', $tag & 192} || 'UNIVERSAL [%d]'
$type{sprintf "%02X", $tag & '18446744073709551583'}
$type{sprintf "%02X", $tag & 192}
Truth table0%0/3
A or B
A= $type{sprintf "%02X", $tag & '18446744073709551583'}B= $type{sprintf "%02X", $tag & 192}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | || "UNIVERSAL [%d]"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | if (($tag & 0x1f) == 0x1f) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | my $k = $tag >> 8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | my $j = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | ▶ | while($k) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | $j = ($j << 7) | ($k & 0x7f); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | $k >>= 8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | my $l = $label; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | $l =~ s/%d/0x%x/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | printf $l, $j; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | printf $label, $tag & ~0xE0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | ▶ | if ($tag & BER_CONSTRUCTOR) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | print " {\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | ▶ | if($len < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | unshift(@seqend, ~(1<<31)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | unshift(@seqend, $ber->[ Convert::BER::_POS() ] + $len); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | $indent .= " "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | $ber->[ Convert::BER::_POS() ] = $pos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | my $tmp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | for ($label) { # switch | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | ▶ | /^INTEGER/ && do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | Convert::BER::INTEGER->unpack($ber,\$tmp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | printf " = %d\n",$tmp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | /^ENUM/ && do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | Convert::BER::ENUM->unpack($ber,\$tmp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | printf " = %d\n",$tmp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | ▶ | /^BOOLEAN/ && do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | Convert::BER::BOOLEAN->unpack($ber,\$tmp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | ▶ | printf " = %s\n",$tmp ? 'TRUE' : 'FALSE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | ▶ | /^OBJECT ID/ && do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | Convert::BER::OBJECT_ID->unpack($ber,\$tmp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | printf " = %s\n",$tmp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | ▶ | /^NULL/ && do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | $ber->[ Convert::BER::_POS() ] = $pos+1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | ▶ | /^STRING/ && do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | Convert::BER::STRING->unpack($ber,\$tmp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | if ($tmp =~ /[\x00-\x1f\x7f-\xff]/s) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | _hexdump($tmp,$fmt . " : ".$indent, $pos); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | printf " = '%s'\n",$tmp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | ▶ | /^BIT STRING/ && do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | Convert::BER::BIT_STRING->unpack($ber,\$tmp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | print " = ",$tmp,"\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | # default -- dump hex data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | Convert::BER::STRING->unpack($ber,\$tmp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | _hexdump($tmp,$fmt . " : ".$indent, $pos); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | select($ofh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | sub hexdump { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hexdump: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | my $ber = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | my $fh = @_ ? shift : \*STDERR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | my $ofh = select($fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | _hexdump($ber->[ Convert::BER::_BUFFER() ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | select($ofh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | ## And now the real guts of it, the encoding and decoding routines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 70 | ▶ | sub encode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encode: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 70 | my $ber = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 70 | local($SIG{'__DIE__'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 70 | $ber->[ Convert::BER::_INDEX() ] = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | return $ber | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 70 | ▶ | if eval { Convert::BER::_encode($ber,\@_) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | $ber->[ Convert::BER::_ERROR() ] = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 124 | ▶ | sub _encode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_encode: called CC=12 SCAR=24.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 124 | my $ber = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 124 | my $desc = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 124 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 124 | ▶ | while($i < @$desc ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 171 | my $type = $desc->[$i++]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 171 | my $arg = $desc->[$i++]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 171 | my $tag = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 171 | ▶ | ($type,$tag) = @$type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | if(ref($type) eq 'ARRAY'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 171 | my $can = $ber->can('_' . $type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 171 | ▶ | die "Unknown element '$type'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | unless $can; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 171 | my $data = &$can(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 171 | my $pkg = $data->[ Convert::BER::_PACKAGE() ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 171 | ▶ | $tag = $data->[ Convert::BER::_TAG() ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | unless defined $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 171 | ▶ | $arg = &{$arg}(@{$ber->[ Convert::BER::_INDEX() ]}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | if(ref($arg) eq 'CODE'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 171 | ▶ | if(ref($arg) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 49 | ▶ | if($can = $data->[Convert::BER::_PACK_ARRAY() ]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 43 | ▶ | pack_tag($ber,$tag) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | if defined $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 43 | &{$can}($pkg,$ber,$arg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 6 | my $a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 6 | foreach $a (@$arg) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 15 | ▶ | pack_tag($ber,$tag) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | if defined $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 15 | &{$data->[Convert::BER::_PACK() ]}($pkg,$ber,$a); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 122 | ▶ | pack_tag($ber,$tag) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | if defined $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 122 | &{$data->[Convert::BER::_PACK() ]}($pkg,$ber,$arg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 124 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 71 | ▶ | sub decode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode: called CC=2 SCAR=7.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 71 | my $ber = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 71 | my $pos = $ber->[ Convert::BER::_POS() ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 71 | local($SIG{'__DIE__'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 71 | $ber->[ Convert::BER::_INDEX() ] = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | return $ber | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 71 | ▶ | if eval { Convert::BER::_decode($ber,\@_) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | $ber->[ Convert::BER::_ERROR() ] = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | $ber->[ Convert::BER::_POS() ] = $pos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 118 | ▶ | sub _decode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode: called CC=14 SCAR=26.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 118 | my $ber = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 118 | my $desc = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 118 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 118 | my $argc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | TAG: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 118 | ▶ | for($argc = @$desc ; $argc > 0 ; $argc -= 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 160 | my $type = $desc->[$i++]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 160 | my $arg = $desc->[$i++]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 160 | my $tag = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 160 | ▶ | ($type,$tag) = @$type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | if(ref($type) eq 'ARRAY'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 160 | my $can = $ber->can('_' . $type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 160 | ▶ | die "Unknown element '$type'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | unless $can; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 160 | my $data = &$can(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 160 | my $pkg = $data->[ Convert::BER::_PACKAGE() ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 160 | ▶ | $tag = $data->[ Convert::BER::_TAG() ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | unless defined $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 160 | ▶ | $arg = &{$arg}(@{$ber->[ Convert::BER::_INDEX() ]}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | if(ref($arg) eq 'CODE'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 160 | ▶ | if(ref($arg) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 42 | ▶ | if($data->[ Convert::BER::_UNPACK_ARRAY() ]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 36 | ▶ | unpack_tag($ber,$tag) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | if(defined $tag); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 36 | &{$data->[ Convert::BER::_UNPACK_ARRAY() ]}($pkg,$ber,$arg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 6 | @$arg = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 6 | ▶ | while(CORE::length($ber->[ Convert::BER::_BUFFER() ]) > $ber->[ Convert::BER::_POS() ]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 14 | ▶ | if(defined $tag) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | next TAG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 14 | ▶ | unless eval { unpack_tag($ber,$tag) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 14 | push @$arg, undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 14 | &{$data->[ Convert::BER::_UNPACK() ]}($pkg,$ber,\$arg->[-1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 118 | ▶ | eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 118 | ▶ | unpack_tag($ber,$tag) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | if(defined $tag); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 118 | &{$data->[ Convert::BER::_UNPACK() ]}($pkg,$ber,$arg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 118 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | } or ($$arg = undef, die); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 118 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | ## a couple of routines to interface to a file descriptor. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 1 | ▶ | sub read { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read: called CC=16 SCAR=41.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 1 | my $ber = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 1 | my $io = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 1 | my $indef = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | # We need to read one packet, and exactly only one packet. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | # So we have to read the first few bytes one at a time, until | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | # we have enough to decode a tage and a length. We then know | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | # how many more bytes to read | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 1 | ▶ | $ber = $ber->new unless ref($ber); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 1 | ▶ | $ber->[ _BUFFER() ] = "" unless $indef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 1 | my $pos = CORE::length($ber->[ _BUFFER() ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 1 | my $start = $pos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | # The first byte is the tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 1 | ▶ | sysread($io,$ber->[ _BUFFER() ],1,$pos++) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | goto READ_ERR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | # print STDERR "-"x80,"\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | # print STDERR CORE::unpack("H*",$ber->[ _BUFFER() ]),"\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 1 | my $ch = ord(substr($ber->[ _BUFFER() ],-1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | # Tag may be multi-byte | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 1 | ▶ | if(($ch & 0x1f) == 0x1f) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | ▶ | sysread($io, $ber->[ _BUFFER() ], 1, $pos++) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | goto READ_ERR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | $ch = ord(substr($ber->[ _BUFFER() ],-1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | } while($ch & 0x80); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | # print STDERR CORE::unpack("H*",$ber->[ _BUFFER() ]),"\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | # The next byte will be the first byte of the length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 1 | ▶ | sysread($io, $ber->[ _BUFFER() ], 1, $pos++) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | goto READ_ERR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | # print STDERR CORE::unpack("H*",$ber->[ _BUFFER() ]),"\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 1 | $ch = ord(substr($ber->[ _BUFFER() ],-1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | # print STDERR CORE::unpack("H*",substr($ber->[ _BUFFER() ],-1))," $ch\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | # May be a multi-byte length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 1 | ▶ | if($ch & 0x80) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | my $len = $ch & 0x7f; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | ▶ | unless ($len) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | # print STDERR CORE::unpack("H*",$ber->[ _BUFFER() ]),"\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | # OK we have an indefinate length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | while(1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | Convert::BER::read($ber,$io,1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | my $p = CORE::length($ber->[ _BUFFER() ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | ▶ | if(($p - $pos) == 2 && substr($ber->[ _BUFFER() ],-2) eq "\0\0") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$p - $pos == 2 and substr($ber->[0], -2) eq "\0\0"
MC/DC0%0/2
$p - $pos == 2 and substr($ber->[0], -2) eq "\0\0"
$p - $pos == 2
substr($ber->[0], -2) eq "\0\0"
Truth table0%0/3
A and B
A= $p - $pos == 2B= substr($ber->[0], -2) eq "\0\0"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | # print STDERR CORE::unpack("H*",$ber->[ _BUFFER() ]),"\n","-"x80,"\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | return $ber; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 0 | $pos = $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | ▶ | while($len) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | ▶ | my $n = sysread($io, $ber->[ _BUFFER() ], $len, $pos) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | goto READ_ERR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | $len -= $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | $pos += $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | # print STDERR CORE::unpack("H*",$ber->[ _BUFFER() ]),"\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | # We can now unpack a tage and a length to determine how many more | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | # bytes to read | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 1 | $ber->[ _POS() ] = $start; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 1 | unpack_tag($ber); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 1 | my $len = unpack_length($ber); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 1 | ▶ | while($len > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 1 | my $got; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | goto READ_ERR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 1 | ▶ | unless( $got = sysread($io, $ber->[ _BUFFER() ],$len,CORE::length($ber->[ _BUFFER() ])) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 1 | $len -= $got; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | # Reset pos back to the beginning. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 1 | $ber->[ _POS() ] = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | # print STDERR CORE::unpack("H*",$ber->[ _BUFFER() ]),"\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 1 | return $ber; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | READ_ERR: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | $@ = "I/O Error $! " . CORE::unpack("H*",$ber->[ _BUFFER() ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 1 | ▶ | sub write { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 1 | my $ber = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 1 | my $io = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 1 | local($SIG{'__DIE__'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 1 | my $togo = CORE::length($ber->[ _BUFFER() ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 1 | my $pos = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 1 | ▶ | while($togo) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 1 | my $len; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 1 | ▶ | unless ($len = syswrite($io, $ber->[ _BUFFER() ],$togo,$pos)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | $@ = "I/O Error $!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 1 | $togo -= $len; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 1 | $pos += $len; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 1 | ▶ | sub send { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 1 | my $ber = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 1 | my $sock = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 1 | local($SIG{'__DIE__'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 1 | ▶ | eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | # Enable reporting a 'Broken pipe' error rather than dying. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 1 | local ($SIG{PIPE}) = "IGNORE"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 1 | ▶ | @_ ? send($sock,$ber->[ _BUFFER() ],0,$_[0]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | : send($sock,$ber->[ _BUFFER() ],0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | } or die "I/O Error: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 1 | ▶ | sub recv { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
recv: called CC=11 SCAR=27.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 1 | my $ber = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 1 | my $sock = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 1 | require Socket; # for Socket::MSG_PEEK | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 1 | local $SIG{'__DIE__'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 1 | ▶ | $ber = $ber->new unless ref($ber); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 1 | $ber->[ _BUFFER() ] = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | # We do not know the size of the datagram, so we have to PEEK --GMB | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | # is there an easier way to determine the packet size ?? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 1 | my $n = 128; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 1 | ▶ | die "I/O Error: $!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined CORE::recv($sock, $ber->[0], $n, Socket::MSG_PEEK()) and not $!
MC/DC0%0/2
defined CORE::recv($sock, $ber->[0], $n, Socket::MSG_PEEK()) and not $!
defined CORE::recv($sock, $ber->[0], $n, Socket::MSG_PEEK())
not $!
Truth table33%1/3
A and not(B)
A= defined CORE::recv($sock, $ber->[0], $n, Socket::MSG_PEEK())B= not $!
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | unless ((defined recv($sock,$ber->[ _BUFFER() ],$n,Socket::MSG_PEEK())) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | and not $!); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | # PEEK until we have the complete tag and length of the BER | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | # packet. Use the length to determine how much data to read from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | # the socket. This is an attempt to ensure that we read the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | # entire packet and that we don't read into the next packet, if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | # there is one. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 1 | my $len; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | # Keep reading until we've read enough of the packet to unpack | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | # the BER length field. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 1 | for(;;) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | # If we can decode a tag and length we can detemine the length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 1 | ▶ | if(defined($len = eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined($len = eval {
do {
$ber->[1] = 0;
unpack_tag($ber);
unpack_length($ber) + $ber->[1]
}
}) and $len >= $ber->[1]
MC/DC0%0/2
defined($len = eval {
do {
$ber->[1] = 0;
unpack_tag($ber);
unpack_length($ber) + $ber->[1]
}
}) and $len >= $ber->[1]
defined($len = eval {
do {
$ber->[1] = 0;
unpack_tag($ber);
unpack_length($ber) + $ber->[1]
}
})
$len >= $ber->[1]
Truth table33%1/3
A and B
A= defined($len = eval {
do {
$ber->[1] = 0;
unpack_tag($ber);
unpack_length($ber) + $ber->[1]
}
})B= $len >= $ber->[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 1 | $ber->[ _POS() ] = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 1 | unpack_tag($ber); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 1 | unpack_length($ber) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | + $ber->[ _POS() ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | # unpack_length will return -1 for unknown length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | && $len >= $ber->[ _POS() ]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 1 | $n = $len; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | # peek some more | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | $n <<= 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 0 | ▶ | die "I/O Error: $!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined CORE::recv($sock, $ber->[0], $n, Socket::MSG_PEEK()) and not $!
MC/DC0%0/2
defined CORE::recv($sock, $ber->[0], $n, Socket::MSG_PEEK()) and not $!
defined CORE::recv($sock, $ber->[0], $n, Socket::MSG_PEEK())
not $!
Truth table0%0/3
A and not(B)
A= defined CORE::recv($sock, $ber->[0], $n, Socket::MSG_PEEK())B= not $!
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | unless ((defined recv($sock,$ber->[ _BUFFER() ],$n,Socket::MSG_PEEK())) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | and not $!); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | # now we know the size, get it again but without MSG_PEEK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | # this will cause the kernel to remove the datagram from it's queue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | # If the data on the socket doesn't correspond to a valid BER | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | # object, the loop above could have read something it thought was | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | # the length and this loop could then block waiting for that many | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | # bytes, which will never arrive. What do you do about something | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | # like that? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 1 | $ber->[ _POS() ] = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 1 | $ber->[ _BUFFER() ] = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 1 | my ($read, $tmp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 1 | $read = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 1 | ▶ | while ($read < $n) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 1 | $ber->[ _PEER() ] = recv($sock, $tmp, $n - $read, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 1 | ▶ | die "I/O Error: $!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $ber->[4] and not $!
MC/DC0%0/2
defined $ber->[4] and not $!
defined $ber->[4]
not $!
Truth table33%1/3
A and not(B)
A= defined $ber->[4]B= not $!
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | unless ((defined ( $ber->[ _PEER() ] ) and not $!)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 1 | $read += CORE::length($tmp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 1 | $ber->[ _BUFFER() ] .= $tmp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 1 | $ber; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | ## The primitive packages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | package Convert::BER::BER; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 0 | ▶ | sub pack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 0 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 0 | ▶ | $ber->[ Convert::BER::_BUFFER() ] .= $arg->[ Convert::BER::_BUFFER() ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | if ref($arg); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | ▶ | sub unpack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 0 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 0 | my $len = CORE::length($ber->[ Convert::BER::_BUFFER() ]) - $ber->[ Convert::BER::_POS() ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 0 | $$arg = $ber->new(Convert::BER::unpack($ber,$len)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | package Convert::BER::ANY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 0 | ▶ | sub pack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 0 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 0 | $ber->[ Convert::BER::_BUFFER() ] .= $arg->[ Convert::BER::_BUFFER() ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 0 | ▶ | sub unpack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 0 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 0 | my $pos = $ber->[ Convert::BER::_POS() ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 0 | my $tag = Convert::BER::unpack_tag($ber); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 0 | my $len = Convert::BER::unpack_length($ber) + $ber->[ Convert::BER::_POS() ] - $pos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 0 | $ber->[ Convert::BER::_POS() ] = $pos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 0 | $$arg = $ber->new(Convert::BER::unpack($ber,$len)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | package Convert::BER::BOOLEAN; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 21 | ▶ | sub pack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 21 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 21 | Convert::BER::pack_length($ber,1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 21 | ▶ | $ber->[ Convert::BER::_BUFFER() ] .= CORE::pack("c", $arg ? 0xff : 0x00); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 21 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 21 | ▶ | sub unpack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 21 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 21 | my $len = Convert::BER::unpack_length($ber); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 21 | ▶ | $$arg = CORE::unpack("c", Convert::BER::unpack($ber,$len)) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 21 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | package Convert::BER::INTEGER; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | ## Math::BigInt support | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 0 | ▶ | sub pack_bigint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack_bigint: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 0 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 0 | require Math::BigInt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 0 | ▶ | my $neg = ($arg < 0) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 0 | my @octet = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 0 | my $num = new Math::BigInt(abs($arg)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 0 | ▶ | $num -= 1 if $neg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 0 | ▶ | while($num > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | 0 | my($i,$y) = $num->bdiv(256); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 0 | $num = new Math::BigInt($i); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 0 | ▶ | $y = $y ^ 0xff if $neg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 0 | unshift(@octet,$y); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 0 | ▶ | @octet = (0) unless @octet; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | 0 | ▶ | my $msb = ($octet[0] & 0x80) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 0 | ▶ | unshift(@octet,$neg ? 0xff : 0x00) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | if($neg != $msb); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | 0 | Convert::BER::pack_length($ber, scalar @octet); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | 0 | $ber->[ Convert::BER::_BUFFER() ] .= CORE::pack("C*",@octet); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 0 | ▶ | sub unpack_bigint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack_bigint: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 0 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 0 | require Math::BigInt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 0 | my $len = Convert::BER::unpack_length($ber); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 0 | my @octet = CORE::unpack("C*",Convert::BER::unpack($ber,$len)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 0 | ▶ | my $neg = ($octet[0] & 0x80) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 0 | my $val = $$arg = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 0 | ▶ | while(@octet) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 0 | my $oct = shift @octet; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 0 | ▶ | $oct = $oct ^ 0xff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | if $neg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | 0 | $val *= (1<<8); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 0 | $val += $oct; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 0 | ▶ | $val = -1 - $val | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | if $neg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | ## Math::BigInteger support | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 0 | ▶ | sub pack_biginteger { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack_biginteger: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | 0 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 0 | my($len,$data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 0 | my $offset = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 0 | require Math::BigInteger; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | # save has no concept of +/- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 0 | my $v = $arg->cmp(new Math::BigInteger(0)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 0 | ▶ | if($v) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 0 | ▶ | if($v < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | 0 | my $b = $arg->bits + 8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | 0 | $b -= $b % 8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 0 | my $tmp = new Math::BigInteger(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | 0 | $tmp->lshift(new Math::BigInteger(1), $b); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | 0 | $arg = $tmp + $arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 0 | $data = $arg->save; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | 0 | $len = CORE::length($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | 0 | my $c = ord(substr($data,0,1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | 0 | ▶ | if($c == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 0 | ▶ | for( ; $len > 1 ; $len--, $offset++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 0 | my $ch = ord(substr($data,$offset,1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | 0 | ▶ | if($ch & 0xff) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | 0 | ▶ | if($ch & 0x80) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | 0 | $len++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 0 | $offset--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | elsif($c == 0xff) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 0 | ▶ | for( ; $len > 1 ; $len--, $offset++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 0 | my $ch = ord(substr($data,$offset,1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 0 | ▶ | unless($ch == 0xff) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | 0 | ▶ | unless($ch & 0x80) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 0 | $len++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | 0 | $offset--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 0 | $len = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 0 | $data = CORE::pack("C",0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | 0 | Convert::BER::pack_length($ber,$len); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | 0 | $ber->[ Convert::BER::_BUFFER() ] .= substr($data,$offset); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | 0 | ▶ | sub unpack_biginteger { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack_biginteger: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | 0 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | 0 | require Math::BigInteger; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | 0 | my $len = Convert::BER::unpack_length($ber); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | 0 | my $data = Convert::BER::unpack($ber,$len); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | 0 | my $int = restore Math::BigInteger $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | # restore has no concept of +/- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | 0 | ▶ | if(ord(substr($data,0,1)) & 0x80) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | 0 | my $tmp = new Math::BigInteger; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | 0 | $tmp->lshift(new Math::BigInteger(1), $len * 8); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | 0 | $tmp = new Math::BigInteger(0) - $tmp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 0 | $int = $tmp + $int; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | 0 | $$arg = $int; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | 51 | ▶ | sub pack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack: called CC=10 SCAR=25.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 51 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | 51 | ▶ | if(ref $arg) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | 0 | ▶ | goto &pack_bigint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | if UNIVERSAL::isa($arg,'Math::BigInt'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | 0 | ▶ | goto &pack_biginteger | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | if UNIVERSAL::isa($arg,'Math::BigInteger'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | 51 | ▶ | my $neg = ($arg < 0) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | 51 | ▶ | my $len = Convert::BER::num_length($neg ? ~ $arg : $arg); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | 51 | my $msb = $arg & (0x80 << (($len - 1) * 8)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | 51 | ▶ | $len++ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
$msb and not $neg or $neg and not $msb
$msb and not $neg
$neg and not $msb
MC/DC50%2/4
$msb and not $neg or $neg and not $msb
$msb
not $neg
$neg
not $msb
Truth table42%3/7
A and not(B) or C and not(D)
A= $msbB= not $negC= $negD= not $msb
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | if(($msb && not($neg)) || ($neg && not($msb))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | 51 | Convert::BER::pack_length($ber,$len); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | 51 | $ber->[ Convert::BER::_BUFFER() ] .= substr(CORE::pack("N",$arg), 0 - $len); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | 51 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 48 | ▶ | sub unpack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack: called CC=6 SCAR=21.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | 48 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | 48 | ▶ | if( ref($arg) && ref($$arg) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $arg and ref $$arg
MC/DC0%0/2
ref $arg and ref $$arg
ref $arg
ref $$arg
Truth table33%1/3
A and B
A= ref $argB= ref $$arg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | 0 | ▶ | goto &unpack_bigint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | if UNIVERSAL::isa($$arg,'Math::BigInt'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | 0 | ▶ | goto &unpack_biginteger | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | if UNIVERSAL::isa($$arg,'Math::BigInteger'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | 48 | my $len = Convert::BER::unpack_length($ber); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | 48 | my $tmp = "\0" x (4 - $len) . Convert::BER::unpack($ber,$len); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | 48 | my $val = CORE::unpack("N",$tmp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | 48 | ▶ | $val -= 0x1 << ($len * 8) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | if($val & (0x1 << (($len * 8) - 1))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | 48 | $$arg = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | 48 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | package Convert::BER::NULL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | 2 | ▶ | sub pack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | 2 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 2 | Convert::BER::pack_length($ber,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | 2 | ▶ | sub unpack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | 2 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | 2 | Convert::BER::unpack_length($ber); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | 2 | $$arg = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | package Convert::BER::STRING; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | 58 | ▶ | sub pack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | 58 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 58 | Convert::BER::pack_length($ber,CORE::length($arg)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | 58 | $ber->[ Convert::BER::_BUFFER() ] .= $arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | 53 | ▶ | sub unpack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | 53 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | 53 | my $len = Convert::BER::unpack_length($ber); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | 53 | $$arg = Convert::BER::unpack($ber,$len); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | 53 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | package Convert::BER::SEQUENCE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | 0 | ▶ | sub pack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | 0 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | 0 | Convert::BER::pack_length($ber,CORE::length($arg->[ Convert::BER::_BUFFER() ])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | 0 | $ber->[ Convert::BER::_BUFFER() ] .= $arg->[ Convert::BER::_BUFFER() ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | 33 | ▶ | sub unpack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | 33 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | 33 | my $len = Convert::BER::unpack_length($ber); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | 33 | $$arg = $ber->new(Convert::BER::unpack($ber,$len)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | 33 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | 33 | ▶ | sub pack_array { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack_array: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | 33 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | 33 | my $ber2 = $ber->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | return undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | 33 | ▶ | unless defined($ber2->_encode($arg)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | 33 | Convert::BER::pack_length($ber,CORE::length($ber2->[ Convert::BER::_BUFFER() ])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | 33 | $ber->[ Convert::BER::_BUFFER() ] .= $ber2->[ Convert::BER::_BUFFER() ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | 33 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | 30 | ▶ | sub unpack_array { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack_array: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | 30 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | 30 | my $ber2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | 30 | $self->unpack($ber,\$ber2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | 30 | $ber2->_decode($arg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | 30 | ▶ | die "Sequence buffer not empty" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | if CORE::length($ber2->[ Convert::BER::_BUFFER() ]) != $ber2->[ Convert::BER::_POS() ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | 30 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | package Convert::BER::OBJECT_ID; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | 2 | ▶ | sub pack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | 2 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | 2 | my @data = ($arg =~ /(\d+)/g); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | 2 | ▶ | if(@data < 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | 0 | @data = (0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | 2 | my $first = $data[1] + ($data[0] * 40); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | 2 | splice(@data,0,2,$first); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | @data = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | 2 | my @d = ($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | 6 | ▶ | if($_ >= 0x80) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | 1 | @d = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | 1 | my $v = 0 | $_; # unsigned | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | 1 | ▶ | while($v) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | 2 | unshift(@d, 0x80 | ($v & 0x7f)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | 2 | $v >>= 7; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | 1 | $d[-1] &= 0x7f; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | 6 | @d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | } @data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | 2 | my $data = CORE::pack("C*", @data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | 2 | Convert::BER::pack_length($ber,CORE::length($data)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | 2 | $ber->[ Convert::BER::_BUFFER() ] .= $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | 2 | ▶ | sub unpack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | 2 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | 2 | my $len = Convert::BER::unpack_length($ber); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | 2 | my @ch = CORE::unpack("C*",Convert::BER::unpack($ber,$len)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | 2 | my @data = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | 2 | my $val = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | 2 | ▶ | while(@ch) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | 7 | my $ch = shift @ch; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | 7 | $val = ($val << 7) | ($ch & 0x7f); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | 7 | ▶ | unless($ch & 0x80) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | 6 | push @data, $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | 6 | $val = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | 2 | ▶ | if(@data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | 2 | my $first = shift @data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | 2 | unshift @data, $first % 40; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | 2 | unshift @data, int($first / 40); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | # unshift @data, ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | 2 | $$arg = join(".",@data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | package Convert::BER::CONSTRUCTED; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | 10 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | # Cannot call import here as Convert::BER has not been initialized | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | 10 | *BER_CONSTRUCTOR = *Convert::BER::BER_CONSTRUCTOR | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | 0 | ▶ | sub pack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | 0 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | 0 | Convert::BER::pack_tag($ber,$arg->tag | BER_CONSTRUCTOR); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | 0 | Convert::BER::pack_length($ber,CORE::length($arg->[ Convert::BER::_BUFFER() ])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | 0 | $ber->[ Convert::BER::_BUFFER() ] .= $arg->[ Convert::BER::_BUFFER() ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | 0 | ▶ | sub unpack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | 0 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | 0 | my $tag = Convert::BER::unpack_tag($ber); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | 0 | ▶ | die "Not constructed" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | unless $tag & BER_CONSTRUCTOR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | 0 | my $len = Convert::BER::unpack_length($ber); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | 0 | my $buf = $ber->new( Convert::BER::unpack($ber,$len)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | 0 | ▶ | die &{$ber}(0,"Bad construction") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | unless( ($buf->tag | BER_CONSTRUCTOR) == $tag); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | 0 | $$arg = $buf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | 0 | ▶ | sub pack_array { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack_array: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | 0 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | 0 | $self->_encode($arg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | 0 | ▶ | sub unpack_array { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack_array: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | 0 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | 0 | my $ber2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | 0 | $self->unpack($ber,\$ber2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | 0 | $ber2->_decode($arg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | package Convert::BER::OPTIONAL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | # optional elements | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | # allows skipping in the encode if it comes across structures like | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | # OPTIONAL => [ BOOLEAN => undef ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | # or more realistically | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | # my $foo = undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | # $foo = 1 if (arg->{'allowed'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | # $ber->encode(SEQUENCE => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | # STRING => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | # OPTIONAL => [ BOOLEAN => $foo ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | # ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | 2 | ▶ | sub pack_array { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack_array: called CC=6 SCAR=19.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | 2 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | 2 | my $a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | my @newarg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | 2 | foreach $a (@$arg) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | 4 | ▶ | return unless defined $a; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | my $c = ref($a) eq "CODE" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | 0 | ▶ | ? &{$a}(@{$ber->[ Convert::BER::_INDEX() ]}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | : $a; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | 3 | ▶ | return unless defined $c; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | 3 | push @newarg, $c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | 1 | ▶ | shift @newarg if (@newarg & 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | 1 | Convert::BER::_encode($ber,\@newarg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | 1 | ▶ | sub unpack_array { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack_array: called CC=5 SCAR=19.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | 1 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | 1 | my($yes,$ref); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | 1 | my $pos = $ber->[ Convert::BER::_POS() ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | 1 | ▶ | if(@$arg & 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | 0 | $ref = [ @$arg ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | 0 | $yes = shift @$ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | 1 | $ref = $arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | 1 | ▶ | if (eval { Convert::BER::_decode($ber,$ref) }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | 1 | ▶ | $$yes = 1 if ref($yes); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | 0 | ▶ | $$yes = undef if ref($yes); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | 0 | $ber->[ Convert::BER::_POS() ] = $pos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | package Convert::BER::SEQUENCE_OF; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | 8 | ▶ | sub pack_array { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack_array: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | 8 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | 8 | my($n,@desc) = @$arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | 8 | my $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | 8 | ▶ | $n = &{$n}(@{$ber->[ Convert::BER::_INDEX() ]}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | if ref($n) eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | 8 | push(@{$ber->[ Convert::BER::_INDEX() ]},0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | 8 | my $b = $ber->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | 8 | ▶ | if(ref($n) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | 3 | my $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | 3 | foreach $v (keys %$n) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | 4 | $ber->[ Convert::BER::_INDEX() ][-1] = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | 4 | $b->_encode(\@desc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | elsif(ref($n) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | 2 | my $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | 2 | foreach $v (@$n) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | 4 | $ber->[ Convert::BER::_INDEX() ][-1] = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | 4 | $b->_encode(\@desc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | 3 | ▶ | while($n--) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | 12 | $b->_encode(\@desc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | 12 | $ber->[ Convert::BER::_INDEX() ][-1] += 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | 8 | pop @{$ber->[ Convert::BER::_INDEX() ]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | 8 | Convert::BER::pack_length($ber,CORE::length($b->[ Convert::BER::_BUFFER() ])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | 8 | $ber->[ Convert::BER::_BUFFER() ] .= $b->[ Convert::BER::_BUFFER() ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | 5 | ▶ | sub unpack_array { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack_array: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | 5 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | 5 | my($nref,@desc) = @$arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | 5 | push(@{$ber->[ Convert::BER::_INDEX() ]},0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | 5 | my $len = Convert::BER::unpack_length($ber); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | 5 | my $b = $ber->new(Convert::BER::unpack($ber,$len)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | 5 | my $pos = $ber->[ Convert::BER::_POS() ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | 5 | my $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | 5 | ▶ | while(CORE::length($b->[ Convert::BER::_BUFFER() ]) > $b->[ Convert::BER::_POS() ]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | 16 | $b->_decode(\@desc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | 16 | $ber->[ Convert::BER::_INDEX() ][-1] += 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | 5 | $$nref = pop @{$ber->[ Convert::BER::_INDEX() ]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | package Convert::BER::BIT_STRING; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | 3 | ▶ | sub pack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | 3 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | 3 | my $less = (8 - (CORE::length($arg) & 7)) & 7; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | 3 | ▶ | $arg .= "0" x $less if $less; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | 3 | my $data = CORE::pack("B*",$arg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | 3 | Convert::BER::pack_length($ber,CORE::length($data)+1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | 3 | $ber->[ Convert::BER::_BUFFER() ] .= chr($less) . $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | 3 | ▶ | sub unpack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | 3 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | 3 | my $len = Convert::BER::unpack_length($ber); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | 3 | my $data = Convert::BER::unpack($ber,$len); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | 3 | my $less; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | 3 | ($less,$data) = CORE::unpack("C B*",$data,); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | 3 | $less = ord($less) & 7; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | 3 | ▶ | substr($data,-$less) = '' if $less; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | 3 | $$arg = $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | package Convert::BER::BIT_STRING8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | 0 | ▶ | sub pack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | 0 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | 0 | Convert::BER::pack_length($ber,CORE::length($arg)+1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | 0 | $ber->[ Convert::BER::_BUFFER() ] .= chr(0) . $arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | 0 | ▶ | sub unpack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | 0 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | 0 | my $len = Convert::BER::unpack_length($ber); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | 0 | my $less = Convert::BER::unpack($ber,1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | 0 | ▶ | my $data = $len > 1 ? Convert::BER::unpack($ber,$len-1) : ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | 0 | $$arg = $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | package Convert::BER::REAL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | 0 | ▶ | sub pack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | 0 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | 0 | require POSIX; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | 0 | my $data = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | 0 | ▶ | if($arg) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | 0 | my $s = 128; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | 0 | ▶ | if($arg < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | 0 | $s |= 64; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | 0 | $arg = -$arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | 0 | my @e = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | 0 | my @m = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | 0 | my($v,$e) = POSIX::frexp($arg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | 0 | $e -= 53; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | 0 | my $ae = abs($e); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | 0 | ▶ | if($ae < 0x80) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | 0 | @e = ($e & 0xff); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | elsif($ae < 0x8000) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | 0 | @e = map { $_ & 0xff } ($e>>8,$e); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | 0 | $s |= 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | elsif($ae < 0x800000) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | 0 | @e = map { $_ & 0xff } ($e>>16,$e>>8,$e); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | 0 | $s |= 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | 0 | @e = (4, map { $_ & 0xff } ($e>>24,$e>>16,$e>>8,$e)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | 0 | $s |= 3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | 0 | $v = POSIX::ldexp($v,5); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | 0 | my $f = POSIX::floor($v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | 0 | my $i = int($f); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | 0 | @m = ($i & 0xff); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | 0 | $v -= $f; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1741 | 0 | for (1..2) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | 0 | $v = POSIX::ldexp($v,24); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | 0 | $f = POSIX::floor($v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | 0 | $i = int($f); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | 0 | push @m, ($i >> 16) & 0xff, ($i >> 8) & 0xff, $i & 0xff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | 0 | $v -= $f; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | 0 | $data = pack("C*",$s,@e,@m); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | 0 | my $len = length($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | 0 | Convert::BER::pack_length($ber,$len); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | 0 | ▶ | Convert::BER::pack($ber,$data) if $len; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | 10 | my @base = (1,3,4,4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | 0 | ▶ | sub unpack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack: not called CC=14 SCAR=53.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | 0 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | 0 | my $len = Convert::BER::unpack_length($ber); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | 0 | ▶ | unless($len) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1762 | 0 | $$arg = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | 0 | my $data = Convert::BER::unpack($ber,$len); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | 0 | my $byte = unpack("C*",$data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | 0 | ▶ | if($byte & 0x80) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | 0 | $data = reverse $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | 0 | chop($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | 0 | require POSIX; # The sins for using REAL | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | 0 | my $base = $base[($byte & 0x30) >> 4]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | 0 | my $scale = $base & 0xC; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1774 | 0 | my $elen = $byte & 0x3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | 0 | ▶ | $elen = ord(chop($data)) - 1 if $elen == 3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1778 | 0 | ▶ | die "Bad REAL encoding" unless $elen >= 0 && $elen <= 3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$elen >= 0 and $elen <= 3
MC/DC0%0/2
$elen >= 0 and $elen <= 3
$elen >= 0
$elen <= 3
Truth table0%0/3
A and B
A= $elen >= 0B= $elen <= 3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1779 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1780 | 0 | my $exp = ord chop($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1781 | 0 | ▶ | $exp = -256 + $exp if $exp > 127; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1782 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1783 | 0 | ▶ | while ($elen--) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | 0 | $exp *= 256; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1785 | 0 | $exp += ord chop($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | 0 | $exp = $exp * $base + $scale; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1790 | 0 | my $v = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | 0 | ▶ | while(length($data)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1792 | 0 | $v = POSIX::ldexp($v,8) + ord chop($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1795 | 0 | ▶ | $v = POSIX::ldexp($v,$exp) if $exp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | 0 | ▶ | $v = -1 * $v if $byte & 0x40; # negative | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1798 | 0 | $$arg = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1800 | elsif($byte & 0x40) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | 0 | require POSIX; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1802 | 0 | ▶ | $$arg = POSIX::HUGE_VAL() * (($byte & 1) ? -1 : 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1804 | elsif(substr($data,1) =~ /^\s*([-+]?)0*(\d+(?:\.\d+(?:[Ee][-+]?\d+)?)?)\s*$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | 0 | $$arg = eval "$1$2"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1808 | 0 | $$arg = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1810 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1816 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1817 | package Convert::BER::_Time_generic; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | 0 | ▶ | sub pack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | 0 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1822 | 0 | ▶ | my $islocal = $self->isa('Convert::BER::TimeUL') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->isa('Convert::BER::TimeUL') || $self->isa('Convert::BER::TimeGL')
MC/DC0%0/2
$self->isa('Convert::BER::TimeUL') || $self->isa('Convert::BER::TimeGL')
$self->isa('Convert::BER::TimeUL')
$self->isa('Convert::BER::TimeGL')
Truth table0%0/3
A || B
A= $self->isa('Convert::BER::TimeUL')B= $self->isa('Convert::BER::TimeGL')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | || $self->isa('Convert::BER::TimeGL'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1824 | 0 | ▶ | my $isgen = $self->isa('Convert::BER::TimeGL') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->isa('Convert::BER::TimeGL') || $self->isa('Convert::BER::TimeGZ')
MC/DC0%0/2
$self->isa('Convert::BER::TimeGL') || $self->isa('Convert::BER::TimeGZ')
$self->isa('Convert::BER::TimeGL')
$self->isa('Convert::BER::TimeGZ')
Truth table0%0/3
A || B
A= $self->isa('Convert::BER::TimeGL')B= $self->isa('Convert::BER::TimeGZ')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | || $self->isa('Convert::BER::TimeGZ'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | 0 | ▶ | my @time = $islocal ? localtime($arg) : gmtime($arg); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1827 | 0 | my $off = 'Z'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | 0 | ▶ | if($islocal) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | 0 | my @g = gmtime($arg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | 0 | my $v = ($time[1] - $g[1]) + ($time[2] - $g[2]) * 60; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | 0 | my $d = $time[7] - $g[7]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | 0 | ▶ | if($d == 1 || $d < -1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$d == 1 or $d < -1
MC/DC0%0/2
$d == 1 or $d < -1
$d == 1
$d < -1
Truth table0%0/3
A or B
A= $d == 1B= $d < -1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1834 | 0 | $v += 1440; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1836 | elsif($d > 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | 0 | $v -= 1440; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1838 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1839 | 0 | $off = sprintf("%+03d%02d",$v / 60, abs($v % 60)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1840 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1841 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1842 | 0 | $time[4] += 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1843 | 0 | ▶ | $time[5] = $isgen ? $time[5] + 1900 : $time[5] % 100; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1844 | 0 | my $str = sprintf("%02d"x6, @time[5,4,3,2,1,0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1845 | 0 | ▶ | if($isgen) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1846 | 0 | my $split = $arg - int($arg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1847 | 0 | ▶ | $str .= sprintf(".%03d", int($split * 1000)) if($split); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1848 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1849 | 0 | Convert::BER::STRING::pack($self,$ber,$str . $off); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1850 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1851 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1852 | 0 | ▶ | sub unpack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack: not called CC=9 SCAR=42.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1853 | 0 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1854 | 0 | my $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1855 | 0 | ▶ | if(Convert::BER::STRING::unpack($self,$ber,\$str)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1856 | 0 | ▶ | my $isgen = $self->isa('Convert::BER::TimeGL') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->isa('Convert::BER::TimeGL') || $self->isa('Convert::BER::TimeGZ')
MC/DC0%0/2
$self->isa('Convert::BER::TimeGL') || $self->isa('Convert::BER::TimeGZ')
$self->isa('Convert::BER::TimeGL')
$self->isa('Convert::BER::TimeGZ')
Truth table0%0/3
A || B
A= $self->isa('Convert::BER::TimeGL')B= $self->isa('Convert::BER::TimeGZ')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1857 | || $self->isa('Convert::BER::TimeGZ'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1858 | 0 | ▶ | my $n = $isgen ? 4 : 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1859 | 0 | ▶ | my ($Y,$M,$D,$h,$m,$s,$z) = $str =~ /^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1860 | (\d{$n}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1861 | (\d\d) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1862 | (\d\d) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1863 | (\d\d) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1864 | (\d\d) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1865 | ((?:\d\d(?:\.\d+)?)?) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1866 | (Z|[-+]\d{4}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1867 | $/x or die "Bad Time string '$str'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1868 | 0 | my $offset = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1869 | 0 | ▶ | if($z ne 'Z') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1870 | 10 | ▶ | use integer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1871 | 0 | $offset = ((($z / 100) * 60) + ($z % 100)) * 60; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1872 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1873 | 0 | ▶ | if($s > int($s)) { # fraction of a seccond | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1874 | 0 | $offset -= ($s - int($s)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1875 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1876 | 0 | $M -= 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1877 | 0 | ▶ | if($isgen) { # GeneralizedTime uses 4-digit years | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1878 | 0 | $Y -= 1900; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1879 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1880 | elsif($Y <= 50) { # ASN.1 UTCTime | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1881 | 0 | $Y += 100; # specifies <=50 = 2000..2050, >50 = 1951..1999 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1882 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1883 | 0 | require Time::Local; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1884 | 0 | $$arg = Time::Local::timegm(int($s),$m,$h,$D,$M,$Y) - $offset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1885 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1886 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1887 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1888 | package Convert::BER::CHOICE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1889 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1890 | 0 | ▶ | sub pack_array { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack_array: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1891 | 0 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1892 | 0 | my $n = $arg->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1893 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1894 | 0 | ▶ | if(defined($n)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1895 | 0 | my $i = ($n * 2) + 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1896 | 0 | ▶ | die "Bad CHOICE index $n" if $n < 0 || $i > @$arg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$n < 0 or $i > @$arg
MC/DC0%0/2
$n < 0 or $i > @$arg
$n < 0
$i > @$arg
Truth table0%0/3
A or B
A= $n < 0B= $i > @$arg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1897 | 0 | $ber->_encode([$arg->[$i-1], $arg->[$i]]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1898 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1899 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1900 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1901 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1902 | 0 | ▶ | sub unpack_array { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack_array: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1903 | 0 | my($self,$ber,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1904 | 0 | my($i,$m,$err); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1905 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1906 | 0 | $m = @$arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1907 | 0 | my $want = Convert::BER::tag($ber); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1908 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1909 | 0 | ▶ | for($i = 1 ; $i < $m ; $i += 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1910 | 0 | my $tag; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1911 | 0 | my $type = $arg->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1912 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1913 | 0 | ▶ | ($type,$tag) = @$type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1914 | if(ref($type) eq 'ARRAY'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1915 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1916 | 0 | my $can = UNIVERSAL::can($ber,'_' . $type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1917 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1918 | 0 | ▶ | die "Unknown element '$type'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1919 | unless $can; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1920 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1921 | 0 | my $data = &$can(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1922 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1923 | 0 | ▶ | $tag = $data->[ Convert::BER::_TAG() ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1924 | unless defined $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1925 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1926 | 0 | ▶ | next unless $tag == $want; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1927 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1928 | 0 | ▶ | if ( eval { Convert::BER::_decode($ber,[@{$arg}[$i,$i+1]]) }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1929 | 0 | my $choice = $arg->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1930 | 0 | $$choice = ($i - 1) >> 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1931 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1932 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1933 | 0 | ▶ | $err = $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1934 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1935 | 0 | ▶ | die ($err || sprintf("Cannot decode CHOICE, found tag 0x%X\n",$want)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$err || sprintf("Cannot decode CHOICE, found tag 0x%X\n", $want)
MC/DC0%0/2
$err || sprintf("Cannot decode CHOICE, found tag 0x%X\n", $want)
$err
sprintf("Cannot decode CHOICE, found tag 0x%X\n", $want)
Truth table0%0/3
A || B
A= $errB= sprintf("Cannot decode CHOICE, found tag 0x%X\n", $want)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1936 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1937 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1938 | 10 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||