asn1tools-js
Version:
ASN.1 encoding and decoding library for TypeScript/JavaScript, compatible with Python asn1tools
81 lines • 2.06 kB
TypeScript
/**
* ASN.1 type implementations using BER encoding
*/
import { Asn1Type } from '../types';
/**
* Base class for all ASN.1 types
*/
export declare abstract class BaseType implements Asn1Type {
name: string;
tag: number;
protected constructed: boolean;
constructor(name: string, tag: number);
abstract encode(value: any): Uint8Array;
abstract decode(data: Uint8Array, offset?: number): {
value: any;
length: number;
};
protected encodeWithTag(content: Uint8Array): Uint8Array;
protected decodeWithTag(data: Uint8Array, offset?: number): {
content: Uint8Array;
totalLength: number;
};
}
/**
* ASN.1 INTEGER type
*/
export declare class IntegerType extends BaseType {
constructor(name: string);
encode(value: any): Uint8Array;
decode(data: Uint8Array, offset?: number): {
value: number | bigint;
length: number;
};
}
/**
* ASN.1 BOOLEAN type
*/
export declare class BooleanType extends BaseType {
constructor(name: string);
encode(value: any): Uint8Array;
decode(data: Uint8Array, offset?: number): {
value: boolean;
length: number;
};
}
/**
* ASN.1 OCTET STRING type
*/
export declare class OctetStringType extends BaseType {
constructor(name: string);
encode(value: any): Uint8Array;
decode(data: Uint8Array, offset?: number): {
value: Uint8Array;
length: number;
};
}
/**
* ASN.1 NULL type
*/
export declare class NullType extends BaseType {
constructor(name: string);
encode(value: any): Uint8Array;
decode(data: Uint8Array, offset?: number): {
value: null;
length: number;
};
}
/**
* ASN.1 ENUMERATED type
*/
export declare class EnumeratedType extends BaseType {
private valueMap;
private nameMap;
constructor(name: string, values: Array<[string, number]>);
encode(value: any): Uint8Array;
decode(data: Uint8Array, offset?: number): {
value: string;
length: number;
};
}
//# sourceMappingURL=types.d.ts.map