]> git.codecow.com Git - Monocypher.git/log
Monocypher.git
4 years agodoc: Use canonical spelling of ChaCha20
Fabio Scotoni [Fri, 11 Jun 2021 18:33:40 +0000 (20:33 +0200)]
doc: Use canonical spelling of ChaCha20

Spelled with two capital Cs according to Daniel J. Bernstein. "ChaCha,
a variant of Salsa20." Workshop Record of SASC 2008: The State of the
Art of Stream Ciphers.

4 years agoAdvertise public key cryptography in the manual
Loup Vaillant [Sun, 6 Jun 2021 21:47:11 +0000 (23:47 +0200)]
Advertise public key cryptography in the manual

Followup on the modifications of the README: if users can't make the
connection between public key cryptography and key exchange there, they
won't make it either when reading the manual (which by the way is
automatically copied to the website).

4 years agoFixed local variable shadowing
Loup Vaillant [Fri, 4 Jun 2021 21:51:20 +0000 (23:51 +0200)]
Fixed local variable shadowing

In crypto_x25519_inverse(), line 2949 and 2953, we use the ZERO macro in
a context where the enclosing scope already defines the varible `i`.

Turns out ZERO defines `i` for internal use in an enclosed scope. This
trigger a warning in some compilers about variable shadowing: declaring
a local variable with the same name as an enclosing local variable. This
warning is especially annoying when combined with -Werror.

To prevent this, the macros COPY and ZERO have been modified so they use
a variable name that is unlikely to be used anywhere else (`i__`).

4 years agoAdvertise Monocypher's features more clearly
Loup Vaillant [Fri, 4 Jun 2021 21:21:23 +0000 (23:21 +0200)]
Advertise Monocypher's features more clearly

For the second time, I've stumbled upon a user that believed Monocypher
did not support public key cryptography, despite the presence of a
fairly high-level key exchange API.

Looking at the README and website, I noticed that while key exchange is
fairly well publicised, "public key cryptography" is not.  I suspect
many users simply don't know that key exchange is a valid way to do
public key cryptography.  In hindsihght, we should not expected them to.

Let's not dwell on how many potential users we may have lost to this
oversight.  Hopefully, writing "Public key cryptography" directly will
help people notice.

4 years agoDefine fe_invert() in terms of invsqrt()
Loup Vaillant [Sat, 22 May 2021 13:30:02 +0000 (15:30 +0200)]
Define fe_invert() in terms of invsqrt()

Pros:
- The code is a couple lines shorter.
- Stack usage may be lowered a tiny little bit (we saved two temporary
  field elements).

Cons:
- Inversion is one field multiplication slower.

Note that fully optimised inversion can be 6 field multiplications
faster than the current version. It would cost quite a bit of code
though (we'd need a dedicated addition chain).

4 years agoMerge pull request #211 from fscoto/master+doc-incremental
Loup Vaillant [Tue, 25 May 2021 18:15:36 +0000 (20:15 +0200)]
Merge pull request #211 from fscoto/master+doc-incremental

doc: Compute secret/public key in some examples

4 years agoInstall advanced man pages
Loup Vaillant [Tue, 25 May 2021 18:11:47 +0000 (20:11 +0200)]
Install advanced man pages

Note that deprecated man pages are omitted.
I believe we should not clutter man pages with them.
Advanced functions however should have their place in the user manual.

4 years agoClarified wording in incremental signatures man page
Loup Vaillant [Tue, 25 May 2021 18:08:47 +0000 (20:08 +0200)]
Clarified wording in incremental signatures man page

Thanks Fabio for suggestions on this patch.
(Any error is still mine, though.)

4 years agodoc: Compute secret/public key in some examples
Fabio Scotoni [Tue, 25 May 2021 14:51:41 +0000 (16:51 +0200)]
doc: Compute secret/public key in some examples

crypto_sign_init_first_pass(3monocypher) gets two initializations of sk
and pk.
They're long-lived keys, but at least now it's possible to run the
example without wondering why nothing works.

4 years agoSimplified crypto_x25519_dirty_small() a tiny bit
Loup Vaillant [Sat, 22 May 2021 13:46:44 +0000 (15:46 +0200)]
Simplified crypto_x25519_dirty_small() a tiny bit

To give the same results as crypto_x25519_dirty_fast(), we originally
multiplied the cofactor by 5 before we multiplied it by L. I noticed
however that this multiplication by 5 could be baked in the base point
itself, and simplifies the computation a little bit.

This also saves a single MUL instruction.

4 years agoExpand Blake2b tests to full length keys and hashes
Loup Vaillant [Fri, 23 Apr 2021 12:08:46 +0000 (14:08 +0200)]
Expand Blake2b tests to full length keys and hashes

4 years agoTypo
Loup Vaillant [Sun, 18 Apr 2021 14:54:43 +0000 (16:54 +0200)]
Typo

4 years agoTest many combinations of input lengths for blake2b
Loup Vaillant [Sun, 18 Apr 2021 14:54:19 +0000 (16:54 +0200)]
Test many combinations of input lengths for blake2b

5 years agoUse official Blake2b test vectors
Loup Vaillant [Thu, 1 Apr 2021 09:19:58 +0000 (11:19 +0200)]
Use official Blake2b test vectors

Should have done this years ago. The test vectors we had were pretty
good, but the official ones are, well, official.

Note that we kept a good deal of our own vectors: while the official
test vectors tested all possible key sizes, they did not test all
possible hash sizes or all possible key sizes.

5 years agoAdded tests vectors for Blake2b
Loup Vaillant [Wed, 31 Mar 2021 19:42:13 +0000 (21:42 +0200)]
Added tests vectors for Blake2b

- We tested with no key, and an empty message.
- We tested with no key, and a non-empty message.
- We tested with a key, and a non-empty message.
- We did *not* test with a key and an empty message.

Well, now we do. Libsodium seems to agree with us. Phew.

5 years agoSpeed benchmark: fixed buffer overflow
Loup Vaillant [Fri, 5 Mar 2021 11:02:24 +0000 (12:02 +0100)]
Speed benchmark: fixed buffer overflow

5 years agoArgon2i: remove useless intermediate block
Loup Vaillant [Fri, 19 Feb 2021 13:33:58 +0000 (14:33 +0100)]
Argon2i: remove useless intermediate block

5 years agoTests suite: fixed C++ compatibility
Loup Vaillant [Sun, 27 Dec 2020 21:23:51 +0000 (22:23 +0100)]
Tests suite: fixed C++ compatibility

5 years agoUpdated CHANGELOG
Loup Vaillant [Sun, 27 Dec 2020 20:50:26 +0000 (21:50 +0100)]
Updated CHANGELOG

5 years agoMerge pull request #203 from fscoto/master+chacha20-doc
Loup Vaillant [Sun, 27 Dec 2020 13:55:09 +0000 (14:55 +0100)]
Merge pull request #203 from fscoto/master+chacha20-doc

crypto_ietf_chacha20: note nonce overflow handling

5 years agocrypto_ietf_chacha20: note nonce overflow handling
Fabio Scotoni [Sun, 27 Dec 2020 12:28:37 +0000 (13:28 +0100)]
crypto_ietf_chacha20: note nonce overflow handling

IETF ChaCha20 has a 32-bit counter.
This means a practical limit of 256 GiB of data for each nonce.
Additionally, IETF QUIC seems to require being able to handle
0xffffffff (I-D.draft-ietf-quic-tls-33 § 5.4.4),
thus getting very close to the overflow,
though not triggering it.

Unlike libsodium and other libraries, we do not have the option to
panic and take down whatever process is running the code and triggering
the overflow condition because Monocypher is neither allowed to use the C
standard library nor allowed to invoke undefined behavior to cause a
crash;
the applicable RFC provides no guidance what to do in this case, either.

Therefore, staying within the (nonce, counter) limits is necessarily
application responsibility;
it is an invariant that, when voided, Monocypher is allowed to do
anything,
similar to the non-guarantee we make for the crypto_blake2b family
and the crypto_argon2i family.

While already here, fix the wrong function prototype in the synopsis.

5 years agoDefined IETF Chacha20 in terms of DJB Chacha20
Loup Vaillant [Fri, 25 Dec 2020 22:50:06 +0000 (23:50 +0100)]
Defined IETF Chacha20 in terms of DJB Chacha20

- It's simpler.
- It makes clear that only the initialisation differ.
- It allows us to inline chacha20_core() and gain a few more lines.

5 years agoTests: fixed array size mismatch warning
Loup Vaillant [Tue, 22 Dec 2020 17:01:00 +0000 (18:01 +0100)]
Tests: fixed array size mismatch warning

5 years agoFix dead store
Loup Vaillant [Wed, 16 Dec 2020 08:33:47 +0000 (09:33 +0100)]
Fix dead store

Fixes #201

5 years agoRemoved spurious comment
Loup Vaillant [Sun, 6 Dec 2020 21:10:05 +0000 (22:10 +0100)]
Removed spurious comment

5 years agoRestricted TIS-CI to the most different platforms
Loup Vaillant [Fri, 4 Dec 2020 23:19:40 +0000 (00:19 +0100)]
Restricted TIS-CI to the most different platforms

We don't care about floating points & such, so we only need to select
a few platforms among all proposed.  This change cuts the number of
platforms by half.

5 years agoTweaked EdDSA signature pre-computed table
Loup Vaillant [Fri, 4 Dec 2020 22:21:02 +0000 (23:21 +0100)]
Tweaked EdDSA signature pre-computed table

Moved from a single 5-bit comb to a dual 4-bit comb.  The size of the
comb is unchanged, but we perform fewer operations.

Before:
- 50 doublings, 51 additions (101 operations)
- 51 16-way constant time lookups
After:
- 30 doublings, 62 additions (92 operations)
- 62 8-way constant time lookups

Note: I hoped for a 6% speedup, barely observed 3.5%. I suspect this is
because additions, even from pre-computed tables, cost a little more
than doublings.

Note: we could save an additional addition by assuming scalars modulo L
all fit in 252 bits.  They do not, but if we pick one at random, they
will in practice (with 2^-128 probability of being wrong, i.e. never).

This would work well in EdDSA, where the scalar is a hash of the private
key.  Finding a private key that makes the scalar overflow 252 bits is
about as hard as breaking a 128-bit key, which we can safely assume will
never happen by accident.

However, this scalar multiplication is also used in the dirty public key
generation, which we use to create hidden X25519 keys with Elligator
(from Edwards, because it's twice as fast as the Montgomery ladder).
Here, users provide the scalar directly. Overflowing 252 bits *can*
happen by accident, if users shoot themselves in the foot with a
non-random scalar.

The risk is small, but a measly 1% performance is not worth leaving
ourselves open to subtle corner cases like that.

5 years agoFaster reduction modulo L
Loup Vaillant [Sun, 29 Nov 2020 20:27:25 +0000 (21:27 +0100)]
Faster reduction modulo L

Replaced TweetNaCl's code by Barrett reduction.

- mod_l(), reduce(), and mul_add() use less stack.
- mod_l(), reduce(), and mul_add() are now much faster.
- Signature generation is noticeably faster (~7% on my Skylake laptop).
- Now I understand all the code. No more black boxes.

The change cost a total of 8 lines of code.

5 years agoAdded speed benchmark for ed25519-donna
Loup Vaillant [Wed, 25 Nov 2020 22:11:53 +0000 (23:11 +0100)]
Added speed benchmark for ed25519-donna

5 years agos/Monocypher/Libsodium in a string
Loup Vaillant [Wed, 25 Nov 2020 21:55:57 +0000 (22:55 +0100)]
s/Monocypher/Libsodium in a string

5 years agoUpdate CHANGELOG for next version
Loup Vaillant [Mon, 9 Nov 2020 22:57:06 +0000 (23:57 +0100)]
Update CHANGELOG for next version

5 years agoRemove TIS-CI from the tarball
Loup Vaillant [Mon, 9 Nov 2020 22:56:23 +0000 (23:56 +0100)]
Remove TIS-CI from the tarball

5 years agoMore uniform TIS-CI file names
Loup Vaillant [Mon, 9 Nov 2020 22:55:15 +0000 (23:55 +0100)]
More uniform TIS-CI file names

5 years agoMerge pull request #200 from fscoto/master+fix-elligator-comment-typo
Loup Vaillant [Mon, 9 Nov 2020 16:57:46 +0000 (17:57 +0100)]
Merge pull request #200 from fscoto/master+fix-elligator-comment-typo

elligator.py: fix comment typo

5 years agoTypos
Loup Vaillant [Mon, 9 Nov 2020 16:42:23 +0000 (17:42 +0100)]
Typos

5 years agoelligator.py: fix comment typo
Fabio Scotoni [Mon, 9 Nov 2020 16:39:11 +0000 (17:39 +0100)]
elligator.py: fix comment typo

5 years agoStreamlined TIS-CI dirty X25519 test
Loup Vaillant [Mon, 9 Nov 2020 15:50:52 +0000 (16:50 +0100)]
Streamlined TIS-CI dirty X25519 test

5 years agoMoved fe constant with the others
Loup Vaillant [Mon, 9 Nov 2020 13:25:29 +0000 (14:25 +0100)]
Moved fe constant with the others

5 years agoAdded test vectors from Kleshni
Loup Vaillant [Mon, 9 Nov 2020 13:04:18 +0000 (14:04 +0100)]
Added test vectors from Kleshni

Fixes #181

The MON-01-004 issue from Cure53's audit noted that Monocypher did not
compare to <https://github.com/Kleshni/Elligator-2>, which I didn't know
of at the time.  Some test vectors were added back then, but full
interoperability was not yet ascertained.  (Moreover, I though I'd added
vectors for the reverse map, and somehow didn't. This is now fixed.)

Now I have been able to generate decoding (direct map) test vectors from
Kleshni's implementation, that Monocypher matches perfectly.  For the
inverse map however, I was not so lucky: Monocypher and Kleshni disagree
on quite a few points, including those used in Kleshni's test vectors.

Some investigation revealed that currently, Kleshni's encoding (inverse
map) is not reliable.  In some cases, the round trip fails to yield the
same point we started with (and it's not just a matter of chopping off
the most significant bit).

However, Monocypher and Kleshni *do* agree on some points, which I have
added (and *checked* I have added) to the list of test vectors.  There's
just one divergence left: Monocypher fails to encode the zero point,
which is a departure from the standard (we're supposed to output the
zero representative instead).

5 years agoDocumented 2^255-19 carry propagation
Loup Vaillant [Sun, 8 Nov 2020 21:41:58 +0000 (22:41 +0100)]
Documented 2^255-19 carry propagation

Fixes #185

Carry propagation is now justified, in a way that I can personally vouch
for (I used to rely on SUPERCOP's ref10 code and proofs).

The use of arithmetic right shifts is also documented, and a workaround
has been devised in case someone somewhere uses a platforms that does
not perform sign extension. (That will never happen.)

5 years agoFixed assumption in 2^255-19 carry propagation
Loup Vaillant [Sun, 8 Nov 2020 12:17:08 +0000 (13:17 +0100)]
Fixed assumption in 2^255-19 carry propagation

Careful re-examination of the carry propagation code revealed that
SUPERCOP's invariants for fe_tobytes() were not respected: there is a
possibility that the inputs slightly outrange the set of input for which
SUPERCOP's original proof was intended.

This happens in invsqrt(), used for EdDSA verification And Elligator,
and the reverse map of Elligator.  X25519 is unaffected.

Note that we were unable to produce a set of input that actually
triggers this range overflow.  Moreover, careful mathematical analysis
(and tests with SAGE) showed that fe_tobytes() is actually much more
tolerant than SUPERCOP's proof let on.  As far as I can tell, this
slight overflow cannot trigger any observable bug.

Still, I figured it would be a good idea to abide those invariants
anyway, if only to facilitate future audits.  To this end, I made sure
the inputs of fe_tobytes() came directly from either multiplications
(which perform a carry propagation), or constants (where carry
propagation has been pre-computed).

5 years agoTIS-CI: ensure results are correct
Loup Vaillant [Sun, 8 Nov 2020 12:01:12 +0000 (13:01 +0100)]
TIS-CI: ensure results are correct

5 years agoLighter TIS-CI tests
Loup Vaillant [Sun, 8 Nov 2020 11:50:03 +0000 (12:50 +0100)]
Lighter TIS-CI tests

5 years agoOverhauled TIS-CI test suite
Loup Vaillant [Sat, 7 Nov 2020 23:51:31 +0000 (00:51 +0100)]
Overhauled TIS-CI test suite

5 years agoTests: fixed tweak coverage for Elligator.
Loup Vaillant [Sat, 7 Nov 2020 23:22:09 +0000 (00:22 +0100)]
Tests: fixed tweak coverage for Elligator.

Shifting the index by 6 caused a reuse of one bit, leading to 4
different configurations instead of 8.
Shifting by 5 means we are using the 3 least significant bits of the
index, as was always intended.

5 years agoFixed tis-ci.c declarations
Loup Vaillant [Sat, 7 Nov 2020 11:20:28 +0000 (12:20 +0100)]
Fixed tis-ci.c declarations

5 years agoRemoved non-standard empty array
Loup Vaillant [Sat, 7 Nov 2020 11:05:05 +0000 (12:05 +0100)]
Removed non-standard empty array

5 years agoManual: fixed old HChacha20 function name
Loup Vaillant [Thu, 5 Nov 2020 18:37:35 +0000 (19:37 +0100)]
Manual: fixed old HChacha20 function name

5 years agoManual: function prototype typo
Loup Vaillant [Thu, 5 Nov 2020 18:25:20 +0000 (19:25 +0100)]
Manual: function prototype typo

5 years agoTests: all messages to standard ouput
Loup Vaillant [Mon, 2 Nov 2020 16:58:05 +0000 (17:58 +0100)]
Tests: all messages to standard ouput

5 years agoNever ignore test failures
Loup Vaillant [Mon, 2 Nov 2020 12:44:20 +0000 (13:44 +0100)]
Never ignore test failures

5 years agoAdded vector based Chacha20 tests
Loup Vaillant [Sun, 1 Nov 2020 17:56:06 +0000 (18:56 +0100)]
Added vector based Chacha20 tests

5 years agoRe-ignore tests/vectors.h
Loup Vaillant [Thu, 29 Oct 2020 21:31:03 +0000 (22:31 +0100)]
Re-ignore tests/vectors.h

5 years agosimplified TEST macro
Loup Vaillant [Thu, 29 Oct 2020 21:30:42 +0000 (22:30 +0100)]
simplified TEST macro

We'll no longer need the entry points, TIS-CI will have dedicated tests

5 years agoReworked test vectors header format
Loup Vaillant [Mon, 26 Oct 2020 16:45:12 +0000 (17:45 +0100)]
Reworked test vectors header format

- Removed the header from git (we will no longer need it)
- Replaced the direct arrays by character strings in hexadecimal format.

That last one is an attempt to make those vectors more readable and
smaller (vectors.h is the biggest source of bloat in the tarballs).

5 years agoMerge pull request #195 from fscoto/master+doc-malleability
Loup Vaillant [Sun, 4 Oct 2020 11:25:22 +0000 (13:25 +0200)]
Merge pull request #195 from fscoto/master+doc-malleability

doc: clarify signature malleability in crypto_sign

5 years agodoc: clarify signature malleability in crypto_sign
Fabio Scotoni [Sun, 4 Oct 2020 04:44:49 +0000 (06:44 +0200)]
doc: clarify signature malleability in crypto_sign

Fixes #189; see the discussion there for details.

5 years agoDedicated test suite for TIS-CI
Loup Vaillant [Wed, 30 Sep 2020 19:48:46 +0000 (21:48 +0200)]
Dedicated test suite for TIS-CI

TIS-CI needs a dedicated test suite, different from the regular one.  So
I'm following my Chief Testing Officer's advice, and stole his work like
I should have from the very beginning.

We'll need to refine this, but this should be a good first step.

5 years agoMerge pull request #191 from fscoto/master+doc-malleability
Loup Vaillant [Sat, 26 Sep 2020 10:52:55 +0000 (12:52 +0200)]
Merge pull request #191 from fscoto/master+doc-malleability

HISTORY: note 2.0.5 rejecting modified signatures

5 years agoMerge pull request #192 from fscoto/master+argon2i-oops-the-params-also-matter
Loup Vaillant [Sat, 26 Sep 2020 10:27:41 +0000 (12:27 +0200)]
Merge pull request #192 from fscoto/master+argon2i-oops-the-params-also-matter

argon2i: Note that all parameters influence output

5 years agoargon2i: Note that all parameters influence output
Fabio Scotoni [Sat, 26 Sep 2020 06:38:50 +0000 (08:38 +0200)]
argon2i: Note that all parameters influence output

Sparked by #190.

5 years agoHISTORY: note 2.0.5 rejecting modified signatures
Fabio Scotoni [Sat, 26 Sep 2020 06:26:58 +0000 (08:26 +0200)]
HISTORY: note 2.0.5 rejecting modified signatures

Change introduced in 974e55d21c1fac7a2e21f91cb7174601b653180a and
24f4be7acc3ec7ff613715a7a97597e587f6d6d8.

The actual reasons to introduce this were actually performance-related.

Sparked by #189.

5 years agodocumented make install USE_ED25519=true
Loup Vaillant [Tue, 22 Sep 2020 19:36:49 +0000 (21:36 +0200)]
documented make install USE_ED25519=true

5 years agoFixed copy in man2html.sh
Loup Vaillant [Mon, 24 Aug 2020 17:20:28 +0000 (19:20 +0200)]
Fixed copy in man2html.sh

5 years agoPoly1305 carry propagation now uses loops
Loup Vaillant [Thu, 13 Aug 2020 15:50:07 +0000 (17:50 +0200)]
Poly1305 carry propagation now uses loops

Mostly for consistency with 25519 arithmetic.
Also slightly reduces binary size in some cases, most notably -Os.

5 years agoSmall carry simplification
Loup Vaillant [Thu, 13 Aug 2020 14:34:51 +0000 (16:34 +0200)]
Small carry simplification

5 years agoMore readable Blake2b unrolled loop
Loup Vaillant [Fri, 31 Jul 2020 21:11:33 +0000 (23:11 +0200)]
More readable Blake2b unrolled loop

5 years agoFixed compiler warning
Loup Vaillant [Fri, 31 Jul 2020 21:04:16 +0000 (23:04 +0200)]
Fixed compiler warning

Fixes #187

Note: w should remain a signed integer, so w-1 is correctly compared in
the FOR_T loop.

5 years agoNo longer ignore tests/vectors.h (for TIS-CI)
Loup Vaillant [Tue, 28 Jul 2020 18:18:12 +0000 (20:18 +0200)]
No longer ignore tests/vectors.h (for TIS-CI)

5 years agoFixed tis.config (3)
Loup Vaillant [Tue, 28 Jul 2020 13:55:39 +0000 (15:55 +0200)]
Fixed tis.config (3)

5 years agoFixed tis.config (2)
Loup Vaillant [Tue, 28 Jul 2020 13:53:08 +0000 (15:53 +0200)]
Fixed tis.config (2)

5 years agoFixed tis.config
Loup Vaillant [Tue, 28 Jul 2020 13:47:54 +0000 (15:47 +0200)]
Fixed tis.config

5 years agoAdded TIS-CI support
Loup Vaillant [Tue, 28 Jul 2020 13:42:25 +0000 (15:42 +0200)]
Added TIS-CI support

5 years agoPrepared entry points for TIS-CI
Loup Vaillant [Tue, 28 Jul 2020 12:47:09 +0000 (14:47 +0200)]
Prepared entry points for TIS-CI

5 years agoSeparated basic/advanced functions in different folders
Loup Vaillant [Tue, 28 Jul 2020 00:08:28 +0000 (02:08 +0200)]
Separated basic/advanced functions in different folders

Addresses MON-01-005
Fixes #182

5 years agoBetter low/high level separation in the header.
Loup Vaillant [Mon, 27 Jul 2020 11:10:32 +0000 (13:10 +0200)]
Better low/high level separation in the header.

Partially addreses MON-01-005.  #182

Also added various warnings in comments.

Also pretend the min number of Argon2i iterations passes is 3.
It's not true, but any less would not be secure.

5 years agoArgon2i hash is now allowed to overlap with the work area
Loup Vaillant [Fri, 10 Jul 2020 22:46:38 +0000 (00:46 +0200)]
Argon2i hash is now allowed to overlap with the work area

Fixes #183

Almost all of Monocypher allows arguments to overlap. Users may come to
expect it, and misuse those who don't allow such an overlap. (Chacha20
and AEAD are an exception, but (i) portability concerns prevents us to
allow it properly, and (ii) disallowed overlaps tend to trigger visible
corruptions immediately.)

Before, having the hash coincide with the working area meant the output
was always zero.  All passwords have the same hash.  Therefore all
passwords are correct.  Oops.  For the record, I made the mistake, and
caught the bug only days later, by pure luck.

Now overlap is allowed, and gives the right result. Note that the work
area is still wiped.  The wipe just happens *before* the final hash is
computed.

5 years agoMerge pull request #184 from fscoto/master+mon-01-001
Loup Vaillant [Fri, 10 Jul 2020 22:32:33 +0000 (00:32 +0200)]
Merge pull request #184 from fscoto/master+mon-01-001

intro: macOS, illumos and Solaris have arc4random_buf(3)

Fix #180

5 years agointro: macOS, illumos and Solaris have arc4random_buf(3)
Fabio Scotoni [Fri, 10 Jul 2020 18:14:46 +0000 (20:14 +0200)]
intro: macOS, illumos and Solaris have arc4random_buf(3)

5 years agoBetter test for crypto_x25519_inverse()
Loup Vaillant [Sun, 5 Jul 2020 09:46:13 +0000 (11:46 +0200)]
Better test for crypto_x25519_inverse()

5 years agoRemoved redundant all zero test vector
Loup Vaillant [Mon, 29 Jun 2020 18:13:15 +0000 (20:13 +0200)]
Removed redundant all zero test vector

5 years agoAdded Kleshni/Elligator-2 test vectors
Loup Vaillant [Sun, 28 Jun 2020 22:40:50 +0000 (00:40 +0200)]
Added Kleshni/Elligator-2 test vectors

An auditor recently told me about the following repository on GitHub:

  https://github.com/Kleshni/Elligator-2/

I was able to steal a couple test vectors from them.  Not all of them
unfortunately:

- Some representative exceed 2^254, and Monocypher do not decode
  negative representatives.  Instead, it assumes it has a positive
  representative, and clears the two most significant bits before
  decoding.

- It is not clear yet what encoding does, and some points in the (few)
  test vectors have their most significant bit set. Monocypher ignores
  the most significant bit of curve point, basically assumes they are
  all below 2^255 - 19.  Adding those points will require tweaking
  similar to the tweaking applied to the Hash to Curve RFC draft test
  vectors.

5 years agoAdded extern "C" to optional & deprecated files
Loup Vaillant [Mon, 15 Jun 2020 21:54:21 +0000 (23:54 +0200)]
Added extern "C" to optional & deprecated files

5 years agoAdjusted changelog date
Loup Vaillant [Mon, 15 Jun 2020 21:41:29 +0000 (23:41 +0200)]
Adjusted changelog date

5 years agoUpdated changelog
Loup Vaillant [Fri, 12 Jun 2020 19:43:55 +0000 (21:43 +0200)]
Updated changelog

5 years agoOptimised key loading in Blake2b
Loup Vaillant [Mon, 8 Jun 2020 15:46:16 +0000 (17:46 +0200)]
Optimised key loading in Blake2b

The idea is to avoid the slow loading code in the internal
blake2b_update() function, and avoid the overhead of calling
crypto_blake2b_update().

It's a micro-optimisation that in principle shouldn't matter that much,
but it might help a bit if we repeatedly hash small messages with a key,
as can happen in authenticated key exchanges like Monokex.

5 years agoRemoved #define from vectors.h
Loup Vaillant [Fri, 29 May 2020 21:40:50 +0000 (23:40 +0200)]
Removed #define from vectors.h

Also reduced the size of vectors.h by removing indirections and printing
numbers in decimal form. Hopefully this will make the tarball a little
smaller.

5 years agoFixed various compiler warnings
Loup Vaillant [Fri, 29 May 2020 18:09:41 +0000 (20:09 +0200)]
Fixed various compiler warnings

Fixes #179

5 years agoMerge pull request #178 from fscoto/master+fix-includes
Loup Vaillant [Sun, 24 May 2020 18:48:18 +0000 (20:48 +0200)]
Merge pull request #178 from fscoto/master+fix-includes

doc: Fix .In for optional code

5 years agodoc: Fix crypto_ed25519_public_key function name
Fabio Scotoni [Sun, 24 May 2020 13:20:39 +0000 (15:20 +0200)]
doc: Fix crypto_ed25519_public_key function name

5 years agodoc: Fix .In for optional code
Fabio Scotoni [Sun, 24 May 2020 10:54:05 +0000 (12:54 +0200)]
doc: Fix .In for optional code

5 years agoREADME: Monocypher is not compatible with NaCl
Loup Vaillant [Tue, 12 May 2020 09:49:44 +0000 (11:49 +0200)]
README: Monocypher is not compatible with NaCl

Fixes #177

This removes the suggestion that we can replace Monocypher with NaCl.
We cannot, only Libsodium is compatible.

5 years agoCosmetic. compact grouping of vtables
Loup Vaillant [Sat, 2 May 2020 20:18:15 +0000 (22:18 +0200)]
Cosmetic. compact grouping of vtables

5 years agoTurned ALIGN into a function
Loup Vaillant [Sat, 2 May 2020 17:25:21 +0000 (19:25 +0200)]
Turned ALIGN into a function

5 years agoMerge pull request #173 from fscoto/master+reproball
Loup Vaillant [Wed, 22 Apr 2020 15:57:26 +0000 (17:57 +0200)]
Merge pull request #173 from fscoto/master+reproball

Make tarball generation reproducible

5 years agodist.sh: Make tarball reproducible
Fabio Scotoni [Wed, 22 Apr 2020 14:35:05 +0000 (16:35 +0200)]
dist.sh: Make tarball reproducible

5 years agoMake Elligator test vector gen deterministic
Fabio Scotoni [Wed, 22 Apr 2020 14:33:03 +0000 (16:33 +0200)]
Make Elligator test vector gen deterministic

This paves the way for reproducible tarballs.
Since the test vectors must be generated for a complete tarball,
these must agree everywhere.

The lack of actual randomness is harmless because these are test
vectors, not actual usages of Elligator.

5 years agoMore readable Blake2 round function
Loup Vaillant [Mon, 20 Apr 2020 14:29:07 +0000 (16:29 +0200)]
More readable Blake2 round function

5 years agoFixed (NULL + 0) undefined behaviour
Loup Vaillant [Mon, 20 Apr 2020 11:59:31 +0000 (13:59 +0200)]
Fixed (NULL + 0) undefined behaviour

It appears that arithmetic on NULL pointers is undefined, even when we
just add zero.

Monocypher generally allows input buffers to be NULL pointers if their
length is zero.  This is because we never dereference those pointers in
this case.  Likewise, we should not perform any arithmetic on them.

The fix is to return immediately when the input buffer length is zero.

5 years agoMerge pull request #171 from stevefan1999-personal/patch-1
Loup Vaillant [Sat, 18 Apr 2020 15:41:39 +0000 (17:41 +0200)]
Merge pull request #171 from stevefan1999-personal/patch-1

Add extern C if C++ presents