diff --git a/lib/asn1/base/node.js b/lib/asn1/base/node.js index d676d21..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); @@ -575,7 +583,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)