Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let the user to specify the class of the tag #136

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/asn1/base/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down