1
0
mirror of https://github.com/danog/fast-srp.git synced 2024-11-26 20:04:49 +01:00
Go to file
2015-09-07 16:33:11 +02:00
lib Fixup for node v0.12.7 2015-09-07 15:32:09 +02:00
test Initial import 2015-09-07 15:23:26 +02:00
index.js Initial import 2015-09-07 15:23:26 +02:00
LICENSE Initial import 2015-09-07 15:23:26 +02:00
package.json Initial import 2015-09-07 15:23:26 +02:00
README.md Update README.md 2015-09-07 16:33:11 +02:00
SRP Design.md Correct a mistake 2015-09-07 16:04:32 +02:00

fast-srp

Is a pure NodeJS implementation of the SRP6a protocol.

It's a derived work of Jed Parson's node-srp and Tom Wu's jsbn.

node-srp uses bignum to handle the big numbers, but I've got many problems with that library mainly compiling it in Windows 7. Finally I've ported the node-srp to use jsbn.

Creating the Verifier

'use strict';

var srp6a = require('fast-srp');

/**
 * Computes the verifier of a user. Only needed to add the user to the auth system.
 *
 * I: (string)		Username to compute verifier
 * P: (string)		Password
 * callback: (function) Callback function with two params; error, verifier
 *
 * returns: verifier (Buffer)
 *
 */

var srp6a_create_user = function(I, P, callback) {
  srp6a.genKey(32, function(error, salt) {
	  if(error) {
	    callback(error);
	  }
	  var v = srp6a.computeVerifier(srp6a.params[4096], salt, new Buffer(I), new Buffer(P));
	  callback(null, v);
  });
}

srp6a_create_user('Zarmack Tanen', '*****', function(error, verifier) {
  if(error)
    throw error;
  console.log("SRP6a verifier of Zarmack Tanen user is " + verifier.toString('hex'));
});