Permalink
Browse files

failing test due to rsa-unpack bugs

  • Loading branch information...
1 parent 08b965c commit 40ec848851f7206bfa043e516bf9c1571d46a2fc @substack committed Nov 7, 2012
Showing with 37 additions and 0 deletions.
  1. +7 −0 package.json
  2. +30 −0 test/generate.js
View
@@ -9,10 +9,17 @@
"dependencies" : {
"optimist" : "~0.3.5"
},
+ "devDependencies" : {
+ "tap" : "~0.3.1",
+ "rsa-unpack" : "~0.0.2"
+ },
"repository" : {
"type" : "git",
"url" : "git://github.com/substack/rsa-json.git"
},
+ "scripts" : {
+ "test" : "tap test/*.js"
+ },
"homepage" : "https://github.com/substack/rsa-json",
"keywords" : [
"rsa",
View
@@ -0,0 +1,30 @@
+var test = require('tap').test;
+var unpack = require('rsa-unpack');
+var rsa = require('../');
+
+test('verify unpacked keys', function (t) {
+ var bs = [ 768, 1002, 1345, 2112, 3100 ];
+ t.plan(10 * bs.length);
+
+ bs.forEach(function (bits) {
+ console.dir(bits);
+ rsa({ bits : bits }, function (err, pair) {
+ if (err) return t.fail(err);
+
+ var pub = unpack(pair.public);
+ var priv = unpack(pair.private);
+ t.equal(pub.bits, bits);
+ t.equal(priv.bits, bits);
+
+ t.equal(pub.modulus.toString('hex'), priv.modulus.toString('hex'));
+ t.equal(pub.publicExponent, priv.publicExponent);
+
+ t.ok(priv.privateExponent.length > 30);
+ t.ok(priv.prime1.length > 30);
+ t.ok(priv.prime2.length > 30);
+ t.ok(priv.exponent1.length > 30);
+ t.ok(priv.exponent2.length > 30);
+ t.ok(priv.coefficient.length > 30);
+ });
+ });
+});

0 comments on commit 40ec848

Please sign in to comment.