| 97 | } |
| 98 | } |
| 99 | getBitString() { |
| 100 | let result; |
| 101 | if (this.getTag() != 3) |
| 102 | throw new Error("BER: not a bit string"); |
| 103 | let length = this.getLength(); |
| 104 | let pad = this.#a[this.#i++]; |
| 105 | if (pad) { |
| 106 | result = new Uint8Array(length - 1); |
| 107 | for (let i = 0; i < length - 1; i++) |
| 108 | result[i] = this.#a[this.#i++] >>> pad; |
| 109 | } |
| 110 | else { |
| 111 | result = this.#a.subarray(this.#i, this.#i + length - 1); |
| 112 | this.#i += length; |
| 113 | } |
| 114 | return result; |
| 115 | } |
| 116 | getOctetString() { |
| 117 | if (this.getTag() != 0x04) |
| 118 | throw new Error("BER: not a octet string"); |