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.4.0 to 4.5.0

rfc/5280/index.js

19

lib/asn1/base/node.js

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

var tags = [
'seq', 'seqof', 'set', 'setof', 'octstr', 'bitstr', 'objid', 'bool',
'gentime', 'utctime', 'null_', 'enum', 'int', 'ia5str', 'utf8str', 'bmpstr',
'numstr', 'printstr'
'seq', 'seqof', 'set', 'setof', 'objid', 'bool',
'gentime', 'utctime', 'null_', 'enum', 'int',
'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str',
'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr'
];

@@ -395,8 +396,4 @@

return this._decodeList(input, tag, state.args[0]);
else if (tag === 'octstr' || tag === 'bitstr')
else if (/str$/.test(tag))
return this._decodeStr(input, tag);
else if (tag === 'ia5str' || tag === 'utf8str' || tag === 'bmpstr')
return this._decodeStr(input, tag);
else if (tag === 'numstr' || tag === 'printstr')
return this._decodeStr(input, tag);
else if (tag === 'objid' && state.args)

@@ -604,8 +601,4 @@ return this._decodeObjid(input, state.args[0], state.args[1]);

if (tag === 'octstr' || tag === 'bitstr' || tag === 'ia5str')
if (/str$/.test(tag))
return this._encodeStr(data, tag);
else if (tag === 'utf8str' || tag === 'bmpstr')
return this._encodeStr(data, tag);
else if (tag === 'numstr' || tag === 'printstr')
return this._encodeStr(data, tag);
else if (tag === 'objid' && state.args)

@@ -612,0 +605,0 @@ return this._encodeObjid(data, state.reverseArgs[0], state.args[1]);

@@ -126,13 +126,18 @@ var inherits = require('inherits');

DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {
if (tag === 'octstr') {
return buffer.raw();
} else if (tag === 'bitstr') {
if (tag === 'bitstr') {
var unused = buffer.readUInt8();
if (buffer.isError(unused))
return unused;
return { unused: unused, data: buffer.raw() };
} else if (tag === 'bmpstr') {
var raw = buffer.raw();
if (raw.length % 2 === 1)
return buffer.error('Decoding of string type: bmpstr length mismatch');
return { unused: unused, data: buffer.raw() };
} else if (tag === 'ia5str' || tag === 'utf8str') {
return buffer.raw().toString();
} else if(tag === 'numstr') {
var str = '';
for (var i = 0; i < raw.length / 2; i++) {
str += String.fromCharCode(raw.readUInt16BE(i * 2));
}
return str;
} else if (tag === 'numstr') {
var numstr = buffer.raw().toString('ascii');

@@ -143,4 +148,5 @@ if (!this._isNumstr(numstr)) {

}
return numstr;
} else if (tag === 'octstr') {
return buffer.raw();
} else if (tag === 'printstr') {

@@ -152,14 +158,5 @@ var printstr = buffer.raw().toString('ascii');

}
return printstr;
} else if(tag === 'bmpstr') {
var raw = buffer.raw();
if (raw.length % 2 === 1)
return buffer.error('Decoding of string type: bmpstr length mismatch');
var str = '';
for (var i = 0; i < raw.length / 2; i++) {
str += String.fromCharCode(raw.readUInt16BE(i * 2));
}
return str;
} else if (/str$/.test(tag)) {
return buffer.raw().toString();
} else {

@@ -166,0 +163,0 @@ return buffer.error('Decoding of string type: ' + tag + ' unsupported');

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

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

@@ -82,3 +78,2 @@ var buf = new Buffer(str.length * 2);

}
return this._createEncoderBuffer(str);

@@ -94,4 +89,5 @@ } else if (tag === 'printstr') {

}
return this._createEncoderBuffer(str);
} else if (/str$/.test(tag)) {
return this._createEncoderBuffer(str);
} else {

@@ -98,0 +94,0 @@ return this.reporter.error('Encoding of string type: ' + tag +

{
"name": "asn1.js",
"version": "4.4.0",
"version": "4.5.0",
"description": "ASN.1 encoder and decoder",

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

try {
var asn1 = require('asn1.js');
var rfc3280 = require('asn1.js-rfc3280');
var rfc5280 = require('asn1.js-rfc5280');
} catch (e) {
var asn1 = require('../' + '..');
var rfc3280 = require('../' + '3280');
var rfc5280 = require('../' + '5280');
}

@@ -19,6 +19,6 @@

this.seq().obj(
this.key('version').def('v1').explicit(0).use(rfc3280.Version),
this.key('requestorName').optional().explicit(1).use(rfc3280.GeneralName),
this.key('version').def('v1').explicit(0).use(rfc5280.Version),
this.key('requestorName').optional().explicit(1).use(rfc5280.GeneralName),
this.key('requestList').seqof(Request),
this.key('requestExtensions').optional().explicit(2).use(rfc3280.Extensions)
this.key('requestExtensions').optional().explicit(2).use(rfc5280.Extensions)
);

@@ -30,5 +30,5 @@ });

this.seq().obj(
this.key('signatureAlgorithm').use(rfc3280.AlgorithmIdentifier),
this.key('signatureAlgorithm').use(rfc5280.AlgorithmIdentifier),
this.key('signature').bitstr(),
this.key('certs').optional().explicit(0).seqof(rfc3280.Certificate)
this.key('certs').optional().explicit(0).seqof(rfc5280.Certificate)
);

@@ -42,3 +42,3 @@ });

this.key('singleRequestExtensions').optional().explicit(0).use(
rfc3280.Extensions)
rfc5280.Extensions)
);

@@ -76,5 +76,5 @@ });

this.key('tbsResponseData').use(ResponseData),
this.key('signatureAlgorithm').use(rfc3280.AlgorithmIdentifier),
this.key('signatureAlgorithm').use(rfc5280.AlgorithmIdentifier),
this.key('signature').bitstr(),
this.key('certs').optional().explicit(0).seqof(rfc3280.Certificate)
this.key('certs').optional().explicit(0).seqof(rfc5280.Certificate)
);

@@ -86,3 +86,3 @@ });

this.seq().obj(
this.key('version').def('v1').explicit(0).use(rfc3280.Version),
this.key('version').def('v1').explicit(0).use(rfc5280.Version),
this.key('responderID').use(ResponderID),

@@ -92,3 +92,3 @@ this.key('producedAt').gentime(),

this.key('responseExtensions').optional().explicit(0)
.use(rfc3280.Extensions)
.use(rfc5280.Extensions)
);

@@ -100,3 +100,3 @@ });

this.choice({
byName: this.explicit(1).use(rfc3280.Name),
byName: this.explicit(1).use(rfc5280.Name),
byKey: this.explicit(2).use(KeyHash)

@@ -118,3 +118,3 @@ });

this.key('nextUpdate').optional().explicit(0).gentime(),
this.key('singleExtensions').optional().explicit(1).use(rfc3280.Extensions)
this.key('singleExtensions').optional().explicit(1).use(rfc5280.Extensions)
);

@@ -136,3 +136,3 @@ });

this.key('revocationTime').gentime(),
this.key('revocationReason').optional().explicit(0).use(rfc3280.CRLReason)
this.key('revocationReason').optional().explicit(0).use(rfc5280.CRLReason)
);

@@ -144,6 +144,6 @@ });

this.seq().obj(
this.key('hashAlgorithm').use(rfc3280.AlgorithmIdentifier),
this.key('hashAlgorithm').use(rfc5280.AlgorithmIdentifier),
this.key('issuerNameHash').octstr(),
this.key('issuerKeyHash').octstr(),
this.key('serialNumber').use(rfc3280.CertificateSerialNumber)
this.key('serialNumber').use(rfc5280.CertificateSerialNumber)
);

@@ -150,0 +150,0 @@ });

@@ -22,7 +22,7 @@ {

"dependencies": {
"asn1.js-rfc3280": "^4.0.0"
"asn1.js-rfc5280": "^4.4.0"
},
"peerDependencies": {
"asn1.js": "^4.0.0"
"asn1.js": "^4.4.0"
}
}

@@ -107,2 +107,18 @@ var assert = require('assert');

});
test('should decode IA5 string', function() {
this.ia5str();
}, '160C646F6720616E6420626F6E65', 'dog and bone');
test('should decode printable string', function() {
this.printstr();
}, '1310427261686D7320616E64204C69737A74', 'Brahms and Liszt');
test('should decode T61 string', function() {
this.t61str();
}, '140C4F6C69766572205477697374', 'Oliver Twist');
test('should decode ISO646 string', function() {
this.iso646str();
}, '1A0B7365707469632074616E6B', 'septic tank');
});

@@ -117,2 +117,18 @@ var assert = require('assert');

});
test('should properly encode IA5 string', function() {
this.ia5str();
}, 'dog and bone', '160C646F6720616E6420626F6E65');
test('should properly encode printable string', function() {
this.printstr();
}, 'Brahms and Liszt', '1310427261686D7320616E64204C69737A74');
test('should properly encode T61 string', function() {
this.t61str();
}, 'Oliver Twist', '140C4F6C69766572205477697374');
test('should properly encode ISO646 string', function() {
this.iso646str();
}, 'septic tank', '1A0B7365707469632074616E6B');
});
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