/** * Concatenate a list of byte arrays into a single {@link Uint8Array}. * * @param arrays The arrays to join, in order. * @returns A new array holding every input back to back. */ export declare function concat(arrays: ReadonlyArray): Uint8Array; /** * Tag-length-value: wrap `content` in an identifier octet + definite-form length. * * @param tag The identifier octet (tag class + constructed bit + number). * @param content The already-encoded value bytes. * @returns The complete `tag || length || content` encoding. */ export declare function tlv(tag: number, content: Uint8Array): Uint8Array; /** SEQUENCE (tag `0x30`) wrapping the concatenated `items`. */ export declare const seq: (...items: Array) => Uint8Array; /** SET (tag `0x31`) wrapping the concatenated `items`. */ export declare const set: (...items: Array) => Uint8Array; /** OCTET STRING (tag `0x04`) wrapping raw `bytes`. */ export declare const octetString: (bytes: Uint8Array) => Uint8Array; /** NULL (tag `0x05`, empty content). */ export declare const nullValue: () => Uint8Array; /** `[n]` context-tag, constructed (EXPLICIT or IMPLICIT-over-constructed). */ export declare const explicit: (tagNum: number, content: Uint8Array) => Uint8Array; /** * Encode a dotted OBJECT IDENTIFIER (§8.19). The first two arcs fold into * `40*a + b`; each subsequent arc is base-128 big-endian. * * @param dotted The OID in dotted form, e.g. `"1.2.840.113549.1.7.2"`. * @returns The OID TLV (tag `0x06`). */ export declare function oid(dotted: string): Uint8Array; /** * Encode an INTEGER (§8.3) in minimal two's-complement form. Accepts a small * non-negative number or raw magnitude bytes; prepends `0x00` when the top bit * is set so the value stays positive. * * @param value A non-negative number, or big-endian magnitude bytes. * @returns The INTEGER TLV (tag `0x02`). */ export declare function integer(value: number | Uint8Array): Uint8Array; /** * Encode a CMS Time (RFC 5652 §11.3): `UTCTime` (`YYMMDDHHMMSSZ`) for years * 1950–2049, `GeneralizedTime` (`YYYYMMDDHHMMSSZ`) otherwise. * * @param d The instant to encode (formatted in UTC). * @returns The time TLV (tag `0x17` or `0x18`). */ export declare function cmsTime(d: Date): Uint8Array; /** * The sorted, concatenated content of a `SET OF` (§11.6) — without the outer * tag, so the same canonical body can be wrapped once as SET (`0x31`, for * signing) and once as `[0]` IMPLICIT (`0xa0`, inside the `SignerInfo`). * * @param items The set members (each a full DER encoding). * @returns The members sorted ascending by encoding and concatenated. */ export declare function setOfBody(items: ReadonlyArray): Uint8Array; /** A parsed DER tag-length-value, as byte offsets into the source buffer. */ export interface Tlv { /** The identifier octet. */ readonly tag: number; /** Offset of the first content byte. */ readonly contentStart: number; /** Offset one past the last content byte. */ readonly contentEnd: number; /** Offset one past the whole TLV (same as `contentEnd` for definite lengths). */ readonly end: number; } /** * Parse the immediate child TLVs of a constructed `parent`, in order. * * @param buf The buffer the offsets index into. * @param parent The constructed TLV whose content is walked. * @returns Each child {@link Tlv}, left to right. */ export declare function children(buf: Uint8Array, parent: Tlv): Array; /** * Read a single TLV header at `offset`, decoding short- and long-form lengths. * * @param buf The source buffer. * @param offset The offset of the identifier octet. * @returns The parsed {@link Tlv} (offsets relative to `buf`). */ export declare function readTlv(buf: Uint8Array, offset: number): Tlv; /** * Pull the issuer Name and serialNumber out of an X.509 certificate, as raw DER * TLV slices (verbatim, for the CMS `IssuerAndSerialNumber`). * * `Certificate ::= SEQ { tbsCertificate SEQ { [0] version?, serialNumber INTEGER, * signature AlgId, issuer Name, ... }, ... }`. * * @param cert The DER-encoded certificate. * @returns The `issuer` Name and `serial` INTEGER, each a verbatim DER slice. */ export declare function certIssuerAndSerial(cert: Uint8Array): { readonly issuer: Uint8Array; readonly serial: Uint8Array; };