Socket
Socket
Sign inDemoInstall

asn1.js

Package Overview
Dependencies
Maintainers
2
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asn1.js - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2

36

lib/asn1/base/node.js

@@ -274,11 +274,29 @@ var Reporter = require('../base').Reporter;

if (state.optional) {
present = this._peekTag(
input,
state.explicit !== null ? state.explicit :
state.implicit !== null ? state.implicit :
state.tag || 0,
state.any
);
if (input.isError(present))
return present;
var tag = null;
if (state.explicit !== null)
tag = state.explicit;
else if (state.implicit !== null)
tag = state.implicit;
else if (state.tag !== null)
tag = state.tag;
if (tag === null && !state.any) {
// Trial and Error
var save = input.save();
try {
if (state.choice === null)
this._decodeGeneric(state.tag, input);
else
this._decodeChoice(input);
present = true;
} catch (e) {
present = false;
}
input.restore(save);
} else {
present = this._peekTag(input, tag, state.any);
if (input.isError(present))
return present;
}
}

@@ -285,0 +303,0 @@

{
"name": "asn1.js",
"version": "2.1.1",
"version": "2.1.2",
"description": "ASN.1 encoder and decoder",

@@ -5,0 +5,0 @@ "main": "lib/asn1.js",

@@ -60,2 +60,14 @@ var assert = require('assert');

it('should decode optional and use', function() {
var B = asn1.define('B', function() {
this.int();
});
var A = asn1.define('A', function() {
this.optional().use(B);
});
var out = A.decode(new Buffer('020101', 'hex'), 'der');
assert.equal(out.toString(10), '1');
});
});

@@ -71,2 +71,15 @@ var assert = require('assert');

}, {required: false, value: 1}, '3003020101');
it('should encode optional and use', function() {
var B = asn1.define('B', function() {
this.int();
});
var A = asn1.define('A', function() {
this.optional().use(B);
});
var out = A.encode(1, 'der');
assert.equal(out.toString('hex'), '020101');
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc