[Pkg-javascript-commits] [node-asn1.js] 189/202: node: add ObjectDescriptor primitive
Bastien Roucariès
rouca at moszumanska.debian.org
Thu Apr 20 19:19:07 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 f3ba22f020c9535d52f73445a6f83b424b0b2475
Author: Sergey Dmitriev <serge.dmitriev at gmail.com>
Date: Mon Oct 24 17:22:48 2016 +0700
node: add ObjectDescriptor primitive
PR-URL: https://github.com/indutny/asn1.js/pull/79
Reviewed-By: Fedor Indutny <fedor at indutny.com>
---
lib/asn1/base/node.js | 6 +++++-
lib/asn1/decoders/der.js | 2 ++
lib/asn1/encoders/der.js | 2 ++
test/der-decode-test.js | 4 ++++
test/der-encode-test.js | 4 ++++
test/ping-pong-test.js | 4 ++++
6 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/lib/asn1/base/node.js b/lib/asn1/base/node.js
index 1672f42..7b26bd8 100644
--- a/lib/asn1/base/node.js
+++ b/lib/asn1/base/node.js
@@ -6,7 +6,7 @@ var assert = require('minimalistic-assert');
// Supported tags
var tags = [
'seq', 'seqof', 'set', 'setof', 'objid', 'bool',
- 'gentime', 'utctime', 'null_', 'enum', 'int',
+ 'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc',
'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str',
'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr'
];
@@ -414,6 +414,8 @@ Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) {
return this._decodeNull(input, options);
else if (tag === 'bool')
return this._decodeBool(input, options);
+ else if (tag === 'objDesc')
+ return this._decodeStr(input, tag, options);
else if (tag === 'int' || tag === 'enum')
return this._decodeInt(input, state.args && state.args[0], options);
@@ -617,6 +619,8 @@ Node.prototype._encodePrimitive = function encodePrimitive(tag, data) {
return this._encodeInt(data, state.args && state.reverseArgs[0]);
else if (tag === 'bool')
return this._encodeBool(data);
+ else if (tag === 'objDesc')
+ return this._encodeStr(data, tag);
else
throw new Error('Unsupported tag: ' + tag);
};
diff --git a/lib/asn1/decoders/der.js b/lib/asn1/decoders/der.js
index a0cfb6f..4ecc75b 100644
--- a/lib/asn1/decoders/der.js
+++ b/lib/asn1/decoders/der.js
@@ -149,6 +149,8 @@ DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {
return numstr;
} else if (tag === 'octstr') {
return buffer.raw();
+ } else if (tag === 'objDesc') {
+ return buffer.raw();
} else if (tag === 'printstr') {
var printstr = buffer.raw().toString('ascii');
if (!this._isPrintstr(printstr)) {
diff --git a/lib/asn1/encoders/der.js b/lib/asn1/encoders/der.js
index 9b0dce6..721f802 100644
--- a/lib/asn1/encoders/der.js
+++ b/lib/asn1/encoders/der.js
@@ -86,6 +86,8 @@ DERNode.prototype._encodeStr = function encodeStr(str, tag) {
return this._createEncoderBuffer(str);
} else if (/str$/.test(tag)) {
return this._createEncoderBuffer(str);
+ } else if (tag === 'objDesc') {
+ return this._createEncoderBuffer(str);
} else {
return this.reporter.error('Encoding of string type: ' + tag +
' unsupported');
diff --git a/test/der-decode-test.js b/test/der-decode-test.js
index ee4e4fd..768d2e3 100644
--- a/test/der-decode-test.js
+++ b/test/der-decode-test.js
@@ -76,6 +76,10 @@ describe('asn1.js DER decoder', function() {
);
}, '30800101ff0000', { 'key': true });
+ test('should decode objDesc', function() {
+ this.objDesc();
+ }, '0703323830', new Buffer('280'));
+
test('should decode bmpstr', function() {
this.bmpstr();
}, '1e26004300650072007400690066006900630061' +
diff --git a/test/der-encode-test.js b/test/der-encode-test.js
index c089267..06003b9 100644
--- a/test/der-encode-test.js
+++ b/test/der-encode-test.js
@@ -30,6 +30,10 @@ describe('asn1.js DER encoder', function() {
});
}
+ test('should encode objDesc', function() {
+ this.objDesc();
+ }, new Buffer('280'), '0703323830');
+
test('should encode choice', function() {
this.choice({
apple: this.bool(),
diff --git a/test/ping-pong-test.js b/test/ping-pong-test.js
index 0e2be0a..5a1e250 100644
--- a/test/ping-pong-test.js
+++ b/test/ping-pong-test.js
@@ -29,6 +29,10 @@ describe('asn1.js ping/pong', function() {
this.octstr();
}, new Buffer('hello'));
+ test('objDesc', function() {
+ this.objDesc()
+ }, new Buffer('hello'));
+
test('bitstr', function() {
this.bitstr();
}, { unused: 4, data: new Buffer('hello!') });
--
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