Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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 4.1.0 to 4.2.0

15

lib/asn1/base/node.js

@@ -8,3 +8,4 @@ var Reporter = require('../base').Reporter;

'seq', 'seqof', 'set', 'setof', 'octstr', 'bitstr', 'objid', 'bool',
'gentime', 'utctime', 'null_', 'enum', 'int', 'ia5str', 'utf8str', 'bmpstr'
'gentime', 'utctime', 'null_', 'enum', 'int', 'ia5str', 'utf8str', 'bmpstr',
'numstr', 'printstr'
];

@@ -381,2 +382,4 @@

return this._decodeStr(input, tag);
else if (tag === 'numstr' || tag === 'printstr')
return this._decodeStr(input, tag);
else if (tag === 'objid' && state.args)

@@ -586,2 +589,4 @@ return this._decodeObjid(input, state.args[0], state.args[1]);

return this._encodeStr(data, tag);
else if (tag === 'numstr' || tag === 'printstr')
return this._encodeStr(data, tag);
else if (tag === 'objid' && state.args)

@@ -602,1 +607,9 @@ return this._encodeObjid(data, state.reverseArgs[0], state.args[1]);

};
Node.prototype._isNumstr = function isNumstr(str) {
return /^[1-9 ]*$/.test(str);
};
Node.prototype._isPrintstr = function isPrintstr(str) {
return /^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(str);
};

@@ -136,2 +136,18 @@ var inherits = require('inherits');

return buffer.raw().toString();
} else if(tag === 'numstr') {
var numstr = buffer.raw().toString('ascii');
if (!this._isNumstr(numstr)) {
return buffer.error('Decoding of string type: ' +
'numstr unsupported characters');
}
return numstr;
} else if (tag === 'printstr') {
var printstr = buffer.raw().toString('ascii');
if (!this._isPrintstr(printstr)) {
return buffer.error('Decoding of string type: ' +
'printstr unsupported characters');
}
return printstr;
} else if(tag === 'bmpstr') {

@@ -138,0 +154,0 @@ var raw = buffer.raw();

@@ -64,9 +64,9 @@ var inherits = require('inherits');

DERNode.prototype._encodeStr = function encodeStr(str, tag) {
if (tag === 'octstr')
if (tag === 'octstr') {
return this._createEncoderBuffer(str);
else if (tag === 'bitstr')
} else if (tag === 'bitstr') {
return this._createEncoderBuffer([ str.unused | 0, str.data ]);
else if (tag === 'ia5str' || tag === 'utf8str')
} else if (tag === 'ia5str' || tag === 'utf8str') {
return this._createEncoderBuffer(str);
else if (tag === 'bmpstr') {
} else if (tag === 'bmpstr') {
var buf = new Buffer(str.length * 2);

@@ -77,5 +77,24 @@ for (var i = 0; i < str.length; i++) {

return this._createEncoderBuffer(buf);
} else if (tag === 'numstr') {
if (!this._isNumstr(str)) {
return this.reporter.error('Encoding of string type: numstr supports ' +
'only digits and space');
}
return this._createEncoderBuffer(str);
} else if (tag === 'printstr') {
if (!this._isPrintstr(str)) {
return this.reporter.error('Encoding of string type: printstr supports ' +
'only latin upper and lower case letters, ' +
'digits, space, apostrophe, left and rigth ' +
'parenthesis, plus sign, comma, hyphen, ' +
'dot, slash, colon, equal sign, ' +
'question mark');
}
return this._createEncoderBuffer(str);
} else {
return this.reporter.error('Encoding of string type: ' + tag +
' unsupported');
}
return this.reporter.error('Encoding of string type: ' + tag +
' unsupported');
};

@@ -82,0 +101,0 @@

4

package.json
{
"name": "asn1.js",
"version": "4.1.0",
"version": "4.2.0",
"description": "ASN.1 encoder and decoder",

@@ -24,3 +24,3 @@ "main": "lib/asn1.js",

"devDependencies": {
"mocha": "^1.14.0"
"mocha": "^2.3.4"
},

@@ -27,0 +27,0 @@ "dependencies": {

@@ -43,2 +43,10 @@ var assert = require('assert');

}, 1, /objid\(\) should be either array or string, got: 1/);
test('numstr', function() {
this.numstr();
}, 'hello', /only digits and space/);
test('printstr', function() {
this.printstr();
}, 'hello!', /only latin upper and lower case letters/);
});

@@ -130,2 +138,10 @@

}, '1e0b041f04400438043204350442', /bmpstr length mismatch/);
test('numstr unsupported characters', function() {
this.numstr();
}, '12024141', /numstr unsupported characters/);
test('printstr unsupported characters', function() {
this.printstr();
}, '13024121', /printstr unsupported characters/);
});

@@ -132,0 +148,0 @@

@@ -48,2 +48,10 @@ var assert = require('assert');

test('numstr', function() {
this.numstr();
}, '1234 5678');
test('printstr', function() {
this.printstr();
}, 'hello');
test('gentime', function() {

@@ -50,0 +58,0 @@ this.gentime();

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