[Pkg-javascript-commits] [node-asn1.js] 48/202: rfc-3280: fix Certificate encoding

Bastien Roucariès rouca at moszumanska.debian.org
Thu Apr 20 19:18:53 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 31da4da3c865da851fc857cab4d5a3dfa49fdcdc
Author: Fedor Indutny <fedor at indutny.com>
Date:   Sat Aug 16 00:49:20 2014 +0400

    rfc-3280: fix Certificate encoding
---
 package.json                |  2 +-
 rfc/3280/index.js           |  6 ++--
 rfc/3280/test/basic-test.js | 70 ++++++++++++++++++++++++++++-----------------
 3 files changed, 48 insertions(+), 30 deletions(-)

diff --git a/package.json b/package.json
index 72ef973..583551f 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,7 @@
   "description": "ASN.1 encoder and decoder",
   "main": "lib/asn1.js",
   "scripts": {
-    "test": "mocha --reporter spec test/*-test.js rfc/2560/test/*-test.js"
+    "test": "mocha --reporter spec test/*-test.js rfc/2560/test/*-test.js rfc/3280/test/*-test.js"
   },
   "repository": {
     "type": "git",
diff --git a/rfc/3280/index.js b/rfc/3280/index.js
index 157dd03..be3ecd1 100644
--- a/rfc/3280/index.js
+++ b/rfc/3280/index.js
@@ -48,11 +48,11 @@ var TBSCertificate = asn1.define('TBSCertificate', function() {
     this.key('subjectPublicKeyInfo').use(SubjectPublicKeyInfo),
 
     // TODO(indutny): validate that version is v2 or v3
-    this.key('issuerUniqueID').optional().implicit(1).use(UniqueIdentifier),
-    this.key('subjectUniqueID').optional().implicit(2).use(UniqueIdentifier),
+    this.key('issuerUniqueID').optional().explicit(1).use(UniqueIdentifier),
+    this.key('subjectUniqueID').optional().explicit(2).use(UniqueIdentifier),
 
     // TODO(indutny): validate that version is v3
-    this.key('extensions').optional().implicit(3).use(Extensions)
+    this.key('extensions').optional().explicit(3).use(Extensions)
   );
 });
 exports.TBSCertificate = TBSCertificate;
diff --git a/rfc/3280/test/basic-test.js b/rfc/3280/test/basic-test.js
index 88d1cb1..128ddbb 100644
--- a/rfc/3280/test/basic-test.js
+++ b/rfc/3280/test/basic-test.js
@@ -1,36 +1,54 @@
 var assert = require('assert');
-var rfc2560 = require('..');
+var asn1 = require('../../../');
+var rfc3280 = require('..');
 
 var Buffer = require('buffer').Buffer;
 
-describe('asn1.js RFC2560', function() {
-  it('should decode OCSP response', function() {
+describe('asn1.js RFC3280', function() {
+  it('should decode Certificate', function() {
     var data = new Buffer(
-      '308201d40a0100a08201cd308201c906092b0601050507300101048201ba308201b630' +
-      '819fa216041499e4405f6b145e3e05d9ddd36354fc62b8f700ac180f32303133313133' +
-      '303037343531305a30743072304a300906052b0e03021a050004140226ee2f5fa28108' +
-      '34dacc3380e680ace827f604041499e4405f6b145e3e05d9ddd36354fc62b8f700ac02' +
-      '1100bb4f9a31232b1ba52a0b77af481800588000180f32303133313133303037343531' +
-      '305aa011180f32303133313230343037343531305a300d06092a864886f70d01010505' +
-      '00038201010027813333c9b46845dfe3d0cb6b19c03929cdfc9181c1ce823929bb911a' +
-      'd9de05721790fcccbab43f9fbdec1217ab8023156d07bbcc3555f25e9e472fbbb5e019' +
-      '2835efcdc71b3dbc5e5c4c5939fc7a610fc6521d4ed7d2b685a812fa1a3a129ea87873' +
-      '972be3be54618ba4a4d96090d7f9aaa5f70d4f07cf5cf3611d8a7b3adafe0b319459ed' +
-      '40d456773d5f45f04c773711d86cc41d274f771a31c10d30cd6f846b587524bfab2445' +
-      '4bbb4535cff46f6b341e50f26a242dd78e246c8dea0e2fabcac9582e000c138766f536' +
-      'd7f7bab81247c294454e62b710b07126de4e09685818f694df5783eb66f384ce5977f1' +
-      '2721ff38c709f3ec580d22ff40818dd17f',
+      '308204763082035ea0030201020208462e4256bb1194dc300d06092a864886f70d0101' +
+      '0505003049310b300906035504061302555331133011060355040a130a476f6f676c65' +
+      '20496e63312530230603550403131c476f6f676c6520496e7465726e65742041757468' +
+      '6f72697479204732301e170d3134303733303132303434305a170d3134313032383030' +
+      '303030305a3068310b30090603550406130255533113301106035504080c0a43616c69' +
+      '666f726e69613116301406035504070c0d4d6f756e7461696e20566965773113301106' +
+      '0355040a0c0a476f6f676c6520496e633117301506035504030c0e7777772e676f6f67' +
+      '6c652e636f6d30820122300d06092a864886f70d01010105000382010f003082010a02' +
+      '82010100b7894e02f9ba01e07889d670fd3618d6022efc96c9d9deae2e800aa19f4b17' +
+      '20c371b9996b2efc12fa191b60a92afe76e80e5d9d47280cbc46a4cd9cf454503fefcf' +
+      'cd2e1c8b113a89bcd1f1427ae793bbd0d1e077bc963ff2ceb2b0c9ab68196fce1b2f40' +
+      '0dc77d6294a7c0d50ff104cf92ee837d5c484a3ba0ce76b9c018cf96545f7e27518232' +
+      '57874945f87b69bac902ce4b378746953c619db909e73fd2f5e2dd009c5c748ec22fcb' +
+      'd6648fe60a5805e98ab8cd65ab0eb0772d7a19aefdc24c9a3933692ca695e7b493f8ac' +
+      '7aab8e5d1229f071cf08ac0b6c641704a74747faacfb857b68359fc1a98c777fb5eb3e' +
+      '9c90d6a13b78f42d6d797fd74f03c30203010001a38201413082013d301d0603551d25' +
+      '0416301406082b0601050507030106082b0601050507030230190603551d1104123010' +
+      '820e7777772e676f6f676c652e636f6d306806082b06010505070101045c305a302b06' +
+      '082b06010505073002861f687474703a2f2f706b692e676f6f676c652e636f6d2f4749' +
+      '4147322e637274302b06082b06010505073001861f687474703a2f2f636c69656e7473' +
+      '312e676f6f676c652e636f6d2f6f637370301d0603551d0e04160414e43d6cc20c12e9' +
+      '7c1920533676ef287737d8884a300c0603551d130101ff04023000301f0603551d2304' +
+      '18301680144add06161bbcf668b576f581b6bb621aba5a812f30170603551d20041030' +
+      '0e300c060a2b06010401d67902050130300603551d1f042930273025a023a021861f68' +
+      '7474703a2f2f706b692e676f6f676c652e636f6d2f47494147322e63726c300d06092a' +
+      '864886f70d010105050003820101002d5501bd33f7b6e06117e53ccf21703565f29ab7' +
+      '8642a771effa4369f32938b45f04208d88a1046ba0a726622e864143c8dac38392430d' +
+      'fbea1b7d41c1e27dd43438a47d36c4a048de318be442abed5f60373687d01b7fefc43e' +
+      '0aacf620b11a69fb237aaa4dc33b97bc0eb39b1abe6902b1518253addda25037389c26' +
+      '0ef2808be7f702f47a6466d6f3b35764f088c94e0a2b9ee403602ae21cbad3fd8e873e' +
+      '9e817945a3d23fd2b35579cce19ea7f8815d166f3e46d53eed25ef391a912bb715af64' +
+      'e43e124f98be487f9d222954a5bebc8d5ca384c7128c6dabffb11150a7d2a62ce565b8' +
+      'a02a6c4c8ecfc7ac7065c1979cb8d50eabd5d36c72a5396e712e',
       'hex');
 
-    var res = rfc2560.OCSPResponse.decode(data, 'der');
-    assert.equal(res.responseStatus, 'successful');
-    assert.equal(res.responseBytes.responseType, 'id-pkix-ocsp-basic');
+    var res = rfc3280.Certificate.decode(data, 'der');
 
-    var basic = rfc2560.BasicOCSPResponse.decode(
-      res.responseBytes.response,
-      'der'
-    );
-    assert.equal(basic.tbsResponseData.version, 'v1');
-    assert.equal(basic.tbsResponseData.producedAt, 1385797510000);
+    var tbs = res.tbsCertificate;
+    assert.equal(tbs.version, 'v3');
+    assert.deepEqual(tbs.serialNumber,
+                     new asn1.bignum('462e4256bb1194dc', 16));
+    assert.equal(tbs.signature.algorithm.join('.'),
+                 '1.2.840.113549.1.1.5');
   });
 });

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