summaryrefslogtreecommitdiffstats
path: root/comm/third_party/asn1js/src/Null.ts
diff options
context:
space:
mode:
Diffstat (limited to 'comm/third_party/asn1js/src/Null.ts')
-rw-r--r--comm/third_party/asn1js/src/Null.ts65
1 files changed, 65 insertions, 0 deletions
diff --git a/comm/third_party/asn1js/src/Null.ts b/comm/third_party/asn1js/src/Null.ts
new file mode 100644
index 0000000000..8c4c4c580d
--- /dev/null
+++ b/comm/third_party/asn1js/src/Null.ts
@@ -0,0 +1,65 @@
+import { ViewWriter } from "./ViewWriter";
+import { ValueBlock, ValueBlockJson } from "./ValueBlock";
+import { BaseBlock, BaseBlockJson, BaseBlockParams } from "./BaseBlock";
+import { typeStore } from "./TypeStore";
+
+export type NullParams = BaseBlockParams;
+export type NullJson = BaseBlockJson<ValueBlockJson>;
+
+export class Null extends BaseBlock<ValueBlock, ValueBlockJson> {
+
+ static {
+ typeStore.Null = this;
+ }
+
+ public static override NAME = "NULL";
+
+ constructor(parameters: NullParams = {}) {
+ super(parameters, ValueBlock); // We will not have a call to "Null value block" because of specified FROM_BER and TO_BER functions
+
+ this.idBlock.tagClass = 1; // UNIVERSAL
+ this.idBlock.tagNumber = 5; // Null
+ }
+
+ public override fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number {
+ if (this.lenBlock.length > 0)
+ this.warnings.push("Non-zero length of value block for Null type");
+
+ if (!this.idBlock.error.length)
+ this.blockLength += this.idBlock.blockLength;
+
+ if (!this.lenBlock.error.length)
+ this.blockLength += this.lenBlock.blockLength;
+
+ this.blockLength += inputLength;
+
+ if ((inputOffset + inputLength) > inputBuffer.byteLength) {
+ this.error = "End of input reached before message was fully decoded (inconsistent offset and length values)";
+
+ return -1;
+ }
+
+ return (inputOffset + inputLength);
+ }
+
+ public override toBER(sizeOnly?: boolean, writer?: ViewWriter): ArrayBuffer {
+ const retBuf = new ArrayBuffer(2);
+
+ if (!sizeOnly) {
+ const retView = new Uint8Array(retBuf);
+ retView[0] = 0x05;
+ retView[1] = 0x00;
+ }
+
+ if (writer) {
+ writer.write(retBuf);
+ }
+
+ return retBuf;
+ }
+
+ protected override onAsciiEncoding(): string {
+ return `${(this.constructor as typeof Null).NAME}`;
+ }
+
+}