@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
183 lines • 8.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_CertificationRequestInfo = exports._decode_CertificationRequestInfo = exports._extension_additions_list_spec_for_CertificationRequestInfo = exports._root_component_type_list_2_spec_for_CertificationRequestInfo = exports._root_component_type_list_1_spec_for_CertificationRequestInfo = exports.CertificationRequestInfo = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
const Name_ta_1 = require("@wildboar/x500/src/lib/modules/InformationFramework/Name.ta");
const Attributes_ta_1 = require("../PKCS-10/Attributes.ta");
const CertificationRequestInfo_version_ta_1 = require("../PKCS-10/CertificationRequestInfo-version.ta");
const SubjectPublicKeyInfo_ta_1 = require("../PKCS-10/SubjectPublicKeyInfo.ta");
/* START_OF_SYMBOL_DEFINITION CertificationRequestInfo */
/**
* @summary CertificationRequestInfo
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* CertificationRequestInfo ::= SEQUENCE {
* version INTEGER { v1(0) } (v1,...),
* subject Name,
* subjectPKInfo SubjectPublicKeyInfo{{ PKInfoAlgorithms }},
* attributes [0] Attributes{{ CRIAttributes }}
* }
* ```
*
* @class
*/
class CertificationRequestInfo {
constructor(
/**
* @summary `version`.
* @public
* @readonly
*/
version,
/**
* @summary `subject`.
* @public
* @readonly
*/
subject,
/**
* @summary `subjectPKInfo`.
* @public
* @readonly
*/
subjectPKInfo,
/**
* @summary `attributes`.
* @public
* @readonly
*/
attributes) {
this.version = version;
this.subject = subject;
this.subjectPKInfo = subjectPKInfo;
this.attributes = attributes;
}
/**
* @summary Restructures an object into a CertificationRequestInfo
* @description
*
* This takes an `object` and converts it to a `CertificationRequestInfo`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `CertificationRequestInfo`.
* @returns {CertificationRequestInfo}
*/
static _from_object(_o) {
return new CertificationRequestInfo(_o.version, _o.subject, _o.subjectPKInfo, _o.attributes);
}
}
exports.CertificationRequestInfo = CertificationRequestInfo;
/* END_OF_SYMBOL_DEFINITION CertificationRequestInfo */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_CertificationRequestInfo */
/**
* @summary The Leading Root Component Types of CertificationRequestInfo
* @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_CertificationRequestInfo = [
new $.ComponentSpec("version", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
new $.ComponentSpec("subject", false, $.hasAnyTag, undefined, undefined),
new $.ComponentSpec("subjectPKInfo", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("attributes", false, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_CertificationRequestInfo */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_CertificationRequestInfo */
/**
* @summary The Trailing Root Component Types of CertificationRequestInfo
* @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_CertificationRequestInfo = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_CertificationRequestInfo */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_CertificationRequestInfo */
/**
* @summary The Extension Addition Component Types of CertificationRequestInfo
* @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_CertificationRequestInfo = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_CertificationRequestInfo */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_CertificationRequestInfo */
let _cached_decoder_for_CertificationRequestInfo = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_CertificationRequestInfo */
/* START_OF_SYMBOL_DEFINITION _decode_CertificationRequestInfo */
/**
* @summary Decodes an ASN.1 element into a(n) CertificationRequestInfo
* @function
* @param {_Element} el The element being decoded.
* @returns {CertificationRequestInfo} The decoded data structure.
*/
function _decode_CertificationRequestInfo(el) {
if (!_cached_decoder_for_CertificationRequestInfo) {
_cached_decoder_for_CertificationRequestInfo = function (el) {
const sequence = el.sequence;
if (sequence.length < 4) {
throw new asn1_ts_1.ASN1ConstructionError("CertificationRequestInfo contained only " +
sequence.length.toString() +
" elements.");
}
sequence[0].name = "version";
sequence[1].name = "subject";
sequence[2].name = "subjectPKInfo";
sequence[3].name = "attributes";
let version;
let subject;
let subjectPKInfo;
let attributes;
version = CertificationRequestInfo_version_ta_1._decode_CertificationRequestInfo_version(sequence[0]);
subject = Name_ta_1._decode_Name(sequence[1]);
subjectPKInfo = SubjectPublicKeyInfo_ta_1._decode_SubjectPublicKeyInfo(sequence[2]);
attributes = $._decode_implicit(() => Attributes_ta_1._decode_Attributes)(sequence[3]);
return new CertificationRequestInfo(version, subject, subjectPKInfo, attributes);
};
}
return _cached_decoder_for_CertificationRequestInfo(el);
}
exports._decode_CertificationRequestInfo = _decode_CertificationRequestInfo;
/* END_OF_SYMBOL_DEFINITION _decode_CertificationRequestInfo */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_CertificationRequestInfo */
let _cached_encoder_for_CertificationRequestInfo = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_CertificationRequestInfo */
/* START_OF_SYMBOL_DEFINITION _encode_CertificationRequestInfo */
/**
* @summary Encodes a(n) CertificationRequestInfo into an ASN.1 Element.
* @function
* @param {value} el The element being decoded.
* @param elGetter A function that can be used to get new ASN.1 elements.
* @returns {_Element} The CertificationRequestInfo, encoded as an ASN.1 Element.
*/
function _encode_CertificationRequestInfo(value, elGetter) {
if (!_cached_encoder_for_CertificationRequestInfo) {
_cached_encoder_for_CertificationRequestInfo = function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ CertificationRequestInfo_version_ta_1._encode_CertificationRequestInfo_version(value.version, $.BER),
/* REQUIRED */ Name_ta_1._encode_Name(value.subject, $.BER),
/* REQUIRED */ SubjectPublicKeyInfo_ta_1._encode_SubjectPublicKeyInfo(value.subjectPKInfo, $.BER),
/* REQUIRED */ $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => Attributes_ta_1._encode_Attributes, $.BER)(value.attributes, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_CertificationRequestInfo(value, elGetter);
}
exports._encode_CertificationRequestInfo = _encode_CertificationRequestInfo;
/* END_OF_SYMBOL_DEFINITION _encode_CertificationRequestInfo */
/* eslint-enable */
//# sourceMappingURL=CertificationRequestInfo.ta.js.map