17 Commits

Author SHA1 Message Date
Hans Svensson
4eb7ec7008
Fix C-warnings (#10)
* .envrc is not for git

* Fix c code - avoid warnings

* Bump Erlang versions in Github workflows
2024-03-19 13:23:23 +01:00
Jesper Louis Andersen
96b883ceba generichash finalization
Make sure we finalize properly in
generichash and check the alive
state of objects. If they are not
alive, return the general finalized
error.
2020-02-06 16:04:23 +01:00
Jesper Louis Andersen
014d50cf47 Implement EQC for generic hashing, fix bug.
Turns out the interval we had in the
file were inverted and I was wrong
in an earlier commit. However, EQC
dutifully found the mistake, and it
is now corrected.
2020-02-06 12:18:47 +01:00
Jesper Louis Andersen
b637ba307b Streamline generichash and pwhash 2020-02-04 17:50:56 +01:00
Jesper Louis Andersen
aa2c69529a Streamlines generichashThe multi-part hash API is nowreflecting the same crypto modulefunctions in style. This is easierto use for people, I believe. 2020-02-04 13:00:16 +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
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
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
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
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
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
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
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