UNPKG

asn1-ts

Version:

ASN.1 encoding and decoding, including BER, CER, and DER.

11 lines (10 loc) 365 B
import * as errors from "../../../errors.mjs"; export default function decodeBoolean(value) { if (value.length !== 1) { throw new errors.ASN1SizeError("BOOLEAN not one byte"); } if ((value[0] !== 0x00) && (value[0] !== 0xFF)) { throw new errors.ASN1Error("BOOLEAN must be encoded as 0xFF or 0x00."); } return (value[0] !== 0); }