pkcs-ts
Version:
PKCS #1 through #15 (Except #11) - Private and Public Keys, Certificates, and More
91 lines • 7.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_EncryptedData = exports._decode_EncryptedData = exports._extension_additions_list_spec_for_EncryptedData = exports._root_component_type_list_2_spec_for_EncryptedData = exports._root_component_type_list_1_spec_for_EncryptedData = exports.EncryptedData = exports._encode_UnprotectedAttributes = exports._decode_UnprotectedAttributes = exports._encode_EncryptedContentInfo = exports._decode_EncryptedContentInfo = exports.EncryptedContentInfo = 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;
const tslib_1 = require("tslib");
const asn1_ts_1 = require("asn1-ts");
const $ = tslib_1.__importStar(require("asn1-ts/dist/node/functional"));
const CMSVersion_ta_1 = require("../CryptographicMessageSyntax/CMSVersion.ta");
const EncryptedContentInfo_ta_1 = require("../CryptographicMessageSyntax/EncryptedContentInfo.ta");
const UnprotectedAttributes_ta_1 = require("../CryptographicMessageSyntax/UnprotectedAttributes.ta");
var CMSVersion_ta_2 = require("../CryptographicMessageSyntax/CMSVersion.ta");
Object.defineProperty(exports, "CMSVersion_v0", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v0; } });
Object.defineProperty(exports, "CMSVersion_v1", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v1; } });
Object.defineProperty(exports, "CMSVersion_v2", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v2; } });
Object.defineProperty(exports, "CMSVersion_v3", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v3; } });
Object.defineProperty(exports, "CMSVersion_v4", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v4; } });
Object.defineProperty(exports, "v0", { enumerable: true, get: function () { return CMSVersion_ta_2.v0; } });
Object.defineProperty(exports, "v1", { enumerable: true, get: function () { return CMSVersion_ta_2.v1; } });
Object.defineProperty(exports, "v2", { enumerable: true, get: function () { return CMSVersion_ta_2.v2; } });
Object.defineProperty(exports, "v3", { enumerable: true, get: function () { return CMSVersion_ta_2.v3; } });
Object.defineProperty(exports, "v4", { enumerable: true, get: function () { return CMSVersion_ta_2.v4; } });
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 EncryptedContentInfo_ta_2 = require("../CryptographicMessageSyntax/EncryptedContentInfo.ta");
Object.defineProperty(exports, "EncryptedContentInfo", { enumerable: true, get: function () { return EncryptedContentInfo_ta_2.EncryptedContentInfo; } });
Object.defineProperty(exports, "_decode_EncryptedContentInfo", { enumerable: true, get: function () { return EncryptedContentInfo_ta_2._decode_EncryptedContentInfo; } });
Object.defineProperty(exports, "_encode_EncryptedContentInfo", { enumerable: true, get: function () { return EncryptedContentInfo_ta_2._encode_EncryptedContentInfo; } });
var UnprotectedAttributes_ta_2 = require("../CryptographicMessageSyntax/UnprotectedAttributes.ta");
Object.defineProperty(exports, "_decode_UnprotectedAttributes", { enumerable: true, get: function () { return UnprotectedAttributes_ta_2._decode_UnprotectedAttributes; } });
Object.defineProperty(exports, "_encode_UnprotectedAttributes", { enumerable: true, get: function () { return UnprotectedAttributes_ta_2._encode_UnprotectedAttributes; } });
class EncryptedData {
constructor(version, encryptedContentInfo, unprotectedAttrs) {
this.version = version;
this.encryptedContentInfo = encryptedContentInfo;
this.unprotectedAttrs = unprotectedAttrs;
}
static _from_object(_o) {
return new EncryptedData(_o.version, _o.encryptedContentInfo, _o.unprotectedAttrs);
}
}
exports.EncryptedData = EncryptedData;
exports._root_component_type_list_1_spec_for_EncryptedData = [
new $.ComponentSpec("version", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
new $.ComponentSpec("encryptedContentInfo", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("unprotectedAttrs", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 1), undefined, undefined),
];
exports._root_component_type_list_2_spec_for_EncryptedData = [];
exports._extension_additions_list_spec_for_EncryptedData = [];
let _cached_decoder_for_EncryptedData = null;
function _decode_EncryptedData(el) {
if (!_cached_decoder_for_EncryptedData) {
_cached_decoder_for_EncryptedData = function (el) {
let version;
let encryptedContentInfo;
let unprotectedAttrs;
const callbacks = {
version: (_el) => {
version = CMSVersion_ta_1._decode_CMSVersion(_el);
},
encryptedContentInfo: (_el) => {
encryptedContentInfo = EncryptedContentInfo_ta_1._decode_EncryptedContentInfo(_el);
},
unprotectedAttrs: (_el) => {
unprotectedAttrs = $._decode_implicit(() => UnprotectedAttributes_ta_1._decode_UnprotectedAttributes)(_el);
},
};
$._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_EncryptedData, exports._extension_additions_list_spec_for_EncryptedData, exports._root_component_type_list_2_spec_for_EncryptedData, undefined);
return new EncryptedData(version, encryptedContentInfo, unprotectedAttrs);
};
}
return _cached_decoder_for_EncryptedData(el);
}
exports._decode_EncryptedData = _decode_EncryptedData;
let _cached_encoder_for_EncryptedData = null;
function _encode_EncryptedData(value, elGetter) {
if (!_cached_encoder_for_EncryptedData) {
_cached_encoder_for_EncryptedData = function (value, elGetter) {
return $._encodeSequence([]
.concat([
CMSVersion_ta_1._encode_CMSVersion(value.version, $.BER),
EncryptedContentInfo_ta_1._encode_EncryptedContentInfo(value.encryptedContentInfo, $.BER),
value.unprotectedAttrs === undefined
? undefined
: $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 1, () => UnprotectedAttributes_ta_1._encode_UnprotectedAttributes, $.BER)(value.unprotectedAttrs, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_EncryptedData(value, elGetter);
}
exports._encode_EncryptedData = _encode_EncryptedData;
//# sourceMappingURL=EncryptedData.ta.js.map