| 346 | return this._decode(new BER(a)); |
| 347 | } |
| 348 | static _decode(b) { |
| 349 | let tag = b.getTag(); |
| 350 | if (tag == 0) { |
| 351 | // must be 00 terminator |
| 352 | if (b.getc() != 0) |
| 353 | throw new Error(); |
| 354 | return null; |
| 355 | } |
| 356 | if ((tag & 0x1f) == 0x1f) { |
| 357 | // extended tag -- just ignore |
| 358 | while (b.getc() >= 0x80) |
| 359 | ; |
| 360 | } |
| 361 | let res = this.decodeTag(tag, b, b.getLength()); |
| 362 | if (!(res instanceof Array)) |
| 363 | res = [res]; |
| 364 | res.unshift(tag); |
| 365 | return res; |
| 366 | } |
| 367 | static decodeTag(tag, b, len) { |
| 368 | let res; |
| 369 | if ((tag >> 6) == 2) { // context specific class |