Rev 4 | Rev 9 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4 | Rev 5 | ||
---|---|---|---|
Line 40... | Line 40... | ||
40 | } |
40 | } |
41 | return $ary; |
41 | return $ary; |
42 | } |
42 | } |
43 | 43 | ||
44 | /** |
44 | /** |
45 | * @return Outputs .<oid> for an absolute OID and <oid> for a relative OID. |
45 | * @return string|false Outputs .<oid> for an absolute OID and <oid> for a relative OID. |
46 | */ |
46 | */ |
47 | public static function derToOID($abBinary, $verbose=false) { |
47 | public static function derToOID($abBinary, $verbose=false) { |
48 | $output_oid = array(); |
48 | $output_oid = array(); |
49 | $output_absolute = true; |
49 | $output_absolute = true; |
50 | 50 | ||
Line 68... | Line 68... | ||
68 | $lengthbyte_pos = 0; |
68 | $lengthbyte_pos = 0; |
69 | $lengthfinished = false; |
69 | $lengthfinished = false; |
70 | 70 | ||
71 | $arcBeginning = true; |
71 | $arcBeginning = true; |
72 | 72 | ||
- | 73 | $isRelative = null; // to avoid that phpstan complains |
|
- | 74 | ||
73 | foreach ($abBinary as $nn => &$pb) { |
75 | foreach ($abBinary as $nn => &$pb) { |
74 | if ($part == 0) { // Class Tag |
76 | if ($part == 0) { // Class Tag |
75 | // Leading octet |
77 | // Leading octet |
76 | // Bit 7 / Bit 6 = Universal (00), Application (01), Context (10), Private(11) |
78 | // Bit 7 / Bit 6 = Universal (00), Application (01), Context (10), Private(11) |
77 | // Bit 5 = Primitive (0), Constructed (1) |
79 | // Bit 5 = Primitive (0), Constructed (1) |
Line 185... | Line 187... | ||
185 | 187 | ||
186 | if (($pb & 0x80) != 0) { |
188 | if (($pb & 0x80) != 0) { |
187 | // 2.48 and up => 2+ octets |
189 | // 2.48 and up => 2+ octets |
188 | // Output in "part 3" |
190 | // Output in "part 3" |
189 | 191 | ||
190 | if ($arcBeginning && ($pb == 0x80)) { |
192 | if ($pb == 0x80) { |
191 | if ($verbose) fprintf(STDERR, "Encoding error. Illegal 0x80 paddings. (See Rec. ITU-T X.690, clause 8.19.2)\n"); |
193 | if ($verbose) fprintf(STDERR, "Encoding error. Illegal 0x80 paddings. (See Rec. ITU-T X.690, clause 8.19.2)\n"); |
192 | return false; |
194 | return false; |
193 | } else { |
195 | } else { |
194 | $arcBeginning = false; |
196 | $arcBeginning = false; |
195 | } |
197 | } |
Line 348... | Line 350... | ||
348 | 350 | ||
349 | $output[] = 0x80 + $lengthCount; |
351 | $output[] = 0x80 + $lengthCount; |
350 | 352 | ||
351 | $nBinaryWork = $nBinary; |
353 | $nBinaryWork = $nBinary; |
352 | do { |
354 | do { |
353 | $output[] = nBinaryWork & 0xFF; |
355 | $output[] = $nBinaryWork & 0xFF; |
354 | $nBinaryWork /= 0x100; |
356 | $nBinaryWork /= 0x100; |
355 | } while ($nBinaryWork > 0); |
357 | } while ($nBinaryWork > 0); |
356 | } |
358 | } |
357 | 359 | ||
358 | foreach ($abBinary as $b) { |
360 | foreach ($abBinary as $b) { |