Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
40 lines
1.1 KiB
Plaintext
40 lines
1.1 KiB
Plaintext
import * as asn1js from "asn1js";
|
|
import { BufferSourceConverter } from "pvtsutils";
|
|
export class OctetString {
|
|
get byteLength() {
|
|
return this.buffer.byteLength;
|
|
}
|
|
get byteOffset() {
|
|
return 0;
|
|
}
|
|
constructor(param) {
|
|
if (typeof param === "number") {
|
|
this.buffer = new ArrayBuffer(param);
|
|
}
|
|
else {
|
|
if (BufferSourceConverter.isBufferSource(param)) {
|
|
this.buffer = BufferSourceConverter.toArrayBuffer(param);
|
|
}
|
|
else if (Array.isArray(param)) {
|
|
this.buffer = new Uint8Array(param);
|
|
}
|
|
else {
|
|
this.buffer = new ArrayBuffer(0);
|
|
}
|
|
}
|
|
}
|
|
fromASN(asn) {
|
|
if (!(asn instanceof asn1js.OctetString)) {
|
|
throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");
|
|
}
|
|
this.buffer = asn.valueBlock.valueHex;
|
|
return this;
|
|
}
|
|
toASN() {
|
|
return new asn1js.OctetString({ valueHex: this.buffer });
|
|
}
|
|
toSchema(name) {
|
|
return new asn1js.OctetString({ name });
|
|
}
|
|
}
|