Comparing version 4.0.0 to 4.1.0
@@ -8,3 +8,3 @@ var Reporter = require('../base').Reporter; | ||
'seq', 'seqof', 'set', 'setof', 'octstr', 'bitstr', 'objid', 'bool', | ||
'gentime', 'utctime', 'null_', 'enum', 'int', 'ia5str', 'utf8str' | ||
'gentime', 'utctime', 'null_', 'enum', 'int', 'ia5str', 'utf8str', 'bmpstr' | ||
]; | ||
@@ -379,3 +379,3 @@ | ||
return this._decodeStr(input, tag); | ||
else if (tag === 'ia5str' || tag === 'utf8str') | ||
else if (tag === 'ia5str' || tag === 'utf8str' || tag === 'bmpstr') | ||
return this._decodeStr(input, tag); | ||
@@ -584,3 +584,3 @@ else if (tag === 'objid' && state.args) | ||
return this._encodeStr(data, tag); | ||
else if (tag === 'utf8str') | ||
else if (tag === 'utf8str' || tag === 'bmpstr') | ||
return this._encodeStr(data, tag); | ||
@@ -587,0 +587,0 @@ else if (tag === 'objid' && state.args) |
@@ -136,4 +136,14 @@ var inherits = require('inherits'); | ||
return buffer.raw().toString(); | ||
} 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 { | ||
return this.error('Decoding of string type: ' + tag + ' unsupported'); | ||
return buffer.error('Decoding of string type: ' + tag + ' unsupported'); | ||
} | ||
@@ -192,3 +202,3 @@ }; | ||
} else { | ||
return this.error('Decoding ' + tag + ' time is not supported yet'); | ||
return buffer.error('Decoding ' + tag + ' time is not supported yet'); | ||
} | ||
@@ -195,0 +205,0 @@ |
@@ -70,2 +70,9 @@ var inherits = require('inherits'); | ||
return this._createEncoderBuffer(str); | ||
else if (tag === 'bmpstr') { | ||
var buf = new Buffer(str.length * 2); | ||
for (var i = 0; i < str.length; i++) { | ||
buf.writeUInt16BE(str.charCodeAt(i), i * 2); | ||
} | ||
return this._createEncoderBuffer(buf); | ||
} | ||
return this.reporter.error('Encoding of string type: ' + tag + | ||
@@ -72,0 +79,0 @@ ' unsupported'); |
{ | ||
"name": "asn1.js", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "ASN.1 encoder and decoder", | ||
@@ -5,0 +5,0 @@ "main": "lib/asn1.js", |
@@ -78,2 +78,11 @@ var assert = require('assert'); | ||
}, '30800101ff0000', { 'key': true }); | ||
test('should decode bmpstr', function() { | ||
this.bmpstr(); | ||
}, '1e26004300650072007400690066006900630061' + | ||
'0074006500540065006d0070006c006100740065', 'CertificateTemplate'); | ||
test('should decode bmpstr with cyrillic chars', function() { | ||
this.bmpstr(); | ||
}, '1e0c041f04400438043204350442', 'Привет'); | ||
}); |
@@ -94,2 +94,11 @@ var assert = require('assert'); | ||
}, '1.2.398.3.10.1.1.1.2.2'.split('.'), '060a2a830e030a0101010202'); | ||
test('should properly encode bmpstr', function() { | ||
this.bmpstr(); | ||
}, 'CertificateTemplate', '1e26004300650072007400690066006900630061' + | ||
'0074006500540065006d0070006c006100740065'); | ||
test('should properly encode bmpstr with cyrillic chars', function() { | ||
this.bmpstr(); | ||
}, 'Привет', '1e0c041f04400438043204350442'); | ||
}); |
@@ -125,2 +125,6 @@ var assert = require('assert'); | ||
}, '', /tag of "int"/); | ||
test('bmpstr invalid length', function() { | ||
this.bmpstr(); | ||
}, '1e0b041f04400438043204350442', /bmpstr length mismatch/); | ||
}); | ||
@@ -127,0 +131,0 @@ |
@@ -44,2 +44,6 @@ var assert = require('assert'); | ||
test('bmpstr', function() { | ||
this.bmpstr(); | ||
}, 'hello'); | ||
test('gentime', function() { | ||
@@ -46,0 +50,0 @@ this.gentime(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
84974
2426