Commit Graph

39 Commits

Author SHA1 Message Date
Jesper Louis Andersen a49c5a816c Introduce SunOS/Illumos support into the mix. 2015-08-29 21:31:44 +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 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
Jesper Louis Andersen bec29dfbe1 Mark internal functions as static functions.
This quells a number of warnings in the library when compiling.
2015-05-11 17:25:11 +02:00
arpunk 7bf9f24259 Add missing include and lib directories 2015-05-06 02:50:41 -05:00
Alexander Færøy de0ce86473 Add Ed 25519 Utility API. 2015-04-02 18:43:58 +02:00
Alexander Færøy b544a37a72 Fix warning: missing declaration for memcpy(). 2015-04-02 18:43:58 +02:00
Alexander Færøy d61d363426 Zero out temporary secret key memory. 2015-02-22 13:26:11 +01:00
Alexander Færøy 4e66fc3b94 Add curve25519_keypair/0 and curve25519_shared/2. 2015-02-21 22:49:44 +01:00
Alexander Færøy 6de936899c Use rebar3 for compilation. 2015-02-21 22:47:20 +01:00
Jesper Louis Andersen 238907e2a7 Fix bug in box_open_afternm + Improve readability of C code.
If we write

	EXP != 0

and EXP is a very large term, it is hard to see what it gets checked against, so we rewrite it as

	0 != EXP

so we instanly see what we check against. While here, teset against 0 != crypto_box_afternm(…)
2014-12-17 16:15:29 +01:00
Jesper Louis Andersen e456f4ea9b Introduce blocking variants. 2014-12-17 15:50:02 +01:00
Jesper Louis Andersen e594146f67 Implement the beforenm/afternm calls at the NIF layer. 2014-12-17 12:46:54 +01:00
Jesper Louis Andersen e10b7c8cfe Fail compilation if the Erlang/OTP system has no dirty scheduler support. 2014-12-16 15:12:52 +01:00
Jesper Louis Andersen 5fec48c091 EQC Test improvements
* Generalize binary generation because it is used again and again.
* Use generalized binary generation in the hash functions since they are much faster as generators.
2014-12-13 02:00:52 +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 281c3e8fbf Provide (scheduler) blocking variants of all the expensive calls. 2014-11-28 14:53:18 +01:00
Jesper Louis Andersen 2d39e2535e Properly initialize libsodium. 2014-11-28 14:41:20 +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 7c8272baa8 Keypair generation cannot fail.
Do not return an `ok` style tuple if key generation cannot fail.
2014-11-25 15:43:15 +01:00
Jesper Louis Andersen c33225cb77 Implement the low-level functions for signing. 2014-11-25 13:48:51 +01:00
Jesper Louis Andersen 30cb016078 Introduce low-level functions for handling string comparison. 2014-11-25 13:23:14 +01:00
Jesper Louis Andersen 265d8c7636 Handle signing keypair generation. 2014-11-24 19:30:04 +01:00
Jesper Louis Andersen 2324b73534 Implement the low-level codes for onetime authentication. 2014-11-24 15:17:02 +01:00
Jesper Louis Andersen 08297bb9c9 Rid ourselves of excess whitespace. 2014-11-24 15:16:54 +01:00
Jesper Louis Andersen 772a97d3db Implement low level code for the authenticators. 2014-11-24 14:39:19 +01:00
Jesper Louis Andersen 101c16e34a Add low-level support for crypto_stream and crypto_stream_xor. 2014-11-24 14:24:03 +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 c074a4b186 If we fail to open the box, release the binary we allocate while doing so. 2014-11-19 23:05:32 +01:00
Jesper Louis Andersen ba0e5e535d Implement the NIF parts of handling the public key crypto boxes in the system. 2014-11-19 22:57:23 +01:00
Jesper Louis Andersen 3365b3e5af Provide a way to get at the typical constants for the public key box. 2014-11-18 23:37:04 +01:00
Jesper Louis Andersen 9a7f4c8d4e Initial checkin. 2014-11-18 23:16:49 +01:00