Commit 3fab04b3 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Use nodejs instead of smjs for credential generation

parent 0b42e316
......@@ -18,7 +18,10 @@ To run basic command-line tools, you will need:
To generate credentials, you will need:
* [The SpiderMonkey JavaScript shell](https://developer.mozilla.org/en-US/docs/SpiderMonkey)
* [Node.js](http://nodejs.org/)
On some systems, the Node.js interpreter might be available as either
`node` or `nodejs`, please adapt `stuff/derive_key.js` accordingly.
To run the web server, you will additionally need:
......
......@@ -81,7 +81,7 @@ let generate_token () =
let checksum = 53 - Z.(to_int (value mod n53)) in
raw ^ String.make 1 digits.[checksum]
let smjs_template = format_of_string "smjs -f media/booth/js/jscrypto/sjcl.js -e 'print(sjcl.codec.hex.fromBits(sjcl.misc.pbkdf2(%S, sjcl.codec.hex.toBits(%S), 1000, 256)))'"
let smjs_template = format_of_string "./stuff/derive_key.js %s %s"
let public_key_of_token x =
let ic = Printf.ksprintf Unix.open_process_in smjs_template x uuid in
......
......@@ -6,7 +6,7 @@ Package: belenios-deps-minimal
Version: 0.0.1
Maintainer: Stéphane Glondu <Stephane.Glondu@inria.fr>
Depends:
spidermonkey-bin,
nodejs,
build-essential,
ocaml-findlib,
libzarith-ocaml-dev,
......
#!/bin/sh
ocamlbuild src/bin/credgen.native
ocamlbuild -quiet src/bin/credgen.native
exec _build/src/bin/credgen.native "$@"
#!/usr/bin/env nodejs
// Hack taken from http://stackoverflow.com/questions/5625569/include-external-js-file-in-node-js-app
var fs = require('fs');
var vm = require('vm');
var includeInThisContext = function(path) {
var code = fs.readFileSync(path);
vm.runInThisContext(code, path);
}.bind(this);
// Use SJCL to derive the key
includeInThisContext(__dirname+"/../media/booth/js/jscrypto/sjcl.js");
var seed = process.argv[2];
var salt = process.argv[3];
console.log(sjcl.codec.hex.fromBits(sjcl.misc.pbkdf2(seed, sjcl.codec.hex.toBits(salt), 1000, 256)));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment