| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.KeyUsage = exports.KeyUsageFlags = exports.id_ce_keyUsage = void 0;
- const asn1_schema_1 = require("@peculiar/asn1-schema");
- const object_identifiers_1 = require("../object_identifiers");
- exports.id_ce_keyUsage = `${object_identifiers_1.id_ce}.15`;
- var KeyUsageFlags;
- (function (KeyUsageFlags) {
- KeyUsageFlags[KeyUsageFlags["digitalSignature"] = 1] = "digitalSignature";
- KeyUsageFlags[KeyUsageFlags["nonRepudiation"] = 2] = "nonRepudiation";
- KeyUsageFlags[KeyUsageFlags["keyEncipherment"] = 4] = "keyEncipherment";
- KeyUsageFlags[KeyUsageFlags["dataEncipherment"] = 8] = "dataEncipherment";
- KeyUsageFlags[KeyUsageFlags["keyAgreement"] = 16] = "keyAgreement";
- KeyUsageFlags[KeyUsageFlags["keyCertSign"] = 32] = "keyCertSign";
- KeyUsageFlags[KeyUsageFlags["cRLSign"] = 64] = "cRLSign";
- KeyUsageFlags[KeyUsageFlags["encipherOnly"] = 128] = "encipherOnly";
- KeyUsageFlags[KeyUsageFlags["decipherOnly"] = 256] = "decipherOnly";
- })(KeyUsageFlags || (exports.KeyUsageFlags = KeyUsageFlags = {}));
- class KeyUsage extends asn1_schema_1.BitString {
- toJSON() {
- const flag = this.toNumber();
- const res = [];
- if (flag & KeyUsageFlags.cRLSign) {
- res.push("crlSign");
- }
- if (flag & KeyUsageFlags.dataEncipherment) {
- res.push("dataEncipherment");
- }
- if (flag & KeyUsageFlags.decipherOnly) {
- res.push("decipherOnly");
- }
- if (flag & KeyUsageFlags.digitalSignature) {
- res.push("digitalSignature");
- }
- if (flag & KeyUsageFlags.encipherOnly) {
- res.push("encipherOnly");
- }
- if (flag & KeyUsageFlags.keyAgreement) {
- res.push("keyAgreement");
- }
- if (flag & KeyUsageFlags.keyCertSign) {
- res.push("keyCertSign");
- }
- if (flag & KeyUsageFlags.keyEncipherment) {
- res.push("keyEncipherment");
- }
- if (flag & KeyUsageFlags.nonRepudiation) {
- res.push("nonRepudiation");
- }
- return res;
- }
- toString() {
- return `[${this.toJSON().join(", ")}]`;
- }
- }
- exports.KeyUsage = KeyUsage;
|