-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
switch to gyp, add tests and more methods #5
base: master
Are you sure you want to change the base?
Conversation
This includes the C++ wrappers, which throw exceptions upon error.
The new binding.gyp re-enables C++ exceptions, since the NACL C++ wrappers throw them to signal errors like "bad signature". index.js was updated to require the right thing (build/Release/nacl)
beforenm/afternm tests are disabled until there is C++ code for them
Two other notes:
|
Oh, wow. That is great! However, I haven't touched any nodejs stuff in months, so all my node-related work is currently pretty much abandoned. In case you want to take over package ownership in npm, just ask. Also, it doesn't seem to build on my machine:
|
Hm, it should be using gyp, not waf (I deleted the wscript file entirely). I've only tested it on node-0.8.15 (on OS-X, via homebrew) though, maybe 0.8.10 behaves differently? I'll ask some more-node-experienced coworkers to review it. I'd be happy to take it over. My npm user name is |
I did a |
These take a few minutes to run, we might want to run just a subset.
The failing tests were modifying a random byte and then confirming that authenticators were invalid. But with Math.round() they were sometimes modifying a byte off the end of the Buffer, hence not modifying the buffer at all, so the authenticator was still valid.
Hi! Thanks for writing node-nacl! I've got some improvements for you.
First off, this switches from waf to gyp, which (I'm told) is the preferred modern node-0.8.x extension mechanism. It bypasses the upstream "do" script, instead it imports a modified copy of nacl (via the "import.py" script). This copy puts real .c and .h files in the "subnacl/" directory, so gyp can use all its own compiler flags and build process. I think this ought to fix the 32-vs-64-bit problems you were having. It also speeds up the build time immensely. The downside is that it always uses the portable "ref" version of the code, so you don't get the super-fast assembly versions (see https://blog.mozilla.org/warner/2012/01/19/improving-the-pynacl-build-process/ for my speed comparison of ref-vs-asm variants).
I also added a "raw" interface,
require("nacl").nacl
, which should map directly to the upstream C/C++ API. Personally I favor a more OOP-ish interface (like in my python-ed25519 package), since that makes it harder to accidentally swap the public and private keys, but I figure it's most useful to provide the same API as djb's library does, and then write separate wrappers on top of that.I added access to some other nacl functions (secretbox, onetimeauth, stream). And I added some unit tests for most of them (copied from djb's papers on xsalsa20 and poly1305), using the "tap" test runner.
I'm new to node.js and gyp, so please let me know what could be improved.
thanks!
-Brian