pkcs-ts
Version:
PKCS #1 through #15 (Except #11) - Private and Public Keys, Certificates, and More
76 lines • 4.06 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 = void 0;
const tslib_1 = require("tslib");
const asn1_ts_1 = require("asn1-ts");
const $ = tslib_1.__importStar(require("asn1-ts/dist/node/functional"));
const HASH_ta_1 = require("x500-ts/dist/node/modules/AuthenticationFramework/HASH.ta");
const ContentInfo_ta_1 = require("../PKCS7/ContentInfo.ta");
const DigestAlgorithmIdentifier_ta_1 = require("../PKCS7/DigestAlgorithmIdentifier.ta");
const Version_ta_1 = require("../PKCS7/Version.ta");
class DigestedData {
constructor(version, digestAlgorithm, contentInfo, digest) {
this.version = version;
this.digestAlgorithm = digestAlgorithm;
this.contentInfo = contentInfo;
this.digest = digest;
}
static _from_object(_o) {
return new DigestedData(_o.version, _o.digestAlgorithm, _o.contentInfo, _o.digest);
}
}
exports.DigestedData = DigestedData;
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("contentInfo", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("digest", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
];
exports._root_component_type_list_2_spec_for_DigestedData = [];
exports._extension_additions_list_spec_for_DigestedData = [];
let _cached_decoder_for_DigestedData = null;
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 = "contentInfo";
sequence[3].name = "digest";
let version;
let digestAlgorithm;
let contentInfo;
let digest;
version = Version_ta_1._decode_Version(sequence[0]);
digestAlgorithm = DigestAlgorithmIdentifier_ta_1._decode_DigestAlgorithmIdentifier(sequence[1]);
contentInfo = ContentInfo_ta_1._decode_ContentInfo(sequence[2]);
digest = HASH_ta_1._get_decoder_for_HASH($._decodeAny)(sequence[3]);
return new DigestedData(version, digestAlgorithm, contentInfo, digest);
};
}
return _cached_decoder_for_DigestedData(el);
}
exports._decode_DigestedData = _decode_DigestedData;
let _cached_encoder_for_DigestedData = null;
function _encode_DigestedData(value, elGetter) {
if (!_cached_encoder_for_DigestedData) {
_cached_encoder_for_DigestedData = function (value, elGetter) {
return $._encodeSequence([]
.concat([
Version_ta_1._encode_Version(value.version, $.BER),
DigestAlgorithmIdentifier_ta_1._encode_DigestAlgorithmIdentifier(value.digestAlgorithm, $.BER),
ContentInfo_ta_1._encode_ContentInfo(value.contentInfo, $.BER),
HASH_ta_1._get_encoder_for_HASH($._encodeAny)(value.digest, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_DigestedData(value, elGetter);
}
exports._encode_DigestedData = _encode_DigestedData;
//# sourceMappingURL=DigestedData.ta.js.map