[Pkg-javascript-commits] [node-asn1.js] 118/202: der: support more objid inputs

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 47d95e92caa5d236f98346586ce8e8648175a832
Author: Fedor Indutny <fedor at indutny.com>
Date:   Wed Jul 22 20:16:03 2015 -0700

    der: support more objid inputs
---
 lib/asn1/encoders/der.js |  4 +++-
 test/der-encode-test.js  | 10 ++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/lib/asn1/encoders/der.js b/lib/asn1/encoders/der.js
index 0f6784d..7fff0d4 100644
--- a/lib/asn1/encoders/der.js
+++ b/lib/asn1/encoders/der.js
@@ -77,11 +77,13 @@ DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) {
       return this.reporter.error('string objid given, but no values map found');
     if (!values.hasOwnProperty(id))
       return this.reporter.error('objid not found in values map');
-    id = values[id].split(/\s+/g);
+    id = values[id].split(/[\s\.]+/g);
     for (var i = 0; i < id.length; i++)
       id[i] |= 0;
   } else if (Array.isArray(id)) {
     id = id.slice();
+    for (var i = 0; i < id.length; i++)
+      id[i] |= 0;
   }
 
   if (!Array.isArray(id)) {
diff --git a/test/der-encode-test.js b/test/der-encode-test.js
index fbd91dc..e198037 100644
--- a/test/der-encode-test.js
+++ b/test/der-encode-test.js
@@ -81,4 +81,14 @@ describe('asn1.js DER encoder', function() {
     var out = A.encode(1, 'der');
     assert.equal(out.toString('hex'), '020101');
   });
+
+  test('should properly encode objid with dots', function() {
+    this.objid({
+      '1.2.398.3.10.1.1.1.2.2': 'yes'
+    });
+  }, 'yes', '060a2a830e030a0101010202');
+
+  test('should properly encode objid as array of strings', function() {
+    this.objid();
+  }, '1.2.398.3.10.1.1.1.2.2'.split('.'), '060a2a830e030a0101010202');
 });

-- 
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