[Pkg-javascript-commits] [node-asn1.js] 120/202: lib: `utf8str`
Bastien Roucariès
rouca at moszumanska.debian.org
Thu Apr 20 19:19:00 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 4ac7d8d72e809b0d9a2c16290e8dabbb9384f075
Author: Fedor Indutny <fedor at indutny.com>
Date: Mon Aug 10 18:55:27 2015 -0700
lib: `utf8str`
---
lib/asn1/base/node.js | 8 ++++++--
lib/asn1/decoders/der.js | 2 +-
lib/asn1/encoders/der.js | 2 +-
test/ping-pong-test.js | 4 ++++
4 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/lib/asn1/base/node.js b/lib/asn1/base/node.js
index 0a6e9e0..92344a9 100644
--- a/lib/asn1/base/node.js
+++ b/lib/asn1/base/node.js
@@ -5,7 +5,7 @@ var assert = require('minimalistic-assert');
// Supported tags
var tags = [
'seq', 'seqof', 'set', 'setof', 'octstr', 'bitstr', 'objid', 'bool',
- 'gentime', 'utctime', 'null_', 'enum', 'int', 'ia5str'
+ 'gentime', 'utctime', 'null_', 'enum', 'int', 'ia5str', 'utf8str'
];
// Public methods list
@@ -373,7 +373,9 @@ 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' || tag === 'ia5str')
+ else if (tag === 'octstr' || tag === 'bitstr')
+ return this._decodeStr(input, tag);
+ else if (tag === 'ia5str' || tag === 'utf8str')
return this._decodeStr(input, tag);
else if (tag === 'objid' && state.args)
return this._decodeObjid(input, state.args[0], state.args[1]);
@@ -577,6 +579,8 @@ Node.prototype._encodePrimitive = function encodePrimitive(tag, data) {
if (tag === 'octstr' || tag === 'bitstr' || tag === 'ia5str')
return this._encodeStr(data, tag);
+ else if (tag === 'utf8str')
+ return this._encodeStr(data, tag);
else if (tag === 'objid' && state.args)
return this._encodeObjid(data, state.reverseArgs[0], state.args[1]);
else if (tag === 'objid')
diff --git a/lib/asn1/decoders/der.js b/lib/asn1/decoders/der.js
index ca2a940..cf878a7 100644
--- a/lib/asn1/decoders/der.js
+++ b/lib/asn1/decoders/der.js
@@ -129,7 +129,7 @@ DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {
return unused;
return { unused: unused, data: buffer.raw() };
- } else if (tag === 'ia5str') {
+ } else if (tag === 'ia5str' || tag === 'utf8str') {
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 7fff0d4..739dce6 100644
--- a/lib/asn1/encoders/der.js
+++ b/lib/asn1/encoders/der.js
@@ -65,7 +65,7 @@ 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')
+ else if (tag === 'ia5str' || tag === 'utf8str')
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 40be7ac..874629b 100644
--- a/test/ping-pong-test.js
+++ b/test/ping-pong-test.js
@@ -37,6 +37,10 @@ describe('asn1.js ping/pong', function() {
this.ia5str();
}, 'hello');
+ test('utf8str', function() {
+ this.utf8str();
+ }, '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