]> git.codecow.com Git - Monocypher.git/log
Monocypher.git
17 months agoDocument maximum AEAD message size main master
Loup Vaillant [Fri, 1 Nov 2024 09:17:00 +0000 (10:17 +0100)]
Document maximum AEAD message size

Fixes #279

17 months agoFix dead link
Loup Vaillant [Tue, 15 Oct 2024 07:14:31 +0000 (09:14 +0200)]
Fix dead link

Fixes #280

21 months agofix problamatic line
Sagar Patil [Thu, 20 Jun 2024 21:21:17 +0000 (17:21 -0400)]
fix problamatic line

22 months agoDoc: use pointers instead of arrays when size is provided
Nihal Jere [Sat, 18 May 2024 02:07:35 +0000 (21:07 -0500)]
Doc: use pointers instead of arrays when size is provided

2 years agoDoc: fixed missing 'void'
Loup Vaillant [Sun, 25 Feb 2024 22:24:01 +0000 (23:24 +0100)]
Doc: fixed missing 'void'

2 years agoDoc: fix plain_text/cipher_text inversion
Loup Vaillant [Thu, 22 Feb 2024 14:40:50 +0000 (15:40 +0100)]
Doc: fix plain_text/cipher_text inversion

2 years agoFix missing pkg-config flags
Loup Vaillant [Mon, 15 Jan 2024 21:57:21 +0000 (22:57 +0100)]
Fix missing pkg-config flags

2 years agoRemove duplicate test vector for HKDF
Loup Vaillant [Mon, 15 Jan 2024 13:38:58 +0000 (14:38 +0100)]
Remove duplicate test vector for HKDF

2 years agoFix speed benchmark bug
Loup Vaillant [Fri, 5 Jan 2024 15:41:01 +0000 (16:41 +0100)]
Fix speed benchmark bug

2 years agoJust changing the types on those two resolved everything, and tests
SethArchambault [Sat, 21 Oct 2023 23:59:11 +0000 (19:59 -0400)]
Just changing the types on those two resolved everything, and tests
pass!

--- a/src/monocypher.c
+++ b/src/monocypher.c
-u64 lane         =
+u32 lane         =
...
-u64  ref       = (window_start + z) % lane_size;
+u32  ref       = (window_start + z) % lane_size;
-u32  index     = (u32)(lane * lane_size) + (u32)ref;
+u32  index     = lane * lane_size + ref;

2 years agomake implicit typecast explicit
SethArchambault [Fri, 20 Oct 2023 00:18:14 +0000 (20:18 -0400)]
make implicit typecast explicit

This came out of adding these compile options:
`-Werror -Wall -Wextra -Wshadow -Wconversion -Wno-deprecated-declarations -Wno-unused-parameter`

/src/monocypher.c
-u32  index     = lane * lane_size + (u32)ref;
+u32  index     = (u32)(lane * lane_size) + (u32)ref;

2 years agoUpdate crypto_argon2.3monocypher - fixes errors and warnings that can lead to incorre...
Seth Archambault [Thu, 19 Oct 2023 03:20:16 +0000 (23:20 -0400)]
Update crypto_argon2.3monocypher - fixes errors and warnings that can lead to incorrect solution

Closes: #264
Fixes these issues, by allowing password array to autosize, and then making sure to drop the \0 character when determining the size of the string, and also reorders the crypto_argon2_inputs field designators to remove a warning.

```
main.cpp:83:24: error: initializer-string for char array is too long, array size is 14 but initializer has size 15 (including the null terminating character)
uint8_t password[14] = "Okay Password!";
                       ^~~~~~~~~~~~~~~~
main.cpp:87:5: warning: ISO C++ requires field designators to be specified in declaration order; field 'pass_size' will be initialized after field 'salt' [-Wreorder-init-list]
    .salt      = salt,                 /* Salt for the password */
    ^~~~~~~~~~~~~~~~~
```

2 years agoUse NULL instead of 0 for null pointers
Loup Vaillant [Tue, 17 Oct 2023 04:35:39 +0000 (06:35 +0200)]
Use NULL instead of 0 for null pointers

Turns out the standard guarantees that NULL is defined in `stddef.h`.
Contrary to what I used to believe, using it doesn't induce any further
dependency.  `0` is also guaranteed by the standard to work, but it's
less explicit and in some cases more error prone.

2 years agoWork around TIS-CI bug on x96_16
Loup Vaillant [Sat, 9 Sep 2023 14:57:07 +0000 (16:57 +0200)]
Work around TIS-CI bug on x96_16

2 years agoFix $(PREFIX) in makefiles
Loup Vaillant [Tue, 5 Sep 2023 21:02:44 +0000 (23:02 +0200)]
Fix $(PREFIX) in makefiles

Apparently the convention for the $(PREFIX) variable is to include the
leading '/'.  Leaving it out and adding it manually confuses some
package systems, and force package maintainers to patch it when their
own $(PREFIX) already starts with '/'.

2 years agoLeaner TIS-CI tests
Loup Vaillant [Sat, 2 Sep 2023 14:24:37 +0000 (16:24 +0200)]
Leaner TIS-CI tests

TIS-CI tests take forever.  It's annoying and cost them compute power
for little benefit.  A quick assesment of Monocypher reveals that the
only things we really care about are endianness and main word size.
Things like the sign of `char`, `sizeof(int)`, or `long double` are
mostly (or entirely) irrelevant.

So, all platforms supported by TIS-CI, only 5 are relevant:

- 16-bits little endian (I chose x86_16)
- 32-bits little endian (I chose x86_32)
- 32-bits big    endian (I chose sparc_32)
- 32-bits little endian (I chose rv64ifdq)
- 32-bits big    endian (I chose mips_64)

All the others are redundant.

---

Also added the missing v_x25519 test.

2 years agoFix /bin/env vs /usr/bin/env vs nothing
Loup Vaillant [Tue, 29 Aug 2023 09:12:01 +0000 (11:12 +0200)]
Fix /bin/env vs /usr/bin/env vs nothing

There's no such thing as /bin/env, though I let that slip by because my
distro redirects /bin to /usr/bin.

I believe "#! /bin/sh" is even more standard that "#! /usr/bin/env sh",
and that's what I used everywhere anyway.

2 years agoFix stupid Github CI
Loup Vaillant [Mon, 28 Aug 2023 21:29:54 +0000 (23:29 +0200)]
Fix stupid Github CI

Stupid Github CI make doesn't take environment variables into account.
We have to override them explicitly, hence the ridiculous CC="$CC".

2 years agoFix CHANGELOG typo
Loup Vaillant [Mon, 28 Aug 2023 21:23:28 +0000 (23:23 +0200)]
Fix CHANGELOG typo

2 years agoAdapt tests to optional makefile variables
Loup Vaillant [Mon, 28 Aug 2023 21:20:05 +0000 (23:20 +0200)]
Adapt tests to optional makefile variables

2 years agoFix missing void in function prototypes
Loup Vaillant [Mon, 28 Aug 2023 21:19:13 +0000 (23:19 +0200)]
Fix missing void in function prototypes

2 years agoMore readable makefile assignments
Loup Vaillant [Mon, 28 Aug 2023 21:18:18 +0000 (23:18 +0200)]
More readable makefile assignments

2 years agoRestore "Do not hardcode Makefile variables"
Loup Vaillant [Mon, 28 Aug 2023 20:28:27 +0000 (22:28 +0200)]
Restore "Do not hardcode Makefile variables"

What was not working on NixOs works out of the box on Ubuntu.
Who knows why.

This reverts commit 2a9b0d19cb4c6b18150fcf29da1e0d74ee47bbf0.

2 years agoRun valgrind without march=native
Loup Vaillant [Thu, 24 Aug 2023 17:02:14 +0000 (19:02 +0200)]
Run valgrind without march=native

Valgrind doesn't always support all relevant instructions and crashes
on some platforms, most notably github CI.

2 years agoSimplify github CI
Loup Vaillant [Thu, 24 Aug 2023 16:57:58 +0000 (18:57 +0200)]
Simplify github CI

2 years agoRevert "Do not hardcode Makefile variables"
Loup Vaillant [Thu, 24 Aug 2023 16:51:04 +0000 (18:51 +0200)]
Revert "Do not hardcode Makefile variables"

Quick tests revealed this choice was a PITA.
Maybe later.

This reverts commit 8471aeef9112d9bfadd027e1681188ee310f3df8.

2 years agoUpdate CHANGELOG
Loup Vaillant [Thu, 24 Aug 2023 16:30:15 +0000 (18:30 +0200)]
Update CHANGELOG

2 years agoDo not hardcode Makefile variables
Loup Vaillant [Thu, 24 Aug 2023 16:25:19 +0000 (18:25 +0200)]
Do not hardcode Makefile variables

Now if those variables exist from the environment, they're automatically taken as default

2 years agoAlign with spaces, not tabs
Loup Vaillant [Sun, 13 Aug 2023 09:00:32 +0000 (11:00 +0200)]
Align with spaces, not tabs

Note: this fights emacs smart-tabs default settings.

2 years agoCosmetic: braces around FOR loop body
Loup Vaillant [Sun, 13 Aug 2023 08:33:24 +0000 (10:33 +0200)]
Cosmetic: braces around FOR loop body

That's the rule, and it makes visually clearer what is part of the loop.

2 years agoFix various documentation typos & oversights
Loup Vaillant [Thu, 27 Jul 2023 15:21:30 +0000 (17:21 +0200)]
Fix various documentation typos & oversights

With the help of a (now updated) `doc_extract_examples.sh` script.
Note: We may want to integrate this script in the test suite, if we end
up writing more documentation.

Fix #260

2 years agoFix Argon2 multiple lanes bug
Loup Vaillant [Thu, 27 Jul 2023 10:36:13 +0000 (12:36 +0200)]
Fix Argon2 multiple lanes bug

Argon2 failed to conform to the reference implementation when used with
multiple lanes, rendering it useless for this compatibility use case.
The error came from the way we select the reference set:

- On the first slice of the first pass, only the current lane is valid.
- When selecting other lanes, only fully completed segments are valid.
- The previous block of *all* lanes must be excluded.

Fixes #263

2 years agoFix Argon2 allocation (test & doc)
Loup Vaillant [Wed, 26 Jul 2023 15:46:50 +0000 (17:46 +0200)]
Fix Argon2 allocation (test & doc)

2 years agoFaster Argon2 inner loop
Loup Vaillant [Mon, 3 Jul 2023 21:27:37 +0000 (23:27 +0200)]
Faster Argon2 inner loop

Compilers aren't magical. They need help to generate the best code.
Here we want to compute the following expression:

    mask = 0xffffffff;
    2 * (a & mask) * (b & mask)

The most efficient way to do this looks like this:

    u64 al = (u32)a;   // Truncate
    u64 bl = (u32)b;   // Truncate
    u64 x  = al * bl;  // 32->64 bits multiply
    u64 2x = x << 1;   // shift
    return 2x;

My compiler doesn't pick up on this, and perform a slower alternative
instead. Either the multiply by two uses an actual multiply instead of a
shift, or the shift is done first, forcing a more expensive 64->64
multiply.  More naive compilers may even do both.

Whatever the cause, I got 5% faster code on GCC 11.3.

2 years agoRemove 'volatile' from TIS tests
Loup Vaillant [Mon, 1 May 2023 11:31:03 +0000 (13:31 +0200)]
Remove 'volatile' from TIS tests

2 years agoAdd explicit crypto_wipe() test
Loup Vaillant [Mon, 1 May 2023 11:16:38 +0000 (13:16 +0200)]
Add explicit crypto_wipe() test

2 years agoOnly wrong TIS results
Loup Vaillant [Mon, 24 Apr 2023 12:27:24 +0000 (14:27 +0200)]
Only wrong TIS results

2 years agoEnable TIS results for EdDSA_pk
Loup Vaillant [Tue, 11 Apr 2023 11:47:45 +0000 (13:47 +0200)]
Enable TIS results for EdDSA_pk

2 years agoAdd EdDSA pk gen to TIS-CI
Loup Vaillant [Tue, 11 Apr 2023 08:33:42 +0000 (10:33 +0200)]
Add EdDSA pk gen to TIS-CI

2 years agotests: ASSERT(memcmp) -> ASSERT_EQUAL()
Loup Vaillant [Tue, 11 Apr 2023 08:32:55 +0000 (10:32 +0200)]
tests: ASSERT(memcmp) -> ASSERT_EQUAL()

3 years agoRevert "Enable results for inspection"
Loup Vaillant [Fri, 24 Mar 2023 07:17:28 +0000 (08:17 +0100)]
Revert "Enable results for inspection"

Enabling inspection causes some tests to run out of memory.

This reverts commit 15113e2fc498cf243bee7b4d2ebbe27232132e07.

3 years agoRevert "Modify Blake2b context input to byte buffer"
Loup Vaillant [Fri, 24 Mar 2023 00:51:10 +0000 (01:51 +0100)]
Revert "Modify Blake2b context input to byte buffer"

This reverts commit 310aab8ddf9b0a31ccc74c06ece8098769cf1231.

Turns out I failed to optimise Blake2b, and it was faster before.

3 years agoFixed NULL += 0 undefined behaviour
Loup Vaillant [Thu, 23 Mar 2023 11:02:57 +0000 (12:02 +0100)]
Fixed NULL += 0 undefined behaviour

3 years agoEnable results for inspection
Loup Vaillant [Thu, 23 Mar 2023 09:38:42 +0000 (10:38 +0100)]
Enable results for inspection

3 years agoRemove obsolete carry propagation test
Loup Vaillant [Thu, 23 Mar 2023 08:25:55 +0000 (09:25 +0100)]
Remove obsolete carry propagation test

3 years agoMakefile nitpicks
Loup Vaillant [Thu, 23 Mar 2023 08:24:20 +0000 (09:24 +0100)]
Makefile nitpicks

3 years agoModify Blake2b context input to byte buffer
Loup Vaillant [Wed, 22 Mar 2023 22:49:16 +0000 (23:49 +0100)]
Modify Blake2b context input to byte buffer

Though it requires a (safe because it's all aligned) cast at one point,
it makes the code simpler and significantly speeds up non-aligned
incremental hashes.

Surprisingly, foregoing word-by-word loading at the begining of the
update doesn't slow anything down, but forgoing it at the end *does*.
So while we align with block boundaries directly, we end up copying the
remaining words first, then the remaining bytes.

3 years agoRename align() to gap() to avoid confusion
Loup Vaillant [Wed, 22 Mar 2023 21:51:22 +0000 (22:51 +0100)]
Rename align() to gap() to avoid confusion

The name "align" made readers believe it returns the next multiple,
while in fact it's returning how much we need to get there.

The name "gap" was suggested to me, and I haven't found better. A fully
descriptive name would likely be quite long, and wouldn't preclude the
need to look the definition up anyway. (And I suspect even now one could
guess from context.)

3 years agoFaster Poly1305 (integrate loop into core rounds)
Loup Vaillant [Mon, 20 Mar 2023 16:23:52 +0000 (17:23 +0100)]
Faster Poly1305 (integrate loop into core rounds)

3 years agoThe proofs were cute, but they don't mesh well with the planned code
Loup Vaillant [Mon, 20 Mar 2023 16:22:35 +0000 (17:22 +0100)]
The proofs were cute, but they don't mesh well with the planned code

3 years agoMore stable speed tests
Loup Vaillant [Mon, 20 Mar 2023 16:21:04 +0000 (17:21 +0100)]
More stable speed tests

3 years agoAdd tinyssh speed tests
Loup Vaillant [Sun, 19 Mar 2023 21:54:48 +0000 (22:54 +0100)]
Add tinyssh speed tests

3 years ago.Lk is better than .%U for links
Loup Vaillant [Tue, 14 Mar 2023 20:46:17 +0000 (21:46 +0100)]
.Lk is better than .%U for links

Source1: https://man.openbsd.org/mdoc.7#Rs
Source2: https://man.openbsd.org/mdoc.7#Lk

3 years agoWikipedia spelling for 'little-endian'
Loup Vaillant [Tue, 14 Mar 2023 20:40:23 +0000 (21:40 +0100)]
Wikipedia spelling for 'little-endian'

3 years agoRemove last blank lines from tarball README.md
Loup Vaillant [Sun, 12 Mar 2023 20:59:59 +0000 (21:59 +0100)]
Remove last blank lines from tarball README.md

3 years agoUpdate LICENCE.md dates
Loup Vaillant [Sun, 12 Mar 2023 20:52:35 +0000 (21:52 +0100)]
Update LICENCE.md dates

Also take the opportunity to remove the external reference from the tarball.

3 years agoupdate CHANGELOG
Loup Vaillant [Mon, 6 Mar 2023 20:46:06 +0000 (21:46 +0100)]
update CHANGELOG

3 years agoSpecify incremental AEAD exact wire format
Loup Vaillant [Mon, 6 Mar 2023 17:08:14 +0000 (18:08 +0100)]
Specify incremental AEAD exact wire format

3 years agoSpecify Elligator exact wire format
Loup Vaillant [Mon, 6 Mar 2023 16:47:09 +0000 (17:47 +0100)]
Specify Elligator exact wire format

3 years agoSplit installation into 3 sub targets
Loup Vaillant [Sun, 5 Mar 2023 10:25:07 +0000 (11:25 +0100)]
Split installation into 3 sub targets

Namely:

- `install-lib`: library files and headers.
- `install-doc`: man pages.
- `install-pc` : pkg-config file.

Some users don't want to install everything.  Those who pull Monocypher
directly from git, despite strong suggestion to use a tarball instead,
can be especially annoyed at the mandoc dependency.

We could also split the library and includes, but this feels overkill.

3 years agoUpdate soname (forgot 4.0.0 breaking changes)
Loup Vaillant [Sun, 5 Mar 2023 10:16:16 +0000 (11:16 +0100)]
Update soname (forgot 4.0.0 breaking changes)

3 years agoFix Ed25519 secret_key size
Loup Vaillant [Wed, 1 Mar 2023 19:48:22 +0000 (20:48 +0100)]
Fix Ed25519 secret_key size

All EdDSA and Ed25519 secret keys are 64 bytes of course.
Fortunately this does not affect the generated code.

Fixes #258

3 years agoFix the most nitpicky Clang warnings, fix C++ compatibility
Loup Vaillant [Mon, 27 Feb 2023 14:06:24 +0000 (15:06 +0100)]
Fix the most nitpicky Clang warnings, fix C++ compatibility

This is mostly about shadowed variables.

3 years agoMove relevant parts of tests/utils.c to tests/gen
Loup Vaillant [Mon, 27 Feb 2023 13:24:05 +0000 (14:24 +0100)]
Move relevant parts of tests/utils.c to tests/gen

The main point is to remove dead code from tests/utils.c, and have the
tarball be as clean as possible.  Incidentally this also cleans up the
dependencies for test vector generation as well.

3 years agoAdd scalarbase property test (curve order)
Loup Vaillant [Sun, 26 Feb 2023 18:26:48 +0000 (19:26 +0100)]
Add scalarbase property test (curve order)

3 years agoGenerate docks with `make all`
Loup Vaillant [Sun, 26 Feb 2023 10:10:48 +0000 (11:10 +0100)]
Generate docks with `make all`

That way the docs no longer have to belong to root when we generate
them.  Some more dist.sh shenanigans were required to spare tarball
users the mandoc dependency.  Mostly making sure their doc is not
deleted when they `make clean`.

3 years agoGive myself some copyright info
Loup Vaillant [Sat, 25 Feb 2023 23:36:32 +0000 (00:36 +0100)]
Give myself some copyright info

Now I'm not exactly sure where the CAVEATS section comes from.  It dates
back to 2017, but it uses wording that was previously in the manual
(which was originally all mine).  It is possible, though I'm not sure,
that I'm misappropriating the work of @CuleX and/or @FScoto here.

Hopefully I'm not.  Or maybe future historians will judge me.

3 years agoResolve mandoc -Tlint nits
Fabio Scotoni [Sat, 25 Feb 2023 10:13:24 +0000 (11:13 +0100)]
Resolve mandoc -Tlint nits

Several of them I have ignored intentionally:

1. unknown manual section comes with the definition;
2. unusual Xr order seems to have been an intentional decision
   grouping by topic rather than alphabetically,
   even if admittedly unusual;
3. no blank before trailing delimiter: Fa extern const
   crypto_argon2_extras crypto_argon2_no_extras;
   is another intentional choice,
   with no reasonable markup existing for a global variable
   declaration other than Bd.

3 years agomakefile: fix install-doc
Fabio Scotoni [Sat, 25 Feb 2023 09:59:41 +0000 (10:59 +0100)]
makefile: fix install-doc

During the documentation overhaul in
85a7c3742f06ab55fdf523a7a6a9cfe5cda09837,
generating the man page symlinks was automated
(introduction of doc/gen_doc.sh, now called doc/doc_gen.sh).

However, the install-doc target of the makefile fails to account for
the source folder not necessarily existing.
This change runs doc/doc_gen.sh before attempting to install
the man pages.

This has the questionable side effect of creating a folder as root and
creating a bunch of files as root (including the HTML files,
i.e. running mandoc as root) when doing sudo make install,
but the average user will "just" install and forget about it anyway.

3 years agoInclude TIS-CI in the relase, remove dist target
Loup Vaillant [Mon, 20 Feb 2023 11:25:35 +0000 (12:25 +0100)]
Include TIS-CI in the relase, remove dist target

3 years agoUpdate intro.3monocypher a bit
Loup Vaillant [Mon, 20 Feb 2023 11:11:45 +0000 (12:11 +0100)]
Update intro.3monocypher a bit

3 years agoCopied the input validation caveat everywhere
Loup Vaillant [Mon, 20 Feb 2023 10:25:49 +0000 (11:25 +0100)]
Copied the input validation caveat everywhere

3 years agoRemoved redundant mkdir in makefile
Loup Vaillant [Mon, 20 Feb 2023 10:25:17 +0000 (11:25 +0100)]
Removed redundant mkdir in makefile

3 years agoUpdate README (and separate the speed section)
Loup Vaillant [Mon, 20 Feb 2023 09:55:24 +0000 (10:55 +0100)]
Update README (and separate the speed section)

3 years agoFewer SLOC cheats
Loup Vaillant [Mon, 20 Feb 2023 08:57:22 +0000 (09:57 +0100)]
Fewer SLOC cheats

3 years agoUpdate CHANGELOG
Loup Vaillant [Mon, 20 Feb 2023 00:42:28 +0000 (01:42 +0100)]
Update CHANGELOG

3 years agoLeaner tarball
Loup Vaillant [Mon, 20 Feb 2023 00:17:38 +0000 (01:17 +0100)]
Leaner tarball

3 years agoLess repetitive makefile
Loup Vaillant [Sun, 19 Feb 2023 23:50:00 +0000 (00:50 +0100)]
Less repetitive makefile

3 years agoClarified where the tarball makefile ends
Loup Vaillant [Sun, 19 Feb 2023 23:41:09 +0000 (00:41 +0100)]
Clarified where the tarball makefile ends

3 years agoPortable POSIX makefile
Loup Vaillant [Sun, 19 Feb 2023 23:33:24 +0000 (00:33 +0100)]
Portable POSIX makefile

Or so I hope. Tested with GNU make and bmake.
This file is quite repetitive now. I really miss "$<".

3 years agoFixed ctgrind
Loup Vaillant [Sun, 19 Feb 2023 23:31:32 +0000 (00:31 +0100)]
Fixed ctgrind

Note that Argon2 reports a "use" of uninitialised value.  It does not
appear to be an secret dependent branch, or even index, but I didn't
expect the warning.

3 years agoWhitespace cosmetic
Loup Vaillant [Sun, 19 Feb 2023 23:31:17 +0000 (00:31 +0100)]
Whitespace cosmetic

3 years agoFix speed tests
Loup Vaillant [Sun, 19 Feb 2023 17:26:16 +0000 (18:26 +0100)]
Fix speed tests

3 years agoDocument how to implement XEdDSA
Loup Vaillant [Sun, 19 Feb 2023 17:22:07 +0000 (18:22 +0100)]
Document how to implement XEdDSA

This serves two purposes:

1. Providing a real use case for the low-level API.
2. Confirming that Monocypher does support XEdDSA.

Closes ##227

3 years agoMoved speed tests out of the main Makefile
Loup Vaillant [Sun, 19 Feb 2023 17:17:53 +0000 (18:17 +0100)]
Moved speed tests out of the main Makefile

3 years agoBetter doc integration
Loup Vaillant [Fri, 10 Feb 2023 15:56:12 +0000 (16:56 +0100)]
Better doc integration

Now some checks must pass before we generate the docs:

- .Nm and .Fo names are identical.
- All .Fn names are referenced in .Nm and .Fo.
- All functions from the headers have an .Nm reference.
- No .Nm reference documents a non-existent function.
- No .Xr reference is dead.

In practice this allowed me to catch many stale references very easily.
Since those were basicaly mechanically caugth typos, I did not update
the date nor copyright information in the affected documents.

Closes #250

3 years agoRemoved TIS-CI tests from slow test suite
Loup Vaillant [Fri, 10 Feb 2023 15:55:48 +0000 (16:55 +0100)]
Removed TIS-CI tests from slow test suite

That test is performed by TIS-CI proper, and the necessary files
are stripped from the tarball anyway.

3 years agoAdded missing Licence info
Loup Vaillant [Fri, 10 Feb 2023 09:29:34 +0000 (10:29 +0100)]
Added missing Licence info

3 years agoAdd Zebra tests for Ed25519
Loup Vaillant [Thu, 9 Feb 2023 17:13:52 +0000 (18:13 +0100)]
Add Zebra tests for Ed25519

No need to test EdDSA with Blake2b this way, both EdDSA flavours use the
same code.

Closes #248

3 years agoRemove Monocypher custom hash from ed25519-donna
Loup Vaillant [Thu, 9 Feb 2023 10:18:49 +0000 (11:18 +0100)]
Remove Monocypher custom hash from ed25519-donna

Only use libsodium's here.  It makes more sense when we generate the
test vectors, since Monocypher is ostensibly not compiled yet.

3 years agoAdd carry propagation tests to main tests & CI
Loup Vaillant [Mon, 6 Feb 2023 13:02:57 +0000 (14:02 +0100)]
Add carry propagation tests to main tests & CI

3 years agoCommented the origin of most test vectors
Loup Vaillant [Sun, 5 Feb 2023 22:33:28 +0000 (23:33 +0100)]
Commented the origin of most test vectors

3 years agoImproved SHA-512 speed on small inputs.
Loup Vaillant [Fri, 3 Feb 2023 17:18:58 +0000 (18:18 +0100)]
Improved SHA-512 speed on small inputs.

Not as much as BLAKE2b because SHA-512 core is slower, but still.
The cost here is about 10 lines of code, and an additional couple
dozen bytes in the binary.

3 years agoSimplify BLAKE2b a tiny little bit
Loup Vaillant [Fri, 3 Feb 2023 15:43:06 +0000 (16:43 +0100)]
Simplify BLAKE2b a tiny little bit

3 years agoAdd small input speed test for SHA-512
Loup Vaillant [Fri, 3 Feb 2023 15:42:31 +0000 (16:42 +0100)]
Add small input speed test for SHA-512

3 years agoBetter SHA-512 test suite
Loup Vaillant [Fri, 3 Feb 2023 15:42:02 +0000 (16:42 +0100)]
Better SHA-512 test suite

3 years agoDoc: typo
Loup Vaillant [Fri, 3 Feb 2023 09:25:13 +0000 (10:25 +0100)]
Doc: typo

3 years agoDocument BLAKE2b KDF, change BLAKE2b API *again*
Loup Vaillant [Thu, 2 Feb 2023 23:14:15 +0000 (00:14 +0100)]
Document BLAKE2b KDF, change BLAKE2b API *again*

And optimised `crypto_blake2b_update()` on short or unaligned inputs.
This also clarifies the source code somewhat, though it's now a bit more
verbose.  That verbosity does give us over 15-30% speed on small updates
& small inputs typical of key derivation schemes.

---

The reason for the rework of the API is that the struct argument simply
does not work in practice.  See, BLAKE2b has not one, but *two* typical
usages: regular hashing, and keyed hashing.  There are many situations
where controlling the size of the hash is useful even when we don't use
the key, and when we do keyed hashing (for MAC or KDF), having to use
the struct is just *so* verbose and tedious.

I briefly considered having just one hash function to rule them all with
6 arguments, but regular hashing still is the main use case.  So instead
of a struct or the original split, I simply have:

* `crypto_blake2b()`       with a variable sized hash.
* `crypto_blake2b_keyed()` with every option.

and in practice, the 6 arguments of the keyed version are quite
manageable: output first as always, then the key, then the message.
And if arguments get too long the pointer/size pairs give us natural
line breaks.

I had to work on KDFs to realise this so thanks @samuel-lucas6 for
bringing the whole issue up.

---

Unlike SHA512, I did *not* add an explicit KDF interface for BLAKE2b.
My reasons being:

* There is no clear standard KDF for BLAKE2b except HKDF.
* HKDF is build on top of HMAC, and HMAC is stupid when BLAKE2b already
  has a keyed mode that does the exact same thing with less code and
  fewer CPU cycles.
* HKDF is kind of *a little* stupid itself.
* `crypto_blake2b_keyed()` already implements KDF extract.
* `crypto_chacha20_*()` already implement KDF expand.
* I hesitate to implement a non-standard convenience function users are
  unlikely to get catastrophically wrong.

So instead I updated the manual, including 3 full KDF functions lazy
users can just blindly copy & paste.

Closes #255

3 years agoFix UB (pointer pointing outside of object)
Loup Vaillant [Thu, 2 Feb 2023 10:15:26 +0000 (11:15 +0100)]
Fix UB (pointer pointing outside of object)

3 years agoAdd HKDF SHA-512
Loup Vaillant [Wed, 1 Feb 2023 22:03:06 +0000 (23:03 +0100)]
Add HKDF SHA-512

In principle, we can imitate HKDF quite easily with SHA-512 alone.
Being fully RFC compliant however is fiddly and tedious, so for users
who want to do key derivation with SHA-512 in the most standard way
possible need dedicated functions.

Note the absence of a `crypto_sha512_hkdf_extract()` function, which
would be nothing more than an alias of `crypto_sha512_hmac()`.  Aliases
to the equivalent incremental interface are also absent.  There are pros
and cons to both the presence and absence of those aliases, I personally
prefer to leave them out.

See #255