@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
206 lines • 11.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_DigestedData = exports._decode_DigestedData = exports._extension_additions_list_spec_for_DigestedData = exports._root_component_type_list_2_spec_for_DigestedData = exports._root_component_type_list_1_spec_for_DigestedData = exports.DigestedData = exports._encode_EncapsulatedContentInfo = exports._decode_EncapsulatedContentInfo = exports.EncapsulatedContentInfo = exports._encode_DigestAlgorithmIdentifier = exports._decode_DigestAlgorithmIdentifier = exports._encode_Digest = exports._decode_Digest = exports._encode_CMSVersion = exports._decode_CMSVersion = exports.v4 = exports.v3 = exports.v2 = exports.v1 = exports.v0 = exports.CMSVersion_v4 = exports.CMSVersion_v3 = exports.CMSVersion_v2 = exports.CMSVersion_v1 = exports.CMSVersion_v0 = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
const CMSVersion_ta_1 = require("../CryptographicMessageSyntax/CMSVersion.ta");
const Digest_ta_1 = require("../CryptographicMessageSyntax/Digest.ta");
const DigestAlgorithmIdentifier_ta_1 = require("../CryptographicMessageSyntax/DigestAlgorithmIdentifier.ta");
const EncapsulatedContentInfo_ta_1 = require("../CryptographicMessageSyntax/EncapsulatedContentInfo.ta");
var CMSVersion_ta_2 = require("../CryptographicMessageSyntax/CMSVersion.ta");
Object.defineProperty(exports, "CMSVersion_v0", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v0; } }); /* IMPORTED_LONG_NAMED_INTEGER */
Object.defineProperty(exports, "CMSVersion_v1", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v1; } }); /* IMPORTED_LONG_NAMED_INTEGER */
Object.defineProperty(exports, "CMSVersion_v2", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v2; } }); /* IMPORTED_LONG_NAMED_INTEGER */
Object.defineProperty(exports, "CMSVersion_v3", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v3; } }); /* IMPORTED_LONG_NAMED_INTEGER */
Object.defineProperty(exports, "CMSVersion_v4", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v4; } }); /* IMPORTED_LONG_NAMED_INTEGER */
Object.defineProperty(exports, "v0", { enumerable: true, get: function () { return CMSVersion_ta_2.v0; } }); /* IMPORTED_SHORT_NAMED_INTEGER */
Object.defineProperty(exports, "v1", { enumerable: true, get: function () { return CMSVersion_ta_2.v1; } }); /* IMPORTED_SHORT_NAMED_INTEGER */
Object.defineProperty(exports, "v2", { enumerable: true, get: function () { return CMSVersion_ta_2.v2; } }); /* IMPORTED_SHORT_NAMED_INTEGER */
Object.defineProperty(exports, "v3", { enumerable: true, get: function () { return CMSVersion_ta_2.v3; } }); /* IMPORTED_SHORT_NAMED_INTEGER */
Object.defineProperty(exports, "v4", { enumerable: true, get: function () { return CMSVersion_ta_2.v4; } }); /* IMPORTED_SHORT_NAMED_INTEGER */
Object.defineProperty(exports, "_decode_CMSVersion", { enumerable: true, get: function () { return CMSVersion_ta_2._decode_CMSVersion; } });
Object.defineProperty(exports, "_encode_CMSVersion", { enumerable: true, get: function () { return CMSVersion_ta_2._encode_CMSVersion; } });
var Digest_ta_2 = require("../CryptographicMessageSyntax/Digest.ta");
Object.defineProperty(exports, "_decode_Digest", { enumerable: true, get: function () { return Digest_ta_2._decode_Digest; } });
Object.defineProperty(exports, "_encode_Digest", { enumerable: true, get: function () { return Digest_ta_2._encode_Digest; } });
var DigestAlgorithmIdentifier_ta_2 = require("../CryptographicMessageSyntax/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 EncapsulatedContentInfo_ta_2 = require("../CryptographicMessageSyntax/EncapsulatedContentInfo.ta");
Object.defineProperty(exports, "EncapsulatedContentInfo", { enumerable: true, get: function () { return EncapsulatedContentInfo_ta_2.EncapsulatedContentInfo; } });
Object.defineProperty(exports, "_decode_EncapsulatedContentInfo", { enumerable: true, get: function () { return EncapsulatedContentInfo_ta_2._decode_EncapsulatedContentInfo; } });
Object.defineProperty(exports, "_encode_EncapsulatedContentInfo", { enumerable: true, get: function () { return EncapsulatedContentInfo_ta_2._encode_EncapsulatedContentInfo; } });
/* START_OF_SYMBOL_DEFINITION DigestedData */
/**
* @summary DigestedData
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* DigestedData ::= SEQUENCE {
* version CMSVersion,
* digestAlgorithm DigestAlgorithmIdentifier,
* encapContentInfo EncapsulatedContentInfo,
* digest Digest
* }
* ```
*
* @class
*/
class DigestedData {
constructor(
/**
* @summary `version`.
* @public
* @readonly
*/
version,
/**
* @summary `digestAlgorithm`.
* @public
* @readonly
*/
digestAlgorithm,
/**
* @summary `encapContentInfo`.
* @public
* @readonly
*/
encapContentInfo,
/**
* @summary `digest`.
* @public
* @readonly
*/
digest) {
this.version = version;
this.digestAlgorithm = digestAlgorithm;
this.encapContentInfo = encapContentInfo;
this.digest = digest;
}
/**
* @summary Restructures an object into a DigestedData
* @description
*
* This takes an `object` and converts it to a `DigestedData`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `DigestedData`.
* @returns {DigestedData}
*/
static _from_object(_o) {
return new DigestedData(_o.version, _o.digestAlgorithm, _o.encapContentInfo, _o.digest);
}
}
exports.DigestedData = DigestedData;
/* END_OF_SYMBOL_DEFINITION DigestedData */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_DigestedData */
/**
* @summary The Leading Root Component Types of DigestedData
* @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_DigestedData = [
new $.ComponentSpec("version", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
new $.ComponentSpec("digestAlgorithm", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("encapContentInfo", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("digest", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_DigestedData */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_DigestedData */
/**
* @summary The Trailing Root Component Types of DigestedData
* @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_DigestedData = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_DigestedData */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_DigestedData */
/**
* @summary The Extension Addition Component Types of DigestedData
* @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_DigestedData = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_DigestedData */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_DigestedData */
let _cached_decoder_for_DigestedData = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_DigestedData */
/* START_OF_SYMBOL_DEFINITION _decode_DigestedData */
/**
* @summary Decodes an ASN.1 element into a(n) DigestedData
* @function
* @param {_Element} el The element being decoded.
* @returns {DigestedData} The decoded data structure.
*/
function _decode_DigestedData(el) {
if (!_cached_decoder_for_DigestedData) {
_cached_decoder_for_DigestedData = function (el) {
const sequence = el.sequence;
if (sequence.length < 4) {
throw new asn1_ts_1.ASN1ConstructionError("DigestedData contained only " +
sequence.length.toString() +
" elements.");
}
sequence[0].name = "version";
sequence[1].name = "digestAlgorithm";
sequence[2].name = "encapContentInfo";
sequence[3].name = "digest";
let version;
let digestAlgorithm;
let encapContentInfo;
let digest;
version = CMSVersion_ta_1._decode_CMSVersion(sequence[0]);
digestAlgorithm = DigestAlgorithmIdentifier_ta_1._decode_DigestAlgorithmIdentifier(sequence[1]);
encapContentInfo = EncapsulatedContentInfo_ta_1._decode_EncapsulatedContentInfo(sequence[2]);
digest = Digest_ta_1._decode_Digest(sequence[3]);
return new DigestedData(version, digestAlgorithm, encapContentInfo, digest);
};
}
return _cached_decoder_for_DigestedData(el);
}
exports._decode_DigestedData = _decode_DigestedData;
/* END_OF_SYMBOL_DEFINITION _decode_DigestedData */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_DigestedData */
let _cached_encoder_for_DigestedData = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_DigestedData */
/* START_OF_SYMBOL_DEFINITION _encode_DigestedData */
/**
* @summary Encodes a(n) DigestedData 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 DigestedData, encoded as an ASN.1 Element.
*/
function _encode_DigestedData(value, elGetter) {
if (!_cached_encoder_for_DigestedData) {
_cached_encoder_for_DigestedData = function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ CMSVersion_ta_1._encode_CMSVersion(value.version, $.BER),
/* REQUIRED */ DigestAlgorithmIdentifier_ta_1._encode_DigestAlgorithmIdentifier(value.digestAlgorithm, $.BER),
/* REQUIRED */ EncapsulatedContentInfo_ta_1._encode_EncapsulatedContentInfo(value.encapContentInfo, $.BER),
/* REQUIRED */ Digest_ta_1._encode_Digest(value.digest, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_DigestedData(value, elGetter);
}
exports._encode_DigestedData = _encode_DigestedData;
/* END_OF_SYMBOL_DEFINITION _encode_DigestedData */
/* eslint-enable */
//# sourceMappingURL=DigestedData.ta.js.map