44 Commits

Author SHA1 Message Date
Jesper Louis Andersen
b1c3e69fb5 Change randombytes/1 so it always executes on a DS
Investigation shows erratic behaviour of the CSPRNG. It may block at times
because it needs to go to the kernel and obtain more random information in
the system. Once this happens, you are blocked for quite a long time, but
we don't generally know when this happens. So just execute these directly
on the dirty scheduler.
2015-08-29 22:09:51 +02:00
Jesper Louis Andersen
2cad66ac2a Handle the ED25519 to Curve25519 conversion routines.
Make sure these either execute on the Dirty Scheduler or execute with bumping
reductions.
2015-08-29 22:08:34 +02:00
Jesper Louis Andersen
2e5163a934 Clean up things which are not needed anymore. 2015-08-29 21:50:16 +02:00
Jesper Louis Andersen
a59e983d9e Fix large detached signature verification. 2015-08-29 21:34:08 +02:00
Jesper Louis Andersen
1562eed9a3 Use DS-variants whenever it doesn't make sense.
Some operations are simply too expensive. Always run these on the dirty
scheduler.
2015-08-29 21:33:22 +02:00
Jesper Louis Andersen
66cf275152 Introduce a scalarmult variant which is safe from arguments swaps. 2015-08-29 21:32:48 +02:00
Jesper Louis Andersen
6bfa191f6b Do not create a new set of 0-bytes all the time.
Rather than creating a set of <<0,…,0>> every time and then throwing it away,
we now reuse a constant. They are small enough they are still small-binaries, but a
process can keep them around and use them whenever it needs to go to the
low-level area.
2015-08-29 20:54:37 +02:00
Jesper Louis Andersen
a135bce9d3 Simplify the code base, first round:
* Introduce enacl:verify/0 to verify the integrity of the library.
* Always run keypair functions on the dirty schedulers.
* Do not call NIFs when creating zerobytes. Avoid constructing new binary data, but reuse a constant.
* The box/box_open and box_seal/box_seal_open API is so expensive to call there is little overhead in
  running it on the DS always.
2015-08-23 21:44:28 +02:00
Jesper Louis Andersen
f444d1e4ac Fix box_seal/2 and box_seal_open/3.
* Call the functions `box_seal` and `box_seal_open` to match the libsodium names in module `enacl`.
* Fix a bug in the C NIF: We should fail if the input is `<` SEALBYTES but not on `<=` SEALBYTES. The latter made it impossible to encode empty messages.
* Add variants which run directly on the interpreter scheduler for small messages.

Also:

* Provide full EQC functions for the testing purposes. This generated around 13000 random test cases in a 5 minute run, all passing.# Please enter the commit message for your changes. Lines starting
2015-08-14 22:03:33 +02:00
Jesper Louis Andersen
92109eb354 Improve and verify sign_*_detached functions.
Provide non-dirty-scheduler variants for small strings, accurately bump
reductions for these strings.

While here, provide EQC test cases for the two functions.
2015-08-12 23:11:41 +02:00
Amir Ghassemi Nasr
233c924b70 correct enacl:seal_box_open return value 2015-08-09 17:24:12 +04:30
Amir Ghassemi Nasr
64c03a1425 added bindings for crypto_box_seal_open\' functions 2015-08-07 00:24:50 +04:30
Parnell Springmeyer
35515e465a Improvements re: suggestions from @jlouis. 2015-07-26 13:49:15 -05:00
Joel Stanley
7e7ac67fb3 Add bindings to the libsodium DSA operations 'crypto_sign_detached' and 'crypto_sign_verify_detached' 2015-07-26 08:00:48 -05:00
Alexander Færøy
de0ce86473
Add Ed 25519 Utility API. 2015-04-02 18:43:58 +02:00
Alexander Færøy
e408278d50
Move the high-level API to enacl_ext 2015-02-22 14:29:44 +01:00
Alexander Færøy
ef36bb85c1
Add curve25519_public_key/1. 2015-02-21 23:08:07 +01:00
Alexander Færøy
4e66fc3b94
Add curve25519_keypair/0 and curve25519_shared/2. 2015-02-21 22:49:44 +01:00
Jesper Louis Andersen
50b0058335 Improve the documentation of the project.
Go over the README file, and improve its contents. Add a Usage/hints section
with some helpful hints on how to use the library in turn. Also while here, make
sure that `rebar doc` works as expected and fix every documentation bug in
the EDoc sections, so it compiles and works. Verify the documentation output
is nice-looking while at it.
2014-12-18 09:28:00 +01:00
Jesper Louis Andersen
159e8f6750 Introduce precomputed keys API.
This patch implements beforenm/afternm calls from NaCl for `box` style
crypto. It's main advantage is way faster computations, since it avoids
recomputing in the elliptic curve for every message.

While here, bump the version to v0.11.0 as new functionality was added.
2014-12-17 17:12:29 +01:00
Jesper Louis Andersen
fc0f535882 Introduce timing for precomputed values. 2014-12-17 16:17:12 +01:00
Jesper Louis Andersen
797daa653b Fix a type specification.
When calling `stream_xor/3` it is possible to supply `iodata()` directly
and you don't have to convert to a binary first. Reflect this in the type
of the specification.
2014-12-17 08:35:50 +01:00
Jesper Louis Andersen
ea4558738a Fix typo in spec, unbreak compilation. 2014-12-16 16:59:30 +01:00
Jesper Louis Andersen
cf08e5446f Fix a type -spec. 2014-12-16 16:55:45 +01:00
Jesper Louis Andersen
23e535fcc2 Use better specifications. 2014-12-13 02:23:04 +01:00
Jesper Louis Andersen
b109ff7834 Provide a type specification of enacl:randombytes/1 2014-12-12 02:45:12 +01:00
Jesper Louis Andersen
fd9f421621 Introduce enacl:randombytes/1. 2014-12-09 00:33:55 +01:00
Jesper Louis Andersen
33a47e4fd4 Do not accept iolist data when binary data is what is forced by the input code. 2014-11-29 17:14:53 +01:00
Jesper Louis Andersen
90509026ce reduction handling, iodata() conversion. 2014-11-29 16:45:58 +01:00
Jesper Louis Andersen
2724873f2f Add timing for all missing operations. 2014-11-29 15:49:13 +01:00
Jesper Louis Andersen
d46ae1da16 Use on-scheduler variants of calls when message sizes are small. 2014-11-28 17:09:48 +01:00
Jesper Louis Andersen
addd22b31a More documentation and testing functions. 2014-11-28 14:41:06 +01:00
Jesper Louis Andersen
9cd38c7651 Introduce test cases for signing and partially for sign-opening. 2014-11-26 22:10:09 +01:00
Jesper Louis Andersen
57bb93683b Introduce tests for authentication verification and provide basis for signatures. 2014-11-26 20:05:59 +01:00
Jesper Louis Andersen
ec0cc1afaa Handle the Auth tests. 2014-11-26 15:08:14 +01:00
Jesper Louis Andersen
6a707aef57 Write test cases for the streaming API. 2014-11-26 14:24:14 +01:00
Jesper Louis Andersen
6354ea4f69 Improve the return values for keypairs.
To avoid the common mistake of re-arranging keypairs, provide them in a map which
forces the programmer to unpack the map in order to obtain the keys. This in turn makes
it harder to swap the PK/SK pair around and mistakenly giving out the secret key to the world.
2014-11-25 15:52:58 +01:00
Jesper Louis Andersen
f205398958 Provide edoc documentation for the primitives. 2014-11-25 15:42:54 +01:00
Jesper Louis Andersen
d37bce7eeb Documentation, documentation, documentation. 2014-11-25 15:08:31 +01:00
Jesper Louis Andersen
f64e62d16e Provide correctness test cases for the verification codes. 2014-11-25 14:10:24 +01:00
Jesper Louis Andersen
d3471348e2 Introduce negative testing.
Negative testing means we inject faulty data into the test now and then. When this happens, we make sure the SUT will
return some kind of badarg error for bad arguments. This means we should make sure things actually work out as they should.

As a side-effect, this can also be used to test for memory leaks. If run for a while, it makes sure there are no leaks in the code base,
and it probably also makes sure there are no ways to crash the server by any means of use of these NIFs. As such, it looks like the
NIFs are fairly stable.
2014-11-22 23:26:45 +01:00
Jesper Louis Andersen
c08f83a755 Implement cryptography for secret boxes. 2014-11-21 17:42:32 +01:00
Jesper Louis Andersen
ff5196b99f Implement crypto boxing/unboxing for public key cryptographic systems. 2014-11-21 13:40:47 +01:00
Jesper Louis Andersen
9a7f4c8d4e Initial checkin. 2014-11-18 23:16:49 +01:00