From 87c589afe5a7ae5df92fcebd37cc36f2c198d62b Mon Sep 17 00:00:00 2001 From: Laurent Eschenauer Date: Tue, 15 Mar 2011 21:41:59 +0100 Subject: [PATCH] Fixed package.json dep and tests --- lib/ostatus/salmon.js | 10 +++++----- package.json | 1 + tests/test-openssl.js | 1 - tests/test-statusnet.js | 3 +-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/ostatus/salmon.js b/lib/ostatus/salmon.js index ecc18f1..7f6a046 100644 --- a/lib/ostatus/salmon.js +++ b/lib/ostatus/salmon.js @@ -32,7 +32,7 @@ var Sys = require('sys'), Mu = require('mu'); Base64 = require('base64'); Crypto = require('crypto'); - Rsa = require('rsa'); + Bn = require('bignumber'); Buffer = require('buffer').Buffer; function unpack(body, callback) { @@ -72,19 +72,19 @@ function verify_signature(me, key) { var hash = sha256.digest('hex'); // Decode the signature from the base64url encoded value we have in the envelope - var sig = Rsa.b64toBA(me.sigs[0].value.replace(/-/g, '+').replace(/_/g, '/')); + var sig = Bn.b64toBA(me.sigs[0].value.replace(/-/g, '+').replace(/_/g, '/')); // Extract the key elements from the key encoding var key = key.replace(/-/g, '+').replace(/_/g, '/').split('.'); - var n = Rsa.b64tohex(key[1]); + var n = Bn.b64tohex(key[1]); var e = "10001"; //Rsa.b64tohex(key[2]); // Prepare the RSA Engine - var rsa = new Rsa.Key(); + var rsa = new Bn.Key(); rsa.setPublic(n, e); // Perform RSA Public on the signature string - var v = rsa.doPublic(new Rsa.BigInteger(sig)); + var v = rsa.doPublic(new Bn.BigInteger(sig)); // Convert the verified output into a string and keep the last 64 characters var buf = new Buffer(v.toByteArray()); diff --git a/package.json b/package.json index 58009e9..220de24 100644 --- a/package.json +++ b/package.json @@ -13,5 +13,6 @@ ,"o3-xml" : "http://files.eschnou.com/o3-xml.tgz" ,"flow" : "0.2.x" ,"base64" : "2.0.x" + ,"bignumber" : "1.1.x" } } diff --git a/tests/test-openssl.js b/tests/test-openssl.js index 8e0d5af..d161018 100644 --- a/tests/test-openssl.js +++ b/tests/test-openssl.js @@ -2,7 +2,6 @@ var assert=require('assert'); var fs=require('fs'); var path=require('path'); var ostatus=require('ostatus'); -var rsa=require('rsa'); /* * Test interoperability with an OpenSSL signed salmon magic enveloppe. diff --git a/tests/test-statusnet.js b/tests/test-statusnet.js index 0af6401..4e20a58 100644 --- a/tests/test-statusnet.js +++ b/tests/test-statusnet.js @@ -2,7 +2,6 @@ var assert=require('assert'); var fs=require('fs'); var path=require('path'); var ostatus=require('ostatus'); -var rsa=require('rsa'); /* * Test interoperability with a Status.net signed salmon magic enveloppe. @@ -12,7 +11,7 @@ function test(){ assert.ok(ostatus.salmon.verify_signature(me, key)); } -var expected = { +var me = { sigs: [ { value: 'UqKwh0XSOhdSD7U9nVHxB67sCNt8lQzkl5aPELQTfuhrlBoktbExhhkP4QGFg0WS0FgPnQpG24z5S4XIk2BTjI8My-VlwRWdeU72NtnLhZjz8EzA1aJTI_Drs71-YICuM_dLAJgo55pF4nIMkRN9KA-rS-y7oC3cwt01MknR8UQ=' } ],