@wildboar/pki-stub
Version:
X.510 PKI-Stub ASN.1 data structures in TypeScript
215 lines • 8.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._get_encoder_for_SIGNED = exports._get_decoder_for_SIGNED = exports._extension_additions_list_spec_for_SIGNED = exports._root_component_type_list_2_spec_for_SIGNED = exports._root_component_type_list_1_spec_for_SIGNED = exports.SIGNED = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
const AlgorithmIdentifier_ta_1 = require("../PKI-Stub/AlgorithmIdentifier.ta");
/* START_OF_SYMBOL_DEFINITION SIGNED */
/**
* @summary SIGNED
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* SIGNED{ToBeSigned} ::= SEQUENCE {
* toBeSigned ToBeSigned,
* algorithmIdentifier AlgorithmIdentifier{{SupportedAlgorithms}},
* signature BIT STRING,
* ...,
* altAlgorithmIdentifier AlgorithmIdentifier{{SupportedAlgorithms}} OPTIONAL,
* altSignature BIT STRING OPTIONAL
* } (WITH COMPONENTS {..., altAlgorithmIdentifier PRESENT, altSignature PRESENT } |
* WITH COMPONENTS {..., altAlgorithmIdentifier ABSENT, altSignature ABSENT } )
* ```
*
* @class
*/
class SIGNED {
constructor(
/**
* @summary `toBeSigned`.
* @public
* @readonly
*/
toBeSigned,
/**
* @summary `algorithmIdentifier`.
* @public
* @readonly
*/
algorithmIdentifier,
/**
* @summary `signature`.
* @public
* @readonly
*/
signature,
/**
* @summary `altAlgorithmIdentifier`.
* @public
* @readonly
*/
altAlgorithmIdentifier,
/**
* @summary `altSignature`.
* @public
* @readonly
*/
altSignature,
/**
* @summary Extensions that are not recognized.
* @public
* @readonly
*/
_unrecognizedExtensionsList = [],
/**
* @summary
*/
originalDER) {
this.toBeSigned = toBeSigned;
this.algorithmIdentifier = algorithmIdentifier;
this.signature = signature;
this.altAlgorithmIdentifier = altAlgorithmIdentifier;
this.altSignature = altSignature;
this._unrecognizedExtensionsList = _unrecognizedExtensionsList;
this.originalDER = originalDER === null || originalDER === void 0 ? void 0 : originalDER.toBytes();
}
/**
* @summary Restructures an object into a SIGNED
* @description
*
* This takes an `object` and converts it to a `SIGNED`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `SIGNED`.
* @returns {SIGNED}
*/
static _from_object(_o) {
return new SIGNED(_o.toBeSigned, _o.algorithmIdentifier, _o.signature, _o.altAlgorithmIdentifier, _o.altSignature, _o._unrecognizedExtensionsList);
}
}
exports.SIGNED = SIGNED;
/* END_OF_SYMBOL_DEFINITION SIGNED */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_SIGNED */
/**
* @summary The Leading Root Component Types of SIGNED
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the leading root component type list of a SET or SEQUENCE.
*
* @constant
*/
exports._root_component_type_list_1_spec_for_SIGNED = [
new $.ComponentSpec("toBeSigned", false, $.hasAnyTag, undefined, undefined),
new $.ComponentSpec("algorithmIdentifier", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("signature", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 3), undefined, undefined),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_SIGNED */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_SIGNED */
/**
* @summary The Trailing Root Component Types of SIGNED
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the trailing root component type list of a SET or SEQUENCE.
*
* @constant
*/
exports._root_component_type_list_2_spec_for_SIGNED = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_SIGNED */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_SIGNED */
/**
* @summary The Extension Addition Component Types of SIGNED
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the extension addition component type list of a SET or SEQUENCE.
*
* @constant
*/
exports._extension_additions_list_spec_for_SIGNED = [
new $.ComponentSpec("altAlgorithmIdentifier", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("altSignature", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 3), undefined, undefined),
];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_SIGNED */
/* START_OF_SYMBOL_DEFINITION _get_decoder_for_SIGNED */
/**
* @summary Returns a function that will decode an ASN.1 element into a(n) SIGNED
* @function
* @param {_Element} el The element being decoded.
* @returns A function that will decode an ASN.1 element.
*/
function _get_decoder_for_SIGNED(_decode_ToBeSigned) {
return function (el) {
/* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */
let toBeSigned;
let algorithmIdentifier;
let signature;
let altAlgorithmIdentifier;
let altSignature;
let _unrecognizedExtensionsList = [];
const originalDER = el.toBytes();
/* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */
/* START_OF_CALLBACKS_MAP */
const callbacks = {
toBeSigned: (_el) => {
toBeSigned = _decode_ToBeSigned(_el);
},
algorithmIdentifier: (_el) => {
algorithmIdentifier = AlgorithmIdentifier_ta_1._decode_AlgorithmIdentifier(_el);
},
signature: (_el) => {
signature = $._decodeBitString(_el);
},
altAlgorithmIdentifier: (_el) => {
altAlgorithmIdentifier = AlgorithmIdentifier_ta_1._decode_AlgorithmIdentifier(_el);
},
altSignature: (_el) => {
altSignature = $._decodeBitString(_el);
},
};
/* END_OF_CALLBACKS_MAP */
$._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_SIGNED, exports._extension_additions_list_spec_for_SIGNED, exports._root_component_type_list_2_spec_for_SIGNED, (ext) => {
_unrecognizedExtensionsList.push(ext);
});
const ret = new SIGNED(
/* SEQUENCE_CONSTRUCTOR_CALL */ toBeSigned, algorithmIdentifier, signature, altAlgorithmIdentifier, altSignature, _unrecognizedExtensionsList, el);
ret.originalDER = originalDER;
return ret;
};
}
exports._get_decoder_for_SIGNED = _get_decoder_for_SIGNED;
/* END_OF_SYMBOL_DEFINITION _get_decoder_for_SIGNED */
/* START_OF_SYMBOL_DEFINITION _get_encoder_for_SIGNED */
/**
* @summary Returns a function that will encode a(n) SIGNED into an ASN.1 Element.
* @function
* @returns A function that will encode a(n) SIGNED as an ASN.1 element.
*/
function _get_encoder_for_SIGNED(_encode_ToBeSigned) {
return function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ _encode_ToBeSigned(value.toBeSigned, $.DER),
/* REQUIRED */ AlgorithmIdentifier_ta_1._encode_AlgorithmIdentifier(value.algorithmIdentifier, $.DER),
/* REQUIRED */ $._encodeBitString(value.signature, $.DER),
], [
/* IF_ABSENT */ value.altAlgorithmIdentifier ===
undefined
? undefined
: AlgorithmIdentifier_ta_1._encode_AlgorithmIdentifier(value.altAlgorithmIdentifier, $.DER),
/* IF_ABSENT */ value.altSignature === undefined
? undefined
: $._encodeBitString(value.altSignature, $.BER),
], value._unrecognizedExtensionsList
? value._unrecognizedExtensionsList
: [])
.filter((c) => !!c), $.DER);
};
}
exports._get_encoder_for_SIGNED = _get_encoder_for_SIGNED;
/* END_OF_SYMBOL_DEFINITION _get_encoder_for_SIGNED */
/* eslint-enable */
//# sourceMappingURL=SIGNED.ta.js.map