110 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
Hans Svensson
fa94eaf6f6 Add access to secretbox_easy/easy_open functions
They are just a simplification of the secretbox API, thus it does
not provide any new functionality. But it helps mapping function
names to libsodium documentation.
2022-08-19 13:23:29 +02:00
Bryan Paxton
0351de9882 add upgrade and unload handlers 2020-07-28 18:30:59 -05:00
Bryan Paxton
e18f9b7337 Ensure we never return 1 from sodium_init() onload
sodium_init() will return 0 on success, -1 on failure, and 1 if sodium is
already loaded and initialized (which is not an error). In the case
where libsodium is already initialized and the system is restarted we
may return 1 from onload nif function resulting in a crash.

- change the call to sodium_init() to check for an error return (-1) and
  return -1 explicitly in this case, otherwise always return zero at the
  end of our onload function.
2020-07-26 15:09:53 -05:00
Jesper Louis Andersen
23bd40a4b3 Netpick the include path order 2020-06-09 12:16:59 +02:00
Jesper Louis Andersen
9258d8b6ad Merge remote-tracking branch 'kuon/patch-2' 2020-06-09 12:11:13 +02:00
Jesper Louis Andersen
5ea33643da Merge remote-tracking branch 'kuon/patch-1' 2020-06-09 12:08:21 +02:00
Nicolas goy
4775270d76 Basic KDF functions 2020-04-19 19:07:23 +02:00
Nicolas goy
00f895b488 Allow specifying algorithm for pwhash 2020-04-17 14:31:35 +02:00
Nicolas goy
a001404877 Add pwhash_SALTBYTES/0 2020-04-17 13:52:33 +02:00
Alexander Malaev
e32c923822 Add crypto_secretstream_* functions. 2020-03-02 10:28:45 +03:00
Jesper Louis Andersen
78621356ec Split extension functions away 2020-02-05 12:08:28 +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
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
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
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
d3c033c4e6 Split off password hashing 2020-01-20 14:38:20 +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
d7e83dd569 Track outlen inside the generichash wrapper 2020-01-17 16:24:51 +01:00
Jesper Louis Andersen
f5918c0156 Fix compilation 2020-01-17 16:03:30 +01:00
Jesper Louis Andersen
d5bb24e671 Start splitting the library into its parts 2020-01-17 15:46:38 +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
3f284be0cb Merge branch 'sign-seed-keypair' of github.com:termoose/enacl 2020-01-16 15:21:50 +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
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
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
Jesper Louis Andersen
3c8d54d87b Merge branch 'master' of github.com:jlouis/enacl 2020-01-15 14:01:32 +01:00
Jesper Louis Andersen
f9d6034e84 Implement missing random functions* enacl:randombytes_int32/0* enacl:randombytes_uniform/1 2020-01-15 13:56:00 +01:00
Jesper Louis Andersen
e66855c029 Use LLVM style C-formattting 2020-01-15 13:21:51 +01:00
Garry Hill
279c2c32c8
Add support for multi-part signatures 2019-11-20 12:11:21 +00:00
Ole Andre Birkedal
6f4a0c2521 Added bindings for crypto_sign_seed_keypair in libsodium 2019-06-15 14:29:15 +02:00
Tino Breddin
26180f42c0 Add win32 support
Replace Make-based compilation of the nif to using rebar's port
compiler.
2018-11-29 11:29:40 +01:00
ECrownofFire
2b183e1974
Add support for aead_xchacha20poly1305 2018-11-25 11:30:34 -05:00
alsdiufgoaiwuegflweuvflasjkdhvlajhsdfg666272727asfgfdsagdlsafg
3442655c5b add crypto_sign_ed25519_sk_to_pk 2018-11-22 13:04:24 +00:00
Hans Svensson
1121321573 Generic hash state needs to be 64-byte aligned
At least according to:
  https://libsodium.gitbook.io/doc/hashing/generic_hashing

We noticed crashes when it was not 16-byte aligned - probably is
architecture dependent. This makes the safe choice and always 64-byte
align it.
2018-11-08 10:44:02 +01:00
ECrownofFire
4afa6fc093
Add checks for ops/mem limit sizes 2018-10-27 23:25:23 -04:00
ECrownofFire
26f4a40eb4
Mark pwhash functions as CPU bound 2018-10-27 23:25:16 -04:00
ECrownofFire
07bcd87294
Add choice of ops and mem limits to pwhash 2018-10-27 23:23:16 -04:00
ECrownofFire
d779071285
Add choice of ops and mem limits to pwhash_str
It natively checks atoms, which is kinda messy, but it avoids having to
export the libsodium pwhash constants, which is nice.
2018-10-27 23:22:55 -04:00
Thomas Arts
40fde1807b Variable is assigned but never used
This is just a warning, but elliminating warnings makes the code go cleanly through clang static code analyzer.
2018-06-13 07:03:04 +02:00