250 Commits

Author SHA1 Message Date
Jesper Louis Andersen
fc943a19c7 Go through the secret API as well 2020-01-24 22:17:24 +01:00
Jesper Louis Andersen
2b8b6224d8 Plug some memory leaks in the public API.
The problem is, like the other recent
patches, about properly releasing
binaries we have allocated but not
given to the VM for it to use.
2020-01-24 22:14:23 +01:00
Jesper Louis Andersen
4939f7bb23 Protect the signature ctx with a mutex
This is the same game as with the
generichash construction. We want
to protect it with a mutex so
different processes can safely do
work on the same resource.

While here, also move the _update
function onto the dirty scheduler.
It is by far the most expensive
operation, and why it wasn't there
in the first place is odd. This should
unblock the scheduler on long
sign-checks. It also move the
possible mutex block onto the
dirty scheduler thread, away from
the core schedulers, improving
latency in the system as a result.
2020-01-24 15:18:04 +01:00
Jesper Louis Andersen
7d8fdf69c0 Protect generichash by a mutex
While sodium is thread-safe, our
resources are not. Furthermore,
we might have an update call going
when someone decides to call
finalize and so on. It is not clever
to do so, but on the other hand
I want to protect against this.

While here, mark the mutexed
calls as dirty CPU. This avoids them
blocking the main scheduler and
only messes with the background
dirty threads, which is somewhat
more safe.

The consequence is that order
access to the resource is now
serialized. I don't think you should
do it, but it is now possible.
2020-01-24 14:48:21 +01:00
Jesper Louis Andersen
e4b35a7035 Flesh out changelog some more
This is a sort-of TODO list at the top of the list, but we use it to keep
track of what we need to do.
2020-01-22 22:23:23 +01:00
Jesper Louis Andersen
49a437347e Improve release naming
Make it obvious you are releasing both tx and rx.
2020-01-22 22:22:53 +01:00
Jesper Louis Andersen
018bf0f6fc Plug a large set of memory leaks in signing
If you fail, there are cases where binaries are not properly released.
This patch fixes them all in signing.
2020-01-22 22:22:29 +01:00
Jesper Louis Andersen
e67619a403 Update the naming scheme of AEAD xchacha20...
Since this AEAD construction variant is an IETF variant, reflect
this in the names of the functions.

This streamlines the API with the libsodium API.
2020-01-22 19:41:58 +01:00
Jesper Louis Andersen
7f857115bb Add aead IETF constructions
Since the chacha20poly1305 constructions were the IETF variants,
we renamed those so they follow the official library better. While
here, we also fixed the argument order of the files.
2020-01-21 14:16:24 +01:00
Jesper Louis Andersen
bdb4719f6d Fix AEAD parameter order / naming.
The order of parameters were in the wrong order. Make them equal
to the official order of libsodium.

While here, rename NONCEBYTES to NPUBBYTES so it reflects the
underlying names as well.
2020-01-21 13:57:39 +01:00
Jesper Louis Andersen
ab40d5bbf8 Rename fixups 2020-01-21 13:56:17 +01:00
Jesper Louis Andersen
92b91bd806 Rename "nacl_error_tuple" -> "enacl_error_tuple"
The new name is consistent where the old name was not.
2020-01-21 13:40:35 +01:00
Jesper Louis Andersen
fec24995d1 Clean up aead construction, plug mem-leak 2020-01-21 13:39:08 +01:00
Jesper Louis Andersen
899fbeefd3 Plug memory leaks in kx_ functions
If we, for some reason, fail to the error-path, then binaries allocated
are not being released properly back to the erlang runtime. Fix this
in the usual fashion by using a stack of undo-operations, and thread
them via goto.
2020-01-21 13:01:48 +01:00
Jesper Louis Andersen
d850b16d1b Fix multi-part signatures
Remove the signstate wrapper as it is not needed anyore.
2020-01-20 15:52:38 +01:00
Jesper Louis Andersen
a5e66ff204 Reap a #define 2020-01-20 15:38:42 +01:00
Jesper Louis Andersen
bf6fb6cf7b Split the remaining operations 2020-01-20 15:31:44 +01:00
Jesper Louis Andersen
fe478ea253 Header file fixupUse <erl_nif.h> since it is a system header.Also rearrange headers to be consistent. 2020-01-20 14:57:42 +01:00
Jesper Louis Andersen
460c5bddfd Rudimentary test of pwhash 2020-01-20 14:45:52 +01:00
Jesper Louis Andersen
d3c033c4e6 Split off password hashing 2020-01-20 14:38:20 +01:00
Jesper Louis Andersen
fddbefeabd Simple AEAD unit tests 2020-01-20 14:38:09 +01:00
Jesper Louis Andersen
2ea36a7352 Start an "Upcoming changes" list
We want to fix a number of problems in the library. So we write down
what we are going to do in order to make it clearer to people.
2020-01-20 14:37:47 +01:00
Jesper Louis Andersen
0427fa42ee Rename enif_crypto_ to enacl_crypto_
This is a better name which spits stuff appropriately.

We don't pollute the enif_ namespace.
2020-01-19 17:56:31 +01:00
Jesper Louis Andersen
f5b8a8eb3b Pull signing out to its own module 2020-01-19 17:38:42 +01:00
Jesper Louis Andersen
4eaef57a76 Rename AEAD routines from enif_* to enacl_* 2020-01-19 13:32:15 +01:00
Jesper Louis Andersen
3ee5a94caf Split off AEAD functions to a separate file 2020-01-19 13:29:32 +01:00
Jesper Louis Andersen
0047af286f Provide a test suite for Generichash 2020-01-19 12:08:17 +01:00
Jesper Louis Andersen
61345d0b6e Fix argument handling in generichash_final
If supplying 1 argument, it is in argv[0], not argv[1]
2020-01-19 12:08:05 +01:00
Jesper Louis Andersen
0f39bae64c Fix name of C function
The name of the generichash function was wrong, so it was not possible to find it when
loading the NIF.
2020-01-19 12:07:18 +01:00
Jesper Louis Andersen
d7e83dd569 Track outlen inside the generichash wrapper 2020-01-17 16:24:51 +01:00
Jesper Louis Andersen
df1b134f73 Track liveness stateReject updates to finalized generichash states. 2020-01-17 16:07:01 +01:00
Jesper Louis Andersen
f5918c0156 Fix compilation 2020-01-17 16:03:30 +01:00
Jesper Louis Andersen
463cae05d5 Bump for first additions 2020-01-17 16:03:16 +01:00
Jesper Louis Andersen
6e057cbd48 The sodium MIN/MAX values are incusive 2020-01-17 15:47:51 +01:00
Jesper Louis Andersen
d5bb24e671 Start splitting the library into its parts 2020-01-17 15:46:38 +01:00
Jesper Louis Andersen
a25b9a2684 Bump CHANGELOG 2020-01-16 15:55:59 +01:00
Jesper Louis Andersen
b7533d3b9c Release resources under failure
sign and generichash failed to release their resources under failure.

This can lead to subtle memory leaks in the very unlikely event
we can't initialize.
2020-01-16 15:45:42 +01:00
Jesper Louis Andersen
f43a730758 Merge branch 'multi-part-signatures' of github.com:hazy/enacl 2020-01-16 15:38:48 +01:00
Jesper Louis Andersen
0cfa88be32 Update changelog 2020-01-16 15:22:43 +01:00
Jesper Louis Andersen
3f284be0cb Merge branch 'sign-seed-keypair' of github.com:termoose/enacl 2020-01-16 15:21:50 +01:00
Jesper Louis Andersen
03bf3b30a1 Update changelog 2020-01-16 13:48:35 +01:00
Jesper Louis Andersen
6032b5839d Provide documentation 2020-01-16 13:47:41 +01:00
Jesper Louis Andersen
e6cb85fb24 Merge branch 'master' of github.com:syfgkjasdkn/enacl 2020-01-16 13:45:31 +01:00
Jesper Louis Andersen
288d51ace7 Bump changelog 2020-01-16 13:42:19 +01:00
Jesper Louis Andersen
25d411aa7d Merge branch 'fix-constant-and-more-tests' of github.com:aeternity/enacl 2020-01-16 13:27:58 +01:00
Jesper Louis Andersen
7f8e0a0e07 Merge branch 'xchacha20' of github.com:ECrownofFire/enacl 2020-01-16 13:15:54 +01:00
Jesper Louis Andersen
aaa5827613 Maintain CHANGELOG a bit 2020-01-15 16:17:44 +01:00
Jesper Louis Andersen
bb703d0c35 Bump CONTRIBUTORS 2020-01-15 16:17:00 +01:00
Jesper Louis Andersen
600020620b Merge branch 'master' of github.com:ECrownofFire/enacl 2020-01-15 16:11:30 +01:00
Jesper Louis Andersen
97ee4bbdcf Use randombytes_uint32
Better name. Says what you are getting.
2020-01-15 14:05:25 +01:00