[Pkg-javascript-commits] [node-asn1.js] 58/202: der: support `ia5str`
Bastien Roucariès
rouca at moszumanska.debian.org
Thu Apr 20 19:18:54 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-asn1.js.
commit 49e203f28e641ecbd4845f6dfb977961f4997553
Author: Fedor Indutny <fedor at indutny.com>
Date: Tue Nov 4 13:34:35 2014 -0500
der: support `ia5str`
---
lib/asn1/base/node.js | 6 +++---
lib/asn1/decoders/der.js | 2 ++
lib/asn1/encoders/der.js | 2 ++
test/ping-pong-test.js | 4 ++++
4 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/lib/asn1/base/node.js b/lib/asn1/base/node.js
index 7eea127..8b771a2 100644
--- a/lib/asn1/base/node.js
+++ b/lib/asn1/base/node.js
@@ -5,7 +5,7 @@ var EncoderBuffer = require('../base').EncoderBuffer;
// Supported tags
var tags = [
'seq', 'seqof', 'set', 'setof', 'octstr', 'bitstr', 'objid', 'bool',
- 'gentime', 'utctime', 'null_', 'enum', 'int'
+ 'gentime', 'utctime', 'null_', 'enum', 'int', 'ia5str'
];
// Public methods list
@@ -354,7 +354,7 @@ Node.prototype._decodeGeneric = function decodeGeneric(tag, input) {
return null;
if (tag === 'seqof' || tag === 'setof')
return this._decodeList(input, tag, state.args[0]);
- else if (tag === 'octstr' || tag === 'bitstr')
+ else if (tag === 'octstr' || tag === 'bitstr' || tag === 'ia5str')
return this._decodeStr(input, tag);
else if (tag === 'objid' && state.args)
return this._decodeObjid(input, state.args[0], state.args[1]);
@@ -536,7 +536,7 @@ Node.prototype._encodeChoice = function encodeChoice(data, reporter) {
Node.prototype._encodePrimitive = function encodePrimitive(tag, data) {
var state = this._baseState;
- if (tag === 'octstr' || tag === 'bitstr')
+ if (tag === 'octstr' || tag === 'bitstr' || tag === 'ia5str')
return this._encodeStr(data, tag);
else if (tag === 'objid' && state.args)
return this._encodeObjid(data, state.reverseArgs[0], state.args[1]);
diff --git a/lib/asn1/decoders/der.js b/lib/asn1/decoders/der.js
index 9e376f2..3690ca2 100644
--- a/lib/asn1/decoders/der.js
+++ b/lib/asn1/decoders/der.js
@@ -129,6 +129,8 @@ DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {
return unused;
return { unused: unused, data: buffer.raw() };
+ } else if (tag === 'ia5str') {
+ return buffer.raw().toString();
} else {
return this.error('Decoding of string type: ' + tag + ' unsupported');
}
diff --git a/lib/asn1/encoders/der.js b/lib/asn1/encoders/der.js
index 13b8794..94dc17f 100644
--- a/lib/asn1/encoders/der.js
+++ b/lib/asn1/encoders/der.js
@@ -65,6 +65,8 @@ DERNode.prototype._encodeStr = function encodeStr(str, tag) {
return this._createEncoderBuffer(str);
else if (tag === 'bitstr')
return this._createEncoderBuffer([ str.unused | 0, str.data ]);
+ else if (tag === 'ia5str')
+ return this._createEncoderBuffer(str);
return this.reporter.error('Encoding of string type: ' + tag +
' unsupported');
};
diff --git a/test/ping-pong-test.js b/test/ping-pong-test.js
index c9f4c2a..ac8311e 100644
--- a/test/ping-pong-test.js
+++ b/test/ping-pong-test.js
@@ -35,6 +35,10 @@ describe('asn1.js ping/pong', function() {
this.bitstr();
}, { unused: 4, data: new Buffer('hello!') });
+ test('ia5str', function() {
+ this.ia5str();
+ }, 'hello');
+
test('gentime', function() {
this.gentime();
}, 1385921175000);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-asn1.js.git
More information about the Pkg-javascript-commits
mailing list