pkcs-ts
Version:
PKCS #1 through #15 (Except #11) - Private and Public Keys, Certificates, and More
75 lines • 4.69 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_KeyEncryptionKeyIdentifier = exports._decode_KeyEncryptionKeyIdentifier = exports._extension_additions_list_spec_for_KeyEncryptionKeyIdentifier = exports._root_component_type_list_2_spec_for_KeyEncryptionKeyIdentifier = exports._root_component_type_list_1_spec_for_KeyEncryptionKeyIdentifier = exports.KeyEncryptionKeyIdentifier = exports._encode_OtherKeyAttribute = exports._decode_OtherKeyAttribute = exports.OtherKeyAttribute = 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 OtherKeyAttribute_ta_1 = require("../PKCS7/OtherKeyAttribute.ta");
var OtherKeyAttribute_ta_2 = require("../PKCS7/OtherKeyAttribute.ta");
Object.defineProperty(exports, "OtherKeyAttribute", { enumerable: true, get: function () { return OtherKeyAttribute_ta_2.OtherKeyAttribute; } });
Object.defineProperty(exports, "_decode_OtherKeyAttribute", { enumerable: true, get: function () { return OtherKeyAttribute_ta_2._decode_OtherKeyAttribute; } });
Object.defineProperty(exports, "_encode_OtherKeyAttribute", { enumerable: true, get: function () { return OtherKeyAttribute_ta_2._encode_OtherKeyAttribute; } });
class KeyEncryptionKeyIdentifier {
constructor(keyIdentifier, date, otherKeyAttribute) {
this.keyIdentifier = keyIdentifier;
this.date = date;
this.otherKeyAttribute = otherKeyAttribute;
}
static _from_object(_o) {
return new KeyEncryptionKeyIdentifier(_o.keyIdentifier, _o.date, _o.otherKeyAttribute);
}
}
exports.KeyEncryptionKeyIdentifier = KeyEncryptionKeyIdentifier;
exports._root_component_type_list_1_spec_for_KeyEncryptionKeyIdentifier = [
new $.ComponentSpec("keyIdentifier", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined),
new $.ComponentSpec("date", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 24), undefined, undefined),
new $.ComponentSpec("otherKeyAttribute", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
];
exports._root_component_type_list_2_spec_for_KeyEncryptionKeyIdentifier = [];
exports._extension_additions_list_spec_for_KeyEncryptionKeyIdentifier = [];
let _cached_decoder_for_KeyEncryptionKeyIdentifier = null;
function _decode_KeyEncryptionKeyIdentifier(el) {
if (!_cached_decoder_for_KeyEncryptionKeyIdentifier) {
_cached_decoder_for_KeyEncryptionKeyIdentifier = function (el) {
let keyIdentifier;
let date;
let otherKeyAttribute;
const callbacks = {
keyIdentifier: (_el) => {
keyIdentifier = $._decodeOctetString(_el);
},
date: (_el) => {
date = $._decodeGeneralizedTime(_el);
},
otherKeyAttribute: (_el) => {
otherKeyAttribute = OtherKeyAttribute_ta_1._decode_OtherKeyAttribute(_el);
},
};
$._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_KeyEncryptionKeyIdentifier, exports._extension_additions_list_spec_for_KeyEncryptionKeyIdentifier, exports._root_component_type_list_2_spec_for_KeyEncryptionKeyIdentifier, undefined);
return new KeyEncryptionKeyIdentifier(keyIdentifier, date, otherKeyAttribute);
};
}
return _cached_decoder_for_KeyEncryptionKeyIdentifier(el);
}
exports._decode_KeyEncryptionKeyIdentifier = _decode_KeyEncryptionKeyIdentifier;
let _cached_encoder_for_KeyEncryptionKeyIdentifier = null;
function _encode_KeyEncryptionKeyIdentifier(value, elGetter) {
if (!_cached_encoder_for_KeyEncryptionKeyIdentifier) {
_cached_encoder_for_KeyEncryptionKeyIdentifier = function (value, elGetter) {
return $._encodeSequence([]
.concat([
$._encodeOctetString(value.keyIdentifier, $.BER),
value.date === undefined
? undefined
: $._encodeGeneralizedTime(value.date, $.BER),
value.otherKeyAttribute === undefined
? undefined
: OtherKeyAttribute_ta_1._encode_OtherKeyAttribute(value.otherKeyAttribute, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_KeyEncryptionKeyIdentifier(value, elGetter);
}
exports._encode_KeyEncryptionKeyIdentifier = _encode_KeyEncryptionKeyIdentifier;
//# sourceMappingURL=KeyEncryptionKeyIdentifier.ta.js.map