@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
299 lines • 17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_AuthenticatedData = exports._decode_AuthenticatedData = exports._extension_additions_list_spec_for_AuthenticatedData = exports._root_component_type_list_2_spec_for_AuthenticatedData = exports._root_component_type_list_1_spec_for_AuthenticatedData = exports.AuthenticatedData = exports._encode_Version = exports._decode_Version = exports._encode_RecipientInfos = exports._decode_RecipientInfos = exports._encode_OriginatorInfo = exports._decode_OriginatorInfo = exports.OriginatorInfo = exports._encode_MessageAuthenticationCodeAlgorithmIdentifier = exports._decode_MessageAuthenticationCodeAlgorithmIdentifier = exports._encode_MessageAuthenticationCode = exports._decode_MessageAuthenticationCode = exports._encode_DigestAlgorithmIdentifier = exports._decode_DigestAlgorithmIdentifier = exports._encode_ContentInfo = exports._decode_ContentInfo = exports.ContentInfo = exports._encode_Attributes = exports._decode_Attributes = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
const Attributes_ta_1 = require("../PKCS7/Attributes.ta");
const ContentInfo_ta_1 = require("../PKCS7/ContentInfo.ta");
const DigestAlgorithmIdentifier_ta_1 = require("../PKCS7/DigestAlgorithmIdentifier.ta");
const MessageAuthenticationCode_ta_1 = require("../PKCS7/MessageAuthenticationCode.ta");
const MessageAuthenticationCodeAlgorithmIdentifier_ta_1 = require("../PKCS7/MessageAuthenticationCodeAlgorithmIdentifier.ta");
const OriginatorInfo_ta_1 = require("../PKCS7/OriginatorInfo.ta");
const RecipientInfos_ta_1 = require("../PKCS7/RecipientInfos.ta");
const Version_ta_1 = require("../PKCS7/Version.ta");
var Attributes_ta_2 = require("../PKCS7/Attributes.ta");
Object.defineProperty(exports, "_decode_Attributes", { enumerable: true, get: function () { return Attributes_ta_2._decode_Attributes; } });
Object.defineProperty(exports, "_encode_Attributes", { enumerable: true, get: function () { return Attributes_ta_2._encode_Attributes; } });
var ContentInfo_ta_2 = require("../PKCS7/ContentInfo.ta");
Object.defineProperty(exports, "ContentInfo", { enumerable: true, get: function () { return ContentInfo_ta_2.ContentInfo; } });
Object.defineProperty(exports, "_decode_ContentInfo", { enumerable: true, get: function () { return ContentInfo_ta_2._decode_ContentInfo; } });
Object.defineProperty(exports, "_encode_ContentInfo", { enumerable: true, get: function () { return ContentInfo_ta_2._encode_ContentInfo; } });
var DigestAlgorithmIdentifier_ta_2 = require("../PKCS7/DigestAlgorithmIdentifier.ta");
Object.defineProperty(exports, "_decode_DigestAlgorithmIdentifier", { enumerable: true, get: function () { return DigestAlgorithmIdentifier_ta_2._decode_DigestAlgorithmIdentifier; } });
Object.defineProperty(exports, "_encode_DigestAlgorithmIdentifier", { enumerable: true, get: function () { return DigestAlgorithmIdentifier_ta_2._encode_DigestAlgorithmIdentifier; } });
var MessageAuthenticationCode_ta_2 = require("../PKCS7/MessageAuthenticationCode.ta");
Object.defineProperty(exports, "_decode_MessageAuthenticationCode", { enumerable: true, get: function () { return MessageAuthenticationCode_ta_2._decode_MessageAuthenticationCode; } });
Object.defineProperty(exports, "_encode_MessageAuthenticationCode", { enumerable: true, get: function () { return MessageAuthenticationCode_ta_2._encode_MessageAuthenticationCode; } });
var MessageAuthenticationCodeAlgorithmIdentifier_ta_2 = require("../PKCS7/MessageAuthenticationCodeAlgorithmIdentifier.ta");
Object.defineProperty(exports, "_decode_MessageAuthenticationCodeAlgorithmIdentifier", { enumerable: true, get: function () { return MessageAuthenticationCodeAlgorithmIdentifier_ta_2._decode_MessageAuthenticationCodeAlgorithmIdentifier; } });
Object.defineProperty(exports, "_encode_MessageAuthenticationCodeAlgorithmIdentifier", { enumerable: true, get: function () { return MessageAuthenticationCodeAlgorithmIdentifier_ta_2._encode_MessageAuthenticationCodeAlgorithmIdentifier; } });
var OriginatorInfo_ta_2 = require("../PKCS7/OriginatorInfo.ta");
Object.defineProperty(exports, "OriginatorInfo", { enumerable: true, get: function () { return OriginatorInfo_ta_2.OriginatorInfo; } });
Object.defineProperty(exports, "_decode_OriginatorInfo", { enumerable: true, get: function () { return OriginatorInfo_ta_2._decode_OriginatorInfo; } });
Object.defineProperty(exports, "_encode_OriginatorInfo", { enumerable: true, get: function () { return OriginatorInfo_ta_2._encode_OriginatorInfo; } });
var RecipientInfos_ta_2 = require("../PKCS7/RecipientInfos.ta");
Object.defineProperty(exports, "_decode_RecipientInfos", { enumerable: true, get: function () { return RecipientInfos_ta_2._decode_RecipientInfos; } });
Object.defineProperty(exports, "_encode_RecipientInfos", { enumerable: true, get: function () { return RecipientInfos_ta_2._encode_RecipientInfos; } });
var Version_ta_2 = require("../PKCS7/Version.ta");
Object.defineProperty(exports, "_decode_Version", { enumerable: true, get: function () { return Version_ta_2._decode_Version; } });
Object.defineProperty(exports, "_encode_Version", { enumerable: true, get: function () { return Version_ta_2._encode_Version; } });
/* START_OF_SYMBOL_DEFINITION AuthenticatedData */
/**
* @summary AuthenticatedData
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* AuthenticatedData ::= SEQUENCE {
* version Version,
* originatorInfo [0] OriginatorInfo OPTIONAL,
* recipientInfos RecipientInfos,
* macAlgorithm MessageAuthenticationCodeAlgorithmIdentifier,
* digestAlgorithm [1] DigestAlgorithmIdentifier OPTIONAL,
* contentInfo ContentInfo,
* authenticatedAttributes [2] Attributes OPTIONAL,
* messageAuthenticationCode MessageAuthenticationCode,
* unauthenticatedAttributes [3] Attributes OPTIONAL
* }
* ```
*
* @class
*/
class AuthenticatedData {
constructor(
/**
* @summary `version`.
* @public
* @readonly
*/
version,
/**
* @summary `originatorInfo`.
* @public
* @readonly
*/
originatorInfo,
/**
* @summary `recipientInfos`.
* @public
* @readonly
*/
recipientInfos,
/**
* @summary `macAlgorithm`.
* @public
* @readonly
*/
macAlgorithm,
/**
* @summary `digestAlgorithm`.
* @public
* @readonly
*/
digestAlgorithm,
/**
* @summary `contentInfo`.
* @public
* @readonly
*/
contentInfo,
/**
* @summary `authenticatedAttributes`.
* @public
* @readonly
*/
authenticatedAttributes,
/**
* @summary `messageAuthenticationCode`.
* @public
* @readonly
*/
messageAuthenticationCode,
/**
* @summary `unauthenticatedAttributes`.
* @public
* @readonly
*/
unauthenticatedAttributes) {
this.version = version;
this.originatorInfo = originatorInfo;
this.recipientInfos = recipientInfos;
this.macAlgorithm = macAlgorithm;
this.digestAlgorithm = digestAlgorithm;
this.contentInfo = contentInfo;
this.authenticatedAttributes = authenticatedAttributes;
this.messageAuthenticationCode = messageAuthenticationCode;
this.unauthenticatedAttributes = unauthenticatedAttributes;
}
/**
* @summary Restructures an object into a AuthenticatedData
* @description
*
* This takes an `object` and converts it to a `AuthenticatedData`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `AuthenticatedData`.
* @returns {AuthenticatedData}
*/
static _from_object(_o) {
return new AuthenticatedData(_o.version, _o.originatorInfo, _o.recipientInfos, _o.macAlgorithm, _o.digestAlgorithm, _o.contentInfo, _o.authenticatedAttributes, _o.messageAuthenticationCode, _o.unauthenticatedAttributes);
}
}
exports.AuthenticatedData = AuthenticatedData;
/* END_OF_SYMBOL_DEFINITION AuthenticatedData */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_AuthenticatedData */
/**
* @summary The Leading Root Component Types of AuthenticatedData
* @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_AuthenticatedData = [
new $.ComponentSpec("version", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
new $.ComponentSpec("originatorInfo", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined),
new $.ComponentSpec("recipientInfos", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 17), undefined, undefined),
new $.ComponentSpec("macAlgorithm", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("digestAlgorithm", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 1), undefined, undefined),
new $.ComponentSpec("contentInfo", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("authenticatedAttributes", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 2), undefined, undefined),
new $.ComponentSpec("messageAuthenticationCode", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined),
new $.ComponentSpec("unauthenticatedAttributes", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 3), undefined, undefined),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_AuthenticatedData */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_AuthenticatedData */
/**
* @summary The Trailing Root Component Types of AuthenticatedData
* @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_AuthenticatedData = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_AuthenticatedData */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_AuthenticatedData */
/**
* @summary The Extension Addition Component Types of AuthenticatedData
* @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_AuthenticatedData = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_AuthenticatedData */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_AuthenticatedData */
let _cached_decoder_for_AuthenticatedData = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_AuthenticatedData */
/* START_OF_SYMBOL_DEFINITION _decode_AuthenticatedData */
/**
* @summary Decodes an ASN.1 element into a(n) AuthenticatedData
* @function
* @param {_Element} el The element being decoded.
* @returns {AuthenticatedData} The decoded data structure.
*/
function _decode_AuthenticatedData(el) {
if (!_cached_decoder_for_AuthenticatedData) {
_cached_decoder_for_AuthenticatedData = function (el) {
/* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */
let version;
let originatorInfo;
let recipientInfos;
let macAlgorithm;
let digestAlgorithm;
let contentInfo;
let authenticatedAttributes;
let messageAuthenticationCode;
let unauthenticatedAttributes;
/* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */
/* START_OF_CALLBACKS_MAP */
const callbacks = {
version: (_el) => {
version = Version_ta_1._decode_Version(_el);
},
originatorInfo: (_el) => {
originatorInfo = $._decode_implicit(() => OriginatorInfo_ta_1._decode_OriginatorInfo)(_el);
},
recipientInfos: (_el) => {
recipientInfos = RecipientInfos_ta_1._decode_RecipientInfos(_el);
},
macAlgorithm: (_el) => {
macAlgorithm = MessageAuthenticationCodeAlgorithmIdentifier_ta_1._decode_MessageAuthenticationCodeAlgorithmIdentifier(_el);
},
digestAlgorithm: (_el) => {
digestAlgorithm = $._decode_implicit(() => DigestAlgorithmIdentifier_ta_1._decode_DigestAlgorithmIdentifier)(_el);
},
contentInfo: (_el) => {
contentInfo = ContentInfo_ta_1._decode_ContentInfo(_el);
},
authenticatedAttributes: (_el) => {
authenticatedAttributes = $._decode_implicit(() => Attributes_ta_1._decode_Attributes)(_el);
},
messageAuthenticationCode: (_el) => {
messageAuthenticationCode = MessageAuthenticationCode_ta_1._decode_MessageAuthenticationCode(_el);
},
unauthenticatedAttributes: (_el) => {
unauthenticatedAttributes = $._decode_implicit(() => Attributes_ta_1._decode_Attributes)(_el);
},
};
/* END_OF_CALLBACKS_MAP */
$._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_AuthenticatedData, exports._extension_additions_list_spec_for_AuthenticatedData, exports._root_component_type_list_2_spec_for_AuthenticatedData, undefined);
return new AuthenticatedData(
/* SEQUENCE_CONSTRUCTOR_CALL */ version, originatorInfo, recipientInfos, macAlgorithm, digestAlgorithm, contentInfo, authenticatedAttributes, messageAuthenticationCode, unauthenticatedAttributes);
};
}
return _cached_decoder_for_AuthenticatedData(el);
}
exports._decode_AuthenticatedData = _decode_AuthenticatedData;
/* END_OF_SYMBOL_DEFINITION _decode_AuthenticatedData */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_AuthenticatedData */
let _cached_encoder_for_AuthenticatedData = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_AuthenticatedData */
/* START_OF_SYMBOL_DEFINITION _encode_AuthenticatedData */
/**
* @summary Encodes a(n) AuthenticatedData 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 AuthenticatedData, encoded as an ASN.1 Element.
*/
function _encode_AuthenticatedData(value, elGetter) {
if (!_cached_encoder_for_AuthenticatedData) {
_cached_encoder_for_AuthenticatedData = function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ Version_ta_1._encode_Version(value.version, $.BER),
/* IF_ABSENT */ value.originatorInfo === undefined
? undefined
: $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => OriginatorInfo_ta_1._encode_OriginatorInfo, $.BER)(value.originatorInfo, $.BER),
/* REQUIRED */ RecipientInfos_ta_1._encode_RecipientInfos(value.recipientInfos, $.BER),
/* REQUIRED */ MessageAuthenticationCodeAlgorithmIdentifier_ta_1._encode_MessageAuthenticationCodeAlgorithmIdentifier(value.macAlgorithm, $.BER),
/* IF_ABSENT */ value.digestAlgorithm === undefined
? undefined
: $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 1, () => DigestAlgorithmIdentifier_ta_1._encode_DigestAlgorithmIdentifier, $.BER)(value.digestAlgorithm, $.BER),
/* REQUIRED */ ContentInfo_ta_1._encode_ContentInfo(value.contentInfo, $.BER),
/* IF_ABSENT */ value.authenticatedAttributes ===
undefined
? undefined
: $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 2, () => Attributes_ta_1._encode_Attributes, $.BER)(value.authenticatedAttributes, $.BER),
/* REQUIRED */ MessageAuthenticationCode_ta_1._encode_MessageAuthenticationCode(value.messageAuthenticationCode, $.BER),
/* IF_ABSENT */ value.unauthenticatedAttributes ===
undefined
? undefined
: $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 3, () => Attributes_ta_1._encode_Attributes, $.BER)(value.unauthenticatedAttributes, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_AuthenticatedData(value, elGetter);
}
exports._encode_AuthenticatedData = _encode_AuthenticatedData;
/* END_OF_SYMBOL_DEFINITION _encode_AuthenticatedData */
/* eslint-enable */
//# sourceMappingURL=AuthenticatedData.ta.js.map