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
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
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
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
Thomas Arts
04b8fa3ecb
Dangerous use of constant
2018-06-12 14:26:14 +02:00
Jesper Louis Andersen
edd95498d1
Fix pwhash_str* functions.
...
The API for pwhash_str returns a cstring in the output buffer. These
are null terminated. However, we return the full buffer as a binary
back to Erlang. This means that we have a buffer with 0'es in the end.
The tests take this buffer and passes it back in as is. Hence all the
tests pass. However, it is conceivable that if we write said buffer to
disk somewhere, we are not going to write those 0's out.
When we then load the ASCII-armored Argon2 string into memory again,
it is not 0-terminated as a cstring should be, and this produces
errors all over the place.
The fix is twofold:
* Return the full buffer to Erlang, but use binary:split/2 to create a
subbinary with the relevant part.
* Add a 0 in the end of ASCII Argon2 string before passing it to
libsodium
Since we are looking at pwhashing, and Argon2, we expect the
computational problem to be memory bound. Thus, spending a bit more
work in memory is not going to have any considerable impact on the
speed of this system.
2018-05-21 15:21:09 +02:00
Jesper Louis Andersen
fb7de2cbb4
Merge pull request #21 from aeternity/add_aead_chacha20poly1305
...
Add AEAD chacha20poly1305
2018-05-20 19:38:14 +02:00
Hans Svensson
2f50ba6289
Also expose crypto_curve25519_scalarmult_base
2018-03-05 15:33:17 +01:00
Hans Svensson
9dfbe8cc90
Expose AEAD ChaCha20 Poly1305 functionality
...
Note: We expose the modern IETF version but still name it plain
aead_chacha20poly1305.
2018-03-05 09:52:39 +01:00
Hans Svensson
a5dab7acf0
Whitespace
2018-03-01 08:41:53 +01:00
daveed-al
cd183efd34
pwhash_str_verify respects specs second param as iodata()
2018-01-31 18:41:31 +08:00
Zane Beckwith
bf4d61680c
Change size_t variables to unsigned int's.
...
These variables are being initialized via calls to `enif_get_uint`,
so it's safer to declare them as unsigned int's rather than size_t's.
Their being used in calls to `enif_alloc_binary`, which takes a size_t
as its size.
However, the resulting ErlNifBinary keeps its size as an unsigned int,
so asking for a size that's an unsigned int should be safe.
This would be problematic in the case where sizeof(size_t) <
sizeof(unsigned), which would mean we're getting fewer bytes allocated
than expected.
Perhaps an explicit check for, for example, `hashSize > MAX_SIZE` would
be good here?
2017-08-14 17:01:50 +00:00
Irina Guberman
e524c2d5c8
Fix 32-bit arch warnings: replace enif_get_uint64 with enif_get_uint
2017-08-12 16:46:47 -05:00
Venkatakumar Srinivasan
ba640b0659
Added generic hash NIF
2017-08-11 13:32:04 -05:00
Venkatakumar Srinivasan
36eedc6751
Pulled in latest version of enacl. Added nif's for password hashing functions
2017-08-11 13:32:04 -05:00
Venkatakumar Srinivasan
c938d3c6e8
Fix to pwhash_str_verify() to accept only binary arguments
2017-08-11 13:32:04 -05:00
Venkatakumar Srinivasan
ee0d800a9a
Implemented nif for crypto_pwhash_str(), crypto_pwhash_str_verify()
2017-08-11 13:32:04 -05:00