]> git.codecow.com Git - Monocypher.git/log
Monocypher.git
6 years agoBump copyright year (again)
Loup Vaillant [Tue, 14 Jan 2020 21:00:24 +0000 (22:00 +0100)]
Bump copyright year (again)

6 years agoBump copyright year
Loup Vaillant [Mon, 13 Jan 2020 22:54:26 +0000 (23:54 +0100)]
Bump copyright year

6 years agoFixed missing wipe
Loup Vaillant [Sat, 11 Jan 2020 13:44:58 +0000 (14:44 +0100)]
Fixed missing wipe

And a few cosmetics

6 years agoRemoved unnecessary wipe
Loup Vaillant [Sat, 11 Jan 2020 13:24:10 +0000 (14:24 +0100)]
Removed unnecessary wipe

6 years agoCosmetic/consistency in Argon2i
Loup Vaillant [Sat, 11 Jan 2020 12:59:09 +0000 (13:59 +0100)]
Cosmetic/consistency in Argon2i

The functions g_copy() and g_xor() both take a pointer to a temporary,
to avoid wiping them again and again. unary_g(), however, did not, and
instead managed its temporary block internally.

Since unary_g() is called less often, this is not really a problem. I
thought it would be cleaner however to have all three functions work the
same way.

This should have a negligible, positive impact on performance as well.

6 years agoMerge pull request #150 from fscoto/master+shhead
Loup Vaillant [Sat, 11 Jan 2020 11:01:41 +0000 (12:01 +0100)]
Merge pull request #150 from fscoto/master+shhead

dist.sh: Forgot copyright header for myself

6 years agoMerge pull request #149 from fscoto/master+custom-hash
Loup Vaillant [Sat, 11 Jan 2020 10:51:05 +0000 (11:51 +0100)]
Merge pull request #149 from fscoto/master+custom-hash

doc: custom hash: clean up C-only-isms

6 years agodoc: custom hash: clean up C-only-isms
Fabio Scotoni [Sat, 11 Jan 2020 06:30:43 +0000 (07:30 +0100)]
doc: custom hash: clean up C-only-isms

Related to e1520e87d.

6 years agoAdded Wycheproof HMAC-SHA512 test vectors
Loup Vaillant [Wed, 8 Jan 2020 22:17:52 +0000 (23:17 +0100)]
Added Wycheproof HMAC-SHA512 test vectors

Only 64-byte tags.  Monocypher does not support shorter tags

6 years agoFixed C++ compilation
Loup Vaillant [Wed, 8 Jan 2020 22:03:55 +0000 (23:03 +0100)]
Fixed C++ compilation

Fixes #148

C++ is less lenient than C with its casts. It requires the pointers to
be cast to the correct type, `void*` alone does not work.

TODO: we should probably fix the documentation as well.

6 years agoRolled loop for zero initialisation
Loup Vaillant [Sun, 5 Jan 2020 20:32:41 +0000 (21:32 +0100)]
Rolled loop for zero initialisation

- Compilers optimise loops better.
- We save one line of code this way.

(This is a nitpick: in practice, this doesn't change a thing.)

6 years agoMerge pull request #145 from fscoto/master+custom-hash
Loup Vaillant [Sun, 5 Jan 2020 18:28:26 +0000 (19:28 +0100)]
Merge pull request #145 from fscoto/master+custom-hash

doc: use static key for custom hash example

6 years agoMerge pull request #147 from mikejsavage/examplesfixes
Loup Vaillant [Sun, 5 Jan 2020 18:15:36 +0000 (19:15 +0100)]
Merge pull request #147 from mikejsavage/examplesfixes

Some examples fixes

6 years agoMerge pull request #146 from mikejsavage/man2csh
Loup Vaillant [Sun, 5 Jan 2020 18:13:55 +0000 (19:13 +0100)]
Merge pull request #146 from mikejsavage/man2csh

Rewrite example test script in shell

6 years agoFix license
Michael Savage [Sun, 29 Dec 2019 10:45:46 +0000 (12:45 +0200)]
Fix license

6 years agoreturn 0
Michael Savage [Sat, 28 Dec 2019 23:54:32 +0000 (01:54 +0200)]
return 0

6 years agoMatch man2html.sh style
Michael Savage [Sat, 28 Dec 2019 23:51:33 +0000 (01:51 +0200)]
Match man2html.sh style

6 years agoQuotes, use cat so the sed train runs strictly left to right
Michael Savage [Sat, 28 Dec 2019 23:47:39 +0000 (01:47 +0200)]
Quotes, use cat so the sed train runs strictly left to right

6 years agodist_ignore extract_examples.sh
Michael Savage [Sat, 28 Dec 2019 23:34:47 +0000 (01:34 +0200)]
dist_ignore extract_examples.sh

6 years agoReview changes
Michael Savage [Sat, 28 Dec 2019 14:59:03 +0000 (16:59 +0200)]
Review changes

6 years agodist.sh: Forgot copyright header for myself
Fabio Scotoni [Sat, 28 Dec 2019 14:05:14 +0000 (15:05 +0100)]
dist.sh: Forgot copyright header for myself

Was just a one-line find(1) change, so one could argue removal of me in
the CC-0 header would've been cleaner,
but Loup wanted me to take credit for it (e-mail of Oct 21, 2019).

6 years agoSome examples fixes
Michael Savage [Sat, 28 Dec 2019 11:54:38 +0000 (13:54 +0200)]
Some examples fixes

6 years agoWhoops
Michael Savage [Sat, 28 Dec 2019 11:58:30 +0000 (13:58 +0200)]
Whoops

6 years agoRewrite example test script in shell
Michael Savage [Sat, 28 Dec 2019 11:53:34 +0000 (13:53 +0200)]
Rewrite example test script in shell

6 years agodoc: use static key for custom hash example
Fabio Scotoni [Sat, 28 Dec 2019 07:03:30 +0000 (08:03 +0100)]
doc: use static key for custom hash example

Removes the non-portable arc4random(3) at least.
Still depends on the non-portable OpenBSD SHA-2 functions.

While there, fix CC-0 header to match reality.

6 years agoMerge pull request #144 from mikejsavage/testexamples
Loup Vaillant [Fri, 27 Dec 2019 23:51:58 +0000 (00:51 +0100)]
Merge pull request #144 from mikejsavage/testexamples

Add a script to extract examples from man pages

6 years agoAdd a script to extract examples from man pages
Michael Savage [Fri, 27 Dec 2019 16:47:47 +0000 (18:47 +0200)]
Add a script to extract examples from man pages

6 years agoTypo
Loup Vaillant [Mon, 23 Dec 2019 15:46:14 +0000 (16:46 +0100)]
Typo

6 years agoMerge pull request #143 from fscoto/master+licensing3
Loup Vaillant [Mon, 23 Dec 2019 15:44:23 +0000 (16:44 +0100)]
Merge pull request #143 from fscoto/master+licensing3

License clarifications

6 years agoLICENCE.md: Clarifications
Fabio Scotoni [Fri, 13 Dec 2019 08:42:28 +0000 (09:42 +0100)]
LICENCE.md: Clarifications

                            !!! important !!!
     No change to the licensing situation of Monocypher is intended.
               These are meant to be clarifications only.

                No action is required on any user's part.
                           !!! /important !!!

These changes are highly delicate, so I feel obliged to give a detailed
explanation of each change.
(For my own sanity, I'll use U.S. spelling for "license",
even if the LICENCE.md is written in British English.)

---

"Monocypher is dual-licensed" -> "Monocypher as a whole is
dual-licensed"

This new wording matches the phrasing found in the top-level license
file of musl and mandoc, both of which are notable and fairly large
BSD-licensed projects.
The file headers added in an earlier commit are part of this:
The copyright notices are an *integral* part of the BSD 2-clause
license;
there has been no formal copyright assignment agreement,
so the copyright notices of all contributors who have made copyrightable
changes are really meant to be in all applicable files.

Pro forma it should be noted, however, that Michael Savage and I have
agreed to the LICENCE.md as it was before this commit by e-mail.

This makes no difference for everyone who's taken just the
monocypher.[ch] files and added those to their project because the
individual files' copyright notices for those two files match the
original LICENCE.md.
(And again, we don't *actually* care about compliance with the BSD
2-clause license from our end because we've waived copyright to the
greatest extent possible for CC-0, so the only ones who would actually
care live in your company's legal department.)

---

"Choose whichever you want" -> "Choose whichever you want from the two
licences listed below"

This change is mainly intended to clarify that you're not meant to
choose an *arbitrary* license, but rather one of the two below.
In practice, this should not matter because if you didn't choose the
2-clause BSD license, you chose CC-0, where copyright is maximally
waived anyway, which allows you to do whatever.

---

"The BSD licence serves as a fallback" -> "The BSD licence serves as a
fallback option"

This change clarifies that using the BSD 2-clause license is just an
option, to be exercised at the recipient's discretion,
without diluting the actual intent of placing Monocypher in the public
domain.

This matters because the CC-0 license *itself* has a section called
"Public License Fallback"; it is NOT the intent to replace section 3 of
CC-0 with a BSD 2-clause license.
The previous wording could, however, have been misconstrued like this
and thus could've butchered the very idea of using CC-0 in the first
place.

---

Added: "See the individual files for specific information about who
contributed to what file during which years.  See below for special
notes."

This text was inspired by mandoc's licensing document.
It is necessary because the "total" copyright notice differs from the
copyright notice that applies to individual files,
so per-file compliance with the 2-clause BSD license differs.

About the special notes, see the section immediately below.

---

I also added a section called "Special notes",
which notes that we're allowed to include the externals because they've
been placed in the public domain by their respective authors.
This should help some people who are very careful about copyright and
distribution rights when redistributing Monocypher as a whole,
as they'll know where to look and all the heavy lifting has already been
done for them.

---

There are a number of files without the headers affixed to them.
Doing so would clutter them (e.g. README.md, CHANGELOG.md, AUTHORS.md)
and bring no actual value.
LICENCE.md applies to them indirectly.

---

(Digressions:
There's probably an interesting relationship between CC-0 and BSD
2-clause to be determined where any contributor agreeing to place their
work under the CC-0 license technically permits relicensing under the
BSD 2-clause in any case with no attribution.
I kind of wonder if CC-0 and a BSD 2-clause license aren't inherently
mutually exclusive -- it's conceptually difficult to grant rights that
you're immediately waiving in the next section of the same document.
But github.com/nothings/stb seems to take a similar approach with
MIT/Unlicense, and that evidently seems to make lawyers happy, so who am
I to judge?
But let's ignore all of these technicalities and be upstanding citizens
of the free software world that provide as much legal certainty as they
can.)

6 years agostyle.css: Affix license header
Fabio Scotoni [Thu, 12 Dec 2019 10:49:26 +0000 (11:49 +0100)]
style.css: Affix license header

Upstream mandoc relicensed mandoc.css about a year ago
to place it in the public domain, making things easy here.

6 years agoAdd AUTHORS.md for externals
Fabio Scotoni [Thu, 12 Dec 2019 10:33:24 +0000 (11:33 +0100)]
Add AUTHORS.md for externals

6 years agoLicensing header additions
Fabio Scotoni [Thu, 12 Dec 2019 10:32:33 +0000 (11:32 +0100)]
Licensing header additions

+50 lines for every file.

The abbreviated CC0 license header was taken from the CC0 FAQ
(https://wiki.creativecommons.org/wiki/CC0_FAQ).

There's no commonly accepted way to shorten the 2-clause BSD license,
so it has to be copied in full every time.
The copyright notices are important for 2-clause BSD license,
so adding a reference to LICENCE.md was impractical.

While already there, affix a SPDX license identifier to all files.
This helps automated license identification programs along,
such as GitHub and scancode-toolkit.

License headers are useful to clarify what license conditions apply
to a particular file.

6 years agoExpunged Monokex test vectors
Loup Vaillant [Fri, 20 Dec 2019 11:54:39 +0000 (12:54 +0100)]
Expunged Monokex test vectors

Monokex is unlikely to be added to Monocypher in the near future, for
a couple reasons:

- It is a high level protocol, and Monocypher is fairly low level.
- It is not yet ready for production.
- It takes a significant amount of code.

Maybe it will be added later, but first, Monokex must focus on being its
own library, with Monocypher as a dependency. (We could also have a
version that uses Libsodium instead.)

6 years agoReintroduce "intro: format link with .Lk"
Loup Vaillant [Wed, 18 Dec 2019 23:11:22 +0000 (00:11 +0100)]
Reintroduce "intro: format link with .Lk"

This reverts commit 8089c0c3820cbcfe0f267e507cc18b4ffd057896.

The bug is groff's and Debian is working to fix it.  We don't need to
work around it anymore.

6 years agoRevert "Fixed typo in manual"
Loup Vaillant [Mon, 16 Dec 2019 09:03:59 +0000 (10:03 +0100)]
Revert "Fixed typo in manual"

This reverts commit 9e362871bea3850a657e36145f6d3d667e0c921c.

I didn't fixed anything, I was destroying a perfectly fine escape
sequence!  Lesson learned: Roff doesn't ignore escape sequences in code
snippets.

6 years agoFixed typo in manual
Loup Vaillant [Sun, 15 Dec 2019 23:09:34 +0000 (00:09 +0100)]
Fixed typo in manual

6 years agoMerge pull request #142 from fscoto/master+new-man
Loup Vaillant [Fri, 13 Dec 2019 13:16:33 +0000 (14:16 +0100)]
Merge pull request #142 from fscoto/master+new-man

Documentation: Remove vestiges of incremental AEAD

6 years agoDocumentation: Remove vestiges of incremental AEAD
Fabio Scotoni [Fri, 13 Dec 2019 08:59:06 +0000 (09:59 +0100)]
Documentation: Remove vestiges of incremental AEAD

6 years agoMerge pull request #141 from fscoto/master+new-man
Loup Vaillant [Thu, 12 Dec 2019 17:28:25 +0000 (18:28 +0100)]
Merge pull request #141 from fscoto/master+new-man

Revert "intro: format link with .Lk"

6 years agoMerge pull request #140 from fscoto/master+build
Loup Vaillant [Thu, 12 Dec 2019 17:26:52 +0000 (18:26 +0100)]
Merge pull request #140 from fscoto/master+build

Two minor build system improvements

6 years agoRevert "intro: format link with .Lk"
Fabio Scotoni [Thu, 12 Dec 2019 12:24:21 +0000 (13:24 +0100)]
Revert "intro: format link with .Lk"

This reverts commit df321b37cda1db5e8bd6fa76e4daf01ac087b865.

As it turns out,
groff (1.22.4) will spew complaints about the Lk formatting to stderr,
even though it's rendered perfectly fine.

6 years agomakefile: Add LIBDIR option
Fabio Scotoni [Thu, 12 Dec 2019 08:58:05 +0000 (09:58 +0100)]
makefile: Add LIBDIR option

This is useful for multiarch, where you may have the library
installed in a subdirectory of /usr/lib/,
e.g. /usr/lib/x86_64-linux-gnu/.
Debian and Ubuntu appear to make use of this extensively;
having this in the makefile will avoid hacks when doing multiarch.
Autotools has a similar feature (passing --libdir to configure).

6 years agomakefile: Honor LDFLAGS variable if given
Fabio Scotoni [Thu, 12 Dec 2019 08:48:36 +0000 (09:48 +0100)]
makefile: Honor LDFLAGS variable if given

This allows specifying e.g. hardening options like -Wl,-z,relro
for link-time options.
It *is* normally possible to add these to CFLAGS,
but LDFLAGS is the established way to do this and tooling expects
it to work.
See also POSIX on make(1), whose default rules use LDFLAGS.

6 years agoMoved TweetNaCl to its own folder
Loup Vaillant [Wed, 11 Dec 2019 22:08:16 +0000 (23:08 +0100)]
Moved TweetNaCl to its own folder

6 years agoTweaked dist.sh
Loup Vaillant [Tue, 10 Dec 2019 20:37:42 +0000 (21:37 +0100)]
Tweaked dist.sh

6 years agoMerge pull request #139 from fscoto/master+new-man
Loup Vaillant [Tue, 10 Dec 2019 17:45:15 +0000 (18:45 +0100)]
Merge pull request #139 from fscoto/master+new-man

Miscellaneous documentation fixes

6 years agoDocumentation: bump date for custom hash man pages
Fabio Scotoni [Tue, 10 Dec 2019 10:37:47 +0000 (11:37 +0100)]
Documentation: bump date for custom hash man pages

6 years agoCHANGELOG: Use correct path for optional files
Fabio Scotoni [Tue, 10 Dec 2019 10:29:21 +0000 (11:29 +0100)]
CHANGELOG: Use correct path for optional files

6 years agoMake custom hash length requirements more explicit
Fabio Scotoni [Tue, 10 Dec 2019 10:21:39 +0000 (11:21 +0100)]
Make custom hash length requirements more explicit

Related to 0074dfab1.

Also note that vtable->final must actually write the hash,
not only finalize the context.

6 years agoDocumentation: Minor wording improvment for custom hash functions
Fabio Scotoni [Tue, 10 Dec 2019 10:15:00 +0000 (11:15 +0100)]
Documentation: Minor wording improvment for custom hash functions

6 years agoVersion 3.0.0 change log
Loup Vaillant [Mon, 9 Dec 2019 16:23:22 +0000 (17:23 +0100)]
Version 3.0.0 change log

6 years agoFixed c25519 speed benchmark
Loup Vaillant [Mon, 9 Dec 2019 16:09:56 +0000 (17:09 +0100)]
Fixed c25519 speed benchmark

6 years agoConsistent naming with 'make dist'
Loup Vaillant [Mon, 9 Dec 2019 16:07:14 +0000 (17:07 +0100)]
Consistent naming with 'make dist'

6 years agoCompleted test coverage
Loup Vaillant [Mon, 9 Dec 2019 13:14:21 +0000 (14:14 +0100)]
Completed test coverage

6 years agoAdded tests for IETF Chacha20
Loup Vaillant [Mon, 9 Dec 2019 10:49:34 +0000 (11:49 +0100)]
Added tests for IETF Chacha20

6 years agoFixed mistakenly ignored files
Loup Vaillant [Fri, 6 Dec 2019 18:12:15 +0000 (19:12 +0100)]
Fixed mistakenly ignored files

6 years agoMerge pull request #138 from fscoto/master+new-man
Loup Vaillant [Fri, 6 Dec 2019 18:01:32 +0000 (19:01 +0100)]
Merge pull request #138 from fscoto/master+new-man

Address man page review concerns

6 years agoDocumentation: complete SEE ALSO in intro(3monocypher)
Fabio Scotoni [Fri, 6 Dec 2019 07:32:47 +0000 (08:32 +0100)]
Documentation: complete SEE ALSO in intro(3monocypher)

This is supposed to be a complete and exhaustive list of
all documented functions,
as can be seen with all incremental functions being listed
separately, rather than only the "main" page that is symlinked to.

6 years agoDocumentation: Address Loup's review via GitHub PR #137
Fabio Scotoni [Fri, 6 Dec 2019 07:23:06 +0000 (08:23 +0100)]
Documentation: Address Loup's review via GitHub PR #137

- Fix typo in crypto_sign_init_first_pass_custom_hash(3monocypher)
- Wipe sk in crypto_sign_init_first_pass_custom_hash(3monocypher);
  while it is just a test program, it is arguably good form to do so
  in any case, especially in documentation code that people might be
  copying and pasting.
- Note that HMACs can be safely truncated.

6 years agoAdjust .In directives in optional/ for new prefix
Fabio Scotoni [Fri, 6 Dec 2019 07:14:10 +0000 (08:14 +0100)]
Adjust .In directives in optional/ for new prefix

6 years agoPrefixed optional files with "monocypher-"
Loup Vaillant [Thu, 5 Dec 2019 21:07:26 +0000 (22:07 +0100)]
Prefixed optional files with "monocypher-"

Monocypher is a "single file" library, with optional files. As a single
file library, it is best to occupy the global namespace directly. It's
only one include, no need for a folder.

The optional file kinda throw things off. We could put it in a
sub-folder, but we probably want both header to be at the same
place. And we certainly don't want to put monocypher.h itself in
sub-folder.

The solution is to have those files, none in a sub folder.

    monocypher.h
    monocypher.c
    monocypher-ed25519.h  (optional)
    monocypher-ed25519.c  (optional)

Namespace pollution is limited to a prefix.  Should be reasonable both
for projects that import those files directly, or for packaging in a
Linux or BSD distribution.

6 years agoMerge pull request #137 from fscoto/master+new-man
Loup Vaillant [Thu, 5 Dec 2019 18:38:25 +0000 (19:38 +0100)]
Merge pull request #137 from fscoto/master+new-man

Man page updates

6 years agointro: Be more accurate about constant-time multiplication
Fabio Scotoni [Thu, 5 Dec 2019 08:09:01 +0000 (09:09 +0100)]
intro: Be more accurate about constant-time multiplication

Information obtained via https://bearssl.org/cmul.html

Considering the interest in Monocypher on embedded platforms,
some ARM Cortex-M CPUs lacking constant-time multiplication needs
special emphasis.

6 years agointro: format link with .Lk
Fabio Scotoni [Thu, 5 Dec 2019 08:02:39 +0000 (09:02 +0100)]
intro: format link with .Lk

6 years agoDocumentation: Get rid of "we" for more neutral style
Fabio Scotoni [Thu, 5 Dec 2019 07:54:58 +0000 (08:54 +0100)]
Documentation: Get rid of "we" for more neutral style

6 years agoUpdate man pages for recent changes
Fabio Scotoni [Thu, 5 Dec 2019 07:31:25 +0000 (08:31 +0100)]
Update man pages for recent changes

Squashed commit of the following:

commit a7b2c919a76aab4b709dc4eb45f04234a8745ad1
Author: Fabio Scotoni <34964387+fscoto@users.noreply.github.com>
Date:   Thu Dec 5 08:25:33 2019 +0100

    Documentation: fix crypto_sha512 prototype

commit 7204c59458ce57f0967b42fe7998a411a097da55
Author: Fabio Scotoni <34964387+fscoto@users.noreply.github.com>
Date:   Thu Dec 5 08:23:10 2019 +0100

    Documentation: follow rename of HMAC functions

    crypto_hmac_* were renamed to crypto_hmac_sha512_* in 32525e92.

commit 2068f01e28cd2a5a4e2bc5ae4dd1a161e469f835
Author: Fabio Scotoni <34964387+fscoto@users.noreply.github.com>
Date:   Wed Dec 4 09:12:41 2019 +0100

    Adjust intro for new functions

commit 9cea43d2fa38b7249babe74f1c04066b4eaf90fa
Author: Fabio Scotoni <34964387+fscoto@users.noreply.github.com>
Date:   Wed Dec 4 09:00:34 2019 +0100

    Copy symbolic links as such

    cp -r copies symbolic links by dereferencing the link,
    essentially causing massive duplication of the man pages when installed.

    cp -PR copies the symlinks in place so that we have the contents on disk
    only once.

commit 19afe7d0f864acae143b0568956851dadddf2edc
Author: Fabio Scotoni <34964387+fscoto@users.noreply.github.com>
Date:   Wed Dec 4 08:47:43 2019 +0100

    Hook optional/ man pages to build

commit 668921527f186249dc8c54c87c0727b68ca30348
Author: Fabio Scotoni <34964387+fscoto@users.noreply.github.com>
Date:   Wed Dec 4 08:32:02 2019 +0100

    Remove mentions of context in Chacha20 documentation

    Contexts for Chacha20 as a whole were removed entirely.

commit e539f22ee036375a0ca7a3de4c84f30ba50d2738
Author: Fabio Scotoni <34964387+fscoto@users.noreply.github.com>
Date:   Wed Dec 4 08:30:26 2019 +0100

    Remove crypto_{mem,zero}cmp man pages

    These were deprecated in 2.0.0 already,
    which means they're due for removal now.

commit 8b04f0380dc0b7b8e81bcee86184c8b0100ca14a
Author: Fabio Scotoni <34964387+fscoto@users.noreply.github.com>
Date:   Tue Dec 3 11:41:24 2019 +0100

    Document custom hash EdDSA functions

commit 5663c8e1a5031eb7921e13cd9b717a924a6e458b
Author: Fabio Scotoni <34964387+fscoto@users.noreply.github.com>
Date:   Tue Dec 3 09:58:42 2019 +0100

    Document Ed25519 functions

commit 19478589d8afc1b1e782d33b9d6053ae89714f8b
Author: Fabio Scotoni <34964387+fscoto@users.noreply.github.com>
Date:   Tue Dec 3 09:31:14 2019 +0100

    Document HMAC functions

commit c75e9474a57d738141d64630ba6b7c28bf999f80
Author: Fabio Scotoni <34964387+fscoto@users.noreply.github.com>
Date:   Tue Dec 3 09:09:46 2019 +0100

    Document SHA-512 functions

commit 4fee40d5dfe7f65494a9ac43ac5ce114361063fa
Author: Fabio Scotoni <34964387+fscoto@users.noreply.github.com>
Date:   Mon Dec 2 11:13:29 2019 +0100

    Update Chacha20 documentation

6 years agoRenamed "crypto_hmac_*" to "crypto_hmac_sha512_*"
Loup Vaillant [Wed, 4 Dec 2019 18:24:59 +0000 (19:24 +0100)]
Renamed "crypto_hmac_*" to "crypto_hmac_sha512_*"

There are several types of HMAC, and users may want to use other
versions of HMAC as well. (For instance, they could code their own
Blake2b HMAC to implement Noise).  Plus, most primitives are named by
their technical name. "hmac" alone is not enough.

The names are longer, but this is the optional part, after all.

6 years agoFixed crypto_sha512 (and HMAC) prototypes
Loup Vaillant [Wed, 4 Dec 2019 18:18:06 +0000 (19:18 +0100)]
Fixed crypto_sha512 (and HMAC) prototypes

The output hash (and MAC) has a fixed size: 64 bytes.

6 years agoFixed unwiped buffer in SHA-512
Loup Vaillant [Tue, 3 Dec 2019 22:31:03 +0000 (23:31 +0100)]
Fixed unwiped buffer in SHA-512

6 years agoFixed buffer overflow in test vector generation
Loup Vaillant [Tue, 3 Dec 2019 18:49:27 +0000 (19:49 +0100)]
Fixed buffer overflow in test vector generation

6 years agoMoved SHA 512 work area to local stack
Loup Vaillant [Tue, 3 Dec 2019 07:52:01 +0000 (08:52 +0100)]
Moved SHA 512 work area to local stack

While some users could perhaps benefit from saving 640 bytes of stack
space by allocating the context statically, or in the heap, in practice
it's not he bottleneck.  Besides, putting the work area there actually
*increases* stack usage on signatures and signature verification, which
are the most stack hungry parts of Monocypher to begin with.

Better not try to be clever.

6 years agoProperty based tests for HMAC SHA-512
Loup Vaillant [Mon, 2 Dec 2019 23:06:45 +0000 (00:06 +0100)]
Property based tests for HMAC SHA-512

6 years agoFixed HMAC SHA-512 (and added tests)
Loup Vaillant [Mon, 2 Dec 2019 22:49:25 +0000 (23:49 +0100)]
Fixed HMAC SHA-512 (and added tests)

Test vectors were generated with Libsodium, with various key sizes (both
shorter and longer than the message), and every message size from 0 to
256 (twice the SHA 512 block size).

Also added Test vectors from RFC 4231, except the one with truncated
output (we don't support truncated outputs, users will have to do that
manually).

6 years agoAdded HMAC SHA512
Loup Vaillant [Sun, 1 Dec 2019 21:36:00 +0000 (22:36 +0100)]
Added HMAC SHA512

EXPERIMENTAL. MAY BE REMOVED.

Monocypher is supposed to be small.  This is why we use Blake2b for both
Argon2 and EdDSA signatures.  Some users however need Ed25519 for
compatibility with other tools.  This means using SHA 512.

We could hide SHA 512 from the public interface entirely, but this seems
like a waste: it could replace Blake2b to make the library smaller. It
will come at a performance loss, but when you verify signatures on a
small device, the hash is rarely the bottleneck.

The main problem with SHA 512 is length extension attacks.  It just
cannot be used as a prefix MAC like Blake2b can.  We need HMAC if we
want SHA 512 to entirely displace Blake2b, so the Monocypher binary
stays small.

Users could use Poly1305 and our version of RFC 8439 of course, but if
they're so tight on space, they're likely to get rid of Poly1305 as
well.  When we have SHA 512 already, HMAC requires much less code.

This is kind of a special corner case. But it could come in handy.

TODO: the tests.

6 years agoREADME typo
Loup Vaillant [Sun, 1 Dec 2019 19:36:11 +0000 (20:36 +0100)]
README typo

6 years agoFixed X25519 speed test
Loup Vaillant [Sun, 1 Dec 2019 19:35:10 +0000 (20:35 +0100)]
Fixed X25519 speed test

6 years agoRemoved deprecated X25519 return value
Loup Vaillant [Sun, 1 Dec 2019 17:27:01 +0000 (18:27 +0100)]
Removed deprecated X25519 return value

6 years agoAdded USE_ED25519 makefile option
Loup Vaillant [Sun, 1 Dec 2019 14:56:34 +0000 (15:56 +0100)]
Added USE_ED25519 makefile option

6 years agoRenamed crypto_sign_sha512_ctx into crypto_sign_ed25519_ctx
Loup Vaillant [Sun, 1 Dec 2019 13:29:16 +0000 (14:29 +0100)]
Renamed crypto_sign_sha512_ctx into crypto_sign_ed25519_ctx

Also renamed crypto_check_sha512_ctx into crypto_check_ed25519_ctx

This is for consistency with the naming of the functions themselves.

6 years agoRenamed crypto_hash_vtable into crypto_sign_vtable
Loup Vaillant [Sun, 1 Dec 2019 12:57:17 +0000 (13:57 +0100)]
Renamed crypto_hash_vtable into crypto_sign_vtable

The vtable holds hash functions, but it's really a vtable for
crypto_sign_ctx_abstract (and its check typedef). It's more tied to
EdDSA than to the hash itself.

6 years agoRemoved obsolete test-legacy include
Loup Vaillant [Sun, 1 Dec 2019 12:53:27 +0000 (13:53 +0100)]
Removed obsolete test-legacy include

6 years agoAdded aliases for Ed25519
Loup Vaillant [Sun, 1 Dec 2019 11:26:47 +0000 (12:26 +0100)]
Added aliases for Ed25519

6 years agoMarked the vtable as part of the public API
Loup Vaillant [Sun, 1 Dec 2019 11:18:27 +0000 (12:18 +0100)]
Marked the vtable as part of the public API

6 years agoRenamed crypto_sign_blake2b_ctx back to crypto_sign_ctx
Loup Vaillant [Sun, 1 Dec 2019 11:01:15 +0000 (12:01 +0100)]
Renamed crypto_sign_blake2b_ctx back to crypto_sign_ctx

Also renamed crypto_check_blake2b_ctx back to crypto_check_ctx.

This serves two purposes: avoid breaking the API when users upgrade from
Monocypher 2.x, and keep the idea that Blake2b is the default hash (the
default settings are implied and need not be named).

Note that although old code is not broken, it will still have warnings.
Those are easily silenced by casting to (void*).

6 years agoCosmetic (whitespace)
Loup Vaillant [Sun, 1 Dec 2019 11:01:07 +0000 (12:01 +0100)]
Cosmetic (whitespace)

6 years agoCosmetic (convert pointers directly)
Loup Vaillant [Sun, 1 Dec 2019 10:55:48 +0000 (11:55 +0100)]
Cosmetic (convert pointers directly)

6 years agoFixed undefined function pointer conversion
Loup Vaillant [Sun, 1 Dec 2019 10:42:30 +0000 (11:42 +0100)]
Fixed undefined function pointer conversion

The TIS interpreter is not happy when we call a function from an
incompatible pointer type.  GCC and Clang don't seem to mind as long as
we explicitly convert the pointer, but apparently that's undefined
behaviour, even though the only incompatibility is transforming a
pointer argument into a void* argument.

I don't know if it's a false positive, but better safe than sorry. The
conversion now uses explicit wrappers instead of a brutal type cast.

I've taken the opportunity to remove the offset. The wrappers now
perform the offset themselves, by accessing the member field the normal
way (after converting from void*, but that can't be avoided).

6 years agoFixed Clang warning
Loup Vaillant [Sun, 1 Dec 2019 09:33:01 +0000 (10:33 +0100)]
Fixed Clang warning

6 years agoFixed outdated include in speed.c
Loup Vaillant [Sat, 30 Nov 2019 23:36:12 +0000 (00:36 +0100)]
Fixed outdated include in speed.c

6 years agochacha20_*_ctr functions now return the new ctr
Loup Vaillant [Sat, 30 Nov 2019 23:08:08 +0000 (00:08 +0100)]
chacha20_*_ctr functions now return the new ctr

This should facilitate building piecemeal streams.  Normally you'd just
increment the nonce, but in some (admittedly rare) cases we may want to
increment the counter instead.

Incrementing the counter is fairly dangerous, because we may overlap the
streams, thus revealing the XOR of two pieces of plain text. Using the
new return value makes sure this doesn't happen.

6 years agoEnabled cohabitation of several EdDSA instances
Loup Vaillant [Sat, 30 Nov 2019 19:36:28 +0000 (20:36 +0100)]
Enabled cohabitation of several EdDSA instances

EdDSA can now use a custom hash! And that hash is not set in stone at
compile time, it can be decided at runtime!  It was done inheritance and
subtype polymorphism.  Don't worry, we are still using pure C.

Custom hashes are defined through vtables. The vtable contains function
pointers, an offset, and a size. (We need the size to wipe the context,
and the offset to find the location of the hash context inside the
signing context.)

An abstract signing context is defined. It is not instantiated
directly. It is instead the first member of the specialised signing
context.  The incremental interface takes pointers to abstract contexts,
but actually requires specialised contexts.

By default, we use the Blake2b specialised context. The incremental
interface doesn't change, except for the need to give it a specialised
context instead of the old crypto_sign_ctx. To enable the use of
different contexts, 3 "custom_hash" functions have been added:

    crypto_sign_public_key_custom_hash
    crypto_sign_init_first_pass_custom_hash
    crypto_check_init_custom_hash

They take a vtable as an additional parameter.

Ed25519 uses the custom hash interface to provide the following:

    crypto_ed25519_public_key
    crypto_ed25519_sign
    crypto_ed25519_check
    crypto_ed25519_sign_init_first_pass
    crypto_ed25519_check_init

To use them, we just have to add ed25519.h and ed25519.c to the project.

Note a slight orthogonality violation. The following work with any
specialised context:

    crypto_sign_update
    crypto_sign_final
    crypto_check_init
    crypto_check_update
    crypto_check_final

But the following requires a *Blake2b* signing context:

    crypto_sign_init_second_pass
    crypto_sign_init_first_pass

This lets us preserve the old function names (making it easier to update
user code), and maybe conveys that Blake2b remains the default hash.

---

Overall, I think we did pretty good: only 3 additional functions in the
main library (and a fourth exported symbol), and we spare the user the
pain of juggling with two contexts instead of just one. The only
drawback are slightly breaking compatibility in the incremental
interface, and requiring an explicit cast to avoid compiler warnings.

6 years agoMerge pull request #136 from fscoto/master+stdint
Loup Vaillant [Sat, 30 Nov 2019 10:34:56 +0000 (11:34 +0100)]
Merge pull request #136 from fscoto/master+stdint

Use stdint.h over inttypes.h

6 years agoUse stdint.h over inttypes.h
Fabio Scotoni [Sat, 30 Nov 2019 07:49:23 +0000 (08:49 +0100)]
Use stdint.h over inttypes.h

Monocypher uses nothing from inttypes.h, other than stdint.h that
inttypes.h indirectly includes.

This seems to make clang --target=wasm32 more amenable to Monocypher in
a freestanding environment.

6 years agoUpdated Wycheproof test vectors
Loup Vaillant [Thu, 28 Nov 2019 21:55:40 +0000 (22:55 +0100)]
Updated Wycheproof test vectors

6 years agoFixed buffer length in test.
Loup Vaillant [Mon, 25 Nov 2019 22:29:39 +0000 (23:29 +0100)]
Fixed buffer length in test.

The buffers tested for equality were too short.  Now we test the whole
of them.

Note: this may not be the only instance of this error.

6 years agoAdded Chacha20 consistency test
Loup Vaillant [Mon, 25 Nov 2019 22:26:45 +0000 (23:26 +0100)]
Added Chacha20 consistency test

I figured the equivalence between giving a stream of zeroes and a null
pointer was insufficiently tested. This is now fixed.

6 years agoSlightly better Chacha20 performance
Loup Vaillant [Mon, 25 Nov 2019 22:14:24 +0000 (23:14 +0100)]
Slightly better Chacha20 performance

6 years agoLocal functions should be static
Loup Vaillant [Mon, 25 Nov 2019 14:47:34 +0000 (15:47 +0100)]
Local functions should be static

6 years agoBumped soname (next release will break the ABI)
Loup Vaillant [Mon, 25 Nov 2019 14:43:34 +0000 (15:43 +0100)]
Bumped soname  (next release will break the ABI)