@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
185 lines • 9.62 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_EncryptedContentInfo = exports._decode_EncryptedContentInfo = exports._extension_additions_list_spec_for_EncryptedContentInfo = exports._root_component_type_list_2_spec_for_EncryptedContentInfo = exports._root_component_type_list_1_spec_for_EncryptedContentInfo = exports.EncryptedContentInfo = exports._encode_EncryptedContent = exports._decode_EncryptedContent = exports._encode_ContentType = exports._decode_ContentType = exports._encode_ContentEncryptionAlgorithmIdentifier = exports._decode_ContentEncryptionAlgorithmIdentifier = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
const ContentEncryptionAlgorithmIdentifier_ta_1 = require("../CryptographicMessageSyntax/ContentEncryptionAlgorithmIdentifier.ta");
const ContentType_ta_1 = require("../CryptographicMessageSyntax/ContentType.ta");
const EncryptedContent_ta_1 = require("../CryptographicMessageSyntax/EncryptedContent.ta");
var ContentEncryptionAlgorithmIdentifier_ta_2 = require("../CryptographicMessageSyntax/ContentEncryptionAlgorithmIdentifier.ta");
Object.defineProperty(exports, "_decode_ContentEncryptionAlgorithmIdentifier", { enumerable: true, get: function () { return ContentEncryptionAlgorithmIdentifier_ta_2._decode_ContentEncryptionAlgorithmIdentifier; } });
Object.defineProperty(exports, "_encode_ContentEncryptionAlgorithmIdentifier", { enumerable: true, get: function () { return ContentEncryptionAlgorithmIdentifier_ta_2._encode_ContentEncryptionAlgorithmIdentifier; } });
var ContentType_ta_2 = require("../CryptographicMessageSyntax/ContentType.ta");
Object.defineProperty(exports, "_decode_ContentType", { enumerable: true, get: function () { return ContentType_ta_2._decode_ContentType; } });
Object.defineProperty(exports, "_encode_ContentType", { enumerable: true, get: function () { return ContentType_ta_2._encode_ContentType; } });
var EncryptedContent_ta_2 = require("../CryptographicMessageSyntax/EncryptedContent.ta");
Object.defineProperty(exports, "_decode_EncryptedContent", { enumerable: true, get: function () { return EncryptedContent_ta_2._decode_EncryptedContent; } });
Object.defineProperty(exports, "_encode_EncryptedContent", { enumerable: true, get: function () { return EncryptedContent_ta_2._encode_EncryptedContent; } });
/* START_OF_SYMBOL_DEFINITION EncryptedContentInfo */
/**
* @summary EncryptedContentInfo
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* EncryptedContentInfo ::= SEQUENCE {
* contentType ContentType,
* contentEncryptionAlgorithm ContentEncryptionAlgorithmIdentifier,
* encryptedContent [0] IMPLICIT EncryptedContent OPTIONAL
* }
* ```
*
* @class
*/
class EncryptedContentInfo {
constructor(
/**
* @summary `contentType`.
* @public
* @readonly
*/
contentType,
/**
* @summary `contentEncryptionAlgorithm`.
* @public
* @readonly
*/
contentEncryptionAlgorithm,
/**
* @summary `encryptedContent`.
* @public
* @readonly
*/
encryptedContent) {
this.contentType = contentType;
this.contentEncryptionAlgorithm = contentEncryptionAlgorithm;
this.encryptedContent = encryptedContent;
}
/**
* @summary Restructures an object into a EncryptedContentInfo
* @description
*
* This takes an `object` and converts it to a `EncryptedContentInfo`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `EncryptedContentInfo`.
* @returns {EncryptedContentInfo}
*/
static _from_object(_o) {
return new EncryptedContentInfo(_o.contentType, _o.contentEncryptionAlgorithm, _o.encryptedContent);
}
}
exports.EncryptedContentInfo = EncryptedContentInfo;
/* END_OF_SYMBOL_DEFINITION EncryptedContentInfo */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_EncryptedContentInfo */
/**
* @summary The Leading Root Component Types of EncryptedContentInfo
* @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_EncryptedContentInfo = [
new $.ComponentSpec("contentType", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 6), undefined, undefined),
new $.ComponentSpec("contentEncryptionAlgorithm", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("encryptedContent", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_EncryptedContentInfo */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_EncryptedContentInfo */
/**
* @summary The Trailing Root Component Types of EncryptedContentInfo
* @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_EncryptedContentInfo = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_EncryptedContentInfo */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_EncryptedContentInfo */
/**
* @summary The Extension Addition Component Types of EncryptedContentInfo
* @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_EncryptedContentInfo = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_EncryptedContentInfo */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_EncryptedContentInfo */
let _cached_decoder_for_EncryptedContentInfo = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_EncryptedContentInfo */
/* START_OF_SYMBOL_DEFINITION _decode_EncryptedContentInfo */
/**
* @summary Decodes an ASN.1 element into a(n) EncryptedContentInfo
* @function
* @param {_Element} el The element being decoded.
* @returns {EncryptedContentInfo} The decoded data structure.
*/
function _decode_EncryptedContentInfo(el) {
if (!_cached_decoder_for_EncryptedContentInfo) {
_cached_decoder_for_EncryptedContentInfo = function (el) {
/* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */
let contentType;
let contentEncryptionAlgorithm;
let encryptedContent;
/* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */
/* START_OF_CALLBACKS_MAP */
const callbacks = {
contentType: (_el) => {
contentType = ContentType_ta_1._decode_ContentType(_el);
},
contentEncryptionAlgorithm: (_el) => {
contentEncryptionAlgorithm = ContentEncryptionAlgorithmIdentifier_ta_1._decode_ContentEncryptionAlgorithmIdentifier(_el);
},
encryptedContent: (_el) => {
encryptedContent = $._decode_implicit(() => EncryptedContent_ta_1._decode_EncryptedContent)(_el);
},
};
/* END_OF_CALLBACKS_MAP */
$._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_EncryptedContentInfo, exports._extension_additions_list_spec_for_EncryptedContentInfo, exports._root_component_type_list_2_spec_for_EncryptedContentInfo, undefined);
return new EncryptedContentInfo(
/* SEQUENCE_CONSTRUCTOR_CALL */ contentType, contentEncryptionAlgorithm, encryptedContent);
};
}
return _cached_decoder_for_EncryptedContentInfo(el);
}
exports._decode_EncryptedContentInfo = _decode_EncryptedContentInfo;
/* END_OF_SYMBOL_DEFINITION _decode_EncryptedContentInfo */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_EncryptedContentInfo */
let _cached_encoder_for_EncryptedContentInfo = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_EncryptedContentInfo */
/* START_OF_SYMBOL_DEFINITION _encode_EncryptedContentInfo */
/**
* @summary Encodes a(n) EncryptedContentInfo 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 EncryptedContentInfo, encoded as an ASN.1 Element.
*/
function _encode_EncryptedContentInfo(value, elGetter) {
if (!_cached_encoder_for_EncryptedContentInfo) {
_cached_encoder_for_EncryptedContentInfo = function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ ContentType_ta_1._encode_ContentType(value.contentType, $.BER),
/* REQUIRED */ ContentEncryptionAlgorithmIdentifier_ta_1._encode_ContentEncryptionAlgorithmIdentifier(value.contentEncryptionAlgorithm, $.BER),
/* IF_ABSENT */ value.encryptedContent === undefined
? undefined
: $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => EncryptedContent_ta_1._encode_EncryptedContent, $.BER)(value.encryptedContent, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_EncryptedContentInfo(value, elGetter);
}
exports._encode_EncryptedContentInfo = _encode_EncryptedContentInfo;
/* END_OF_SYMBOL_DEFINITION _encode_EncryptedContentInfo */
/* eslint-enable */
//# sourceMappingURL=EncryptedContentInfo.ta.js.map