From 96fbaa35557d5cbcdbe42242fb5997a46349dbd3 Mon Sep 17 00:00:00 2001 From: farhadh Date: Thu, 16 Feb 2023 13:32:26 +0100 Subject: [PATCH 1/2] Let the user to specify the class of the tag --- lib/asn1/base/node.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/asn1/base/node.js b/lib/asn1/base/node.js index d676d21..82f90ec 100644 --- a/lib/asn1/base/node.js +++ b/lib/asn1/base/node.js @@ -575,7 +575,7 @@ Node.prototype._encodeValue = function encode(data, reporter, parent) { // Encode data itself if (!state.any && state.choice === null) { const tag = state.implicit !== null ? state.implicit : state.tag; - const cls = state.implicit === null ? 'universal' : 'context'; + const cls = state.cls ? state.cls : (state.implicit === null ? 'universal' : 'context'); if (tag === null) { if (state.use === null) From 5bde0f0f7b2b2a86a693e382847346f757fde742 Mon Sep 17 00:00:00 2001 From: farhadh Date: Thu, 9 Feb 2023 13:28:19 +0100 Subject: [PATCH 2/2] Added support for specifying class of the types. --- lib/asn1/base/node.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/asn1/base/node.js b/lib/asn1/base/node.js index 82f90ec..f6649d8 100644 --- a/lib/asn1/base/node.js +++ b/lib/asn1/base/node.js @@ -218,6 +218,14 @@ Node.prototype.implicit = function implicit(num) { return this; }; +Node.prototype.cls = function cls(cls) { + const state = this._baseState; + + state.cls = cls; + + return this; +}; + Node.prototype.obj = function obj() { const state = this._baseState; const args = Array.prototype.slice.call(arguments);