catacomb
4 years agorand/rand.c: More dynamic assertions converted to use `STATIC_ASSERT'.
Mark Wooding [Thu, 12 Dec 2019 19:11:47 +0000 (19:11 +0000)]
rand/rand.c: More dynamic assertions converted to use `STATIC_ASSERT'.

4 years agoMerge branch '2.5.x'
Mark Wooding [Sat, 9 May 2020 19:55:40 +0000 (20:55 +0100)]
Merge branch '2.5.x'

* 2.5.x:
  Release 2.5.2.
  base/regdump.c: Be helpful about VFP/NEON registers before `regdump_init'.
  base/regdump.h (ARM32, ARM64): Properly parenthesize `_regfmt' arguments.
  base/regdump.c: Dump ARM VFP/NEON registers with the correct source tag.
  debian/catacomb2.symbols: Bump versions for fixed functions.
  Release 2.4.5.
  math/group-parse.c (group-parse): Parse binary-group descriptions.
  math/group-parse.c: Fix copyright notice.
  *.c: Check for ARM64 SIMD before using the accelerated code.
  base/dispatch.c: Recognize `CPUFEAT_ARM_NEON' as requesting ARM64 SIMD.
  symm/t/chacha: Missing test from RFC8439.
  math/t/{mpx,mpmont}: Add some extra tests for flushing out `mul4' bugs.
  math/mpx-mul4-*: Test the `...zc' variants too.
  math/Makefile.am, symm/Makefile.am: Use `--no-install' on oddball tests.
  progs/pixie.c: Don't crash when trying to set an empty passphrase.
  configure.ac, vars.am: Use host-specific link options for test programs.

4 years agoRelease 2.5.2. 2.5.2
Mark Wooding [Sat, 9 May 2020 19:51:15 +0000 (20:51 +0100)]
Release 2.5.2.

4 years agobase/regdump.c: Be helpful about VFP/NEON registers before `regdump_init'.
Mark Wooding [Thu, 7 Nov 2019 01:31:29 +0000 (01:31 +0000)]
base/regdump.c: Be helpful about VFP/NEON registers before `regdump_init'.

On ARM32 (only), you really /must/ call `regdump_init' before dumping
VFP/NEON registers because otherwise there's no way to tell that they
need saving -- so they aren't and an important pointer is left null.

Rather than crashing, detect this and print a message explaining why the
register can't be dumped.

4 years agobase/regdump.h (ARM32, ARM64): Properly parenthesize `_regfmt' arguments.
Mark Wooding [Thu, 7 Nov 2019 01:34:52 +0000 (01:34 +0000)]
base/regdump.h (ARM32, ARM64): Properly parenthesize `_regfmt' arguments.

4 years agobase/regdump.c: Dump ARM VFP/NEON registers with the correct source tag.
Mark Wooding [Thu, 7 Nov 2019 01:30:41 +0000 (01:30 +0000)]
base/regdump.c: Dump ARM VFP/NEON registers with the correct source tag.

Otherwise you get an assertion failure from `regwd'.

4 years agodebian/catacomb2.symbols: Bump versions for fixed functions.
Mark Wooding [Sat, 9 May 2020 17:24:48 +0000 (18:24 +0100)]
debian/catacomb2.symbols: Bump versions for fixed functions.

4 years agoMerge branch '2.4.x' into 2.5.x
Mark Wooding [Sat, 9 May 2020 19:39:18 +0000 (20:39 +0100)]
Merge branch '2.4.x' into 2.5.x

* 2.4.x:
  Release 2.4.5.
  math/group-parse.c (group-parse): Parse binary-group descriptions.
  math/group-parse.c: Fix copyright notice.
  *.c: Check for ARM64 SIMD before using the accelerated code.
  base/dispatch.c: Recognize `CPUFEAT_ARM_NEON' as requesting ARM64 SIMD.
  symm/t/chacha: Missing test from RFC8439.
  math/t/{mpx,mpmont}: Add some extra tests for flushing out `mul4' bugs.
  math/mpx-mul4-*: Test the `...zc' variants too.
  math/Makefile.am, symm/Makefile.am: Use `--no-install' on oddball tests.
  progs/pixie.c: Don't crash when trying to set an empty passphrase.
  configure.ac, vars.am: Use host-specific link options for test programs.

4 years agoRelease 2.4.5. 2.4.5
Mark Wooding [Sat, 9 May 2020 16:58:16 +0000 (17:58 +0100)]
Release 2.4.5.

4 years agomath/group-parse.c (group-parse): Parse binary-group descriptions.
Mark Wooding [Wed, 20 Nov 2019 18:37:01 +0000 (18:37 +0000)]
math/group-parse.c (group-parse): Parse binary-group descriptions.

I don't recommend them, but their omission is a bug.

4 years agomath/group-parse.c: Fix copyright notice.
Mark Wooding [Wed, 20 Nov 2019 18:36:16 +0000 (18:36 +0000)]
math/group-parse.c: Fix copyright notice.

Huh.  I guess I cloned this from TrIPE then.

For the record: this file has actually been subject to LGPL2+ since its
incorporation into Catacomb.

4 years ago*.c: Check for ARM64 SIMD before using the accelerated code.
Mark Wooding [Fri, 15 Nov 2019 17:09:01 +0000 (17:09 +0000)]
*.c: Check for ARM64 SIMD before using the accelerated code.

I don't expect ARM64 processors to omit the SIMD instructions, but it's
convenient to have a way to inhibit the accelerated code (e.g., for
performance measurement).

4 years agobase/dispatch.c: Recognize `CPUFEAT_ARM_NEON' as requesting ARM64 SIMD.
Mark Wooding [Fri, 15 Nov 2019 17:06:46 +0000 (17:06 +0000)]
base/dispatch.c: Recognize `CPUFEAT_ARM_NEON' as requesting ARM64 SIMD.

The original ARMv8 spec describes the advanced SIMD instructions as
mandatory, but there's a feature flag for them, so I guess that there
might be processors which don't support them.

4 years agosymm/t/chacha: Missing test from RFC8439.
Mark Wooding [Mon, 4 Nov 2019 13:33:03 +0000 (13:33 +0000)]
symm/t/chacha: Missing test from RFC8439.

4 years agomath/t/{mpx,mpmont}: Add some extra tests for flushing out `mul4' bugs.
Mark Wooding [Sat, 9 Nov 2019 00:41:46 +0000 (00:41 +0000)]
math/t/{mpx,mpmont}: Add some extra tests for flushing out `mul4' bugs.

4 years agomath/mpx-mul4-*: Test the `...zc' variants too.
Mark Wooding [Mon, 4 Nov 2019 11:59:28 +0000 (11:59 +0000)]
math/mpx-mul4-*: Test the `...zc' variants too.

4 years agomath/Makefile.am, symm/Makefile.am: Use `--no-install' on oddball tests.
Mark Wooding [Sat, 9 May 2020 13:24:15 +0000 (14:24 +0100)]
math/Makefile.am, symm/Makefile.am: Use `--no-install' on oddball tests.

There are a small number of test programs -- mostly for unsaturated
bignum code built specially to test unusual piece sizes -- and these
should be built with `-no-install' or whataver just like the normal test
programs.

4 years agoprogs/pixie.c: Don't crash when trying to set an empty passphrase.
Mark Wooding [Sat, 26 Oct 2019 14:51:22 +0000 (15:51 +0100)]
progs/pixie.c: Don't crash when trying to set an empty passphrase.

4 years agoconfigure.ac, vars.am: Use host-specific link options for test programs.
Mark Wooding [Sat, 9 May 2020 12:26:13 +0000 (13:26 +0100)]
configure.ac, vars.am: Use host-specific link options for test programs.

It turns out that `libtool' spams an annoying warning message to the
terminal every time you call it with `-no-install' on a Windowsish or
Mac OSish system.  Since this is just intended to be an optimization and
developer-convenience feature, wind it down to `-no-fast-install' on the
affected platforms so as not to provoke these really annoying messages.

4 years agoRelease 1.4.0.
Mark Wooding [Fri, 8 May 2020 02:45:30 +0000 (03:45 +0100)]
Release 1.4.0.

4 years agomdwsetup.py: Turn off Python's usual `SIGINT' handler.
Mark Wooding [Mon, 13 Apr 2020 11:29:22 +0000 (12:29 +0100)]
mdwsetup.py: Turn off Python's usual `SIGINT' handler.

Without this, a buggy native-code extension can loop forever, and Emacs
can't easily be persuaded to kill it.

4 years agopysetup.mk: Handle the `DESTDIR' install variable usefully.
Mark Wooding [Mon, 25 Nov 2019 15:04:07 +0000 (15:04 +0000)]
pysetup.mk: Handle the `DESTDIR' install variable usefully.

4 years agopysetup.mk: Remove pointless explicit `make' step in `distcheck'.
Mark Wooding [Mon, 14 Oct 2019 10:29:44 +0000 (11:29 +0100)]
pysetup.mk: Remove pointless explicit `make' step in `distcheck'.

Now that `check/PYTHON' depends on `all/PYTHON', this just adds a
serialization point which we don't need or want.

4 years agomdwsetup.py: Add a command for running tests.
Mark Wooding [Wed, 9 Oct 2019 18:50:56 +0000 (19:50 +0100)]
mdwsetup.py: Add a command for running tests.

4 years agopysetup.mk: Pass `make' flags down to `distcheck' build rules.
Mark Wooding [Mon, 14 Oct 2019 10:26:46 +0000 (11:26 +0100)]
pysetup.mk: Pass `make' flags down to `distcheck' build rules.

This firstly means that Makefile variables such as `PYTHON' are honoured
properly, and secondly that flags requesting parallel building are
respected.

4 years agopysetup.mk: Run commands on multiple `python's, possibly in parallel.
Mark Wooding [Mon, 14 Oct 2019 10:22:16 +0000 (11:22 +0100)]
pysetup.mk: Run commands on multiple `python's, possibly in parallel.

Most targets delegated to `setup.py' are now run, in parallel, on
multiple Python versions listed in the new Makefile variable `PYTHONS'.
The exceptions are `gen' and `dist', which only make sense with a single
Python.

Targets which can run multiple Python versions now support per-version
options for targets: set the variable OPTS-TARGET/PYTHON (e.g.,
`OPTS-install/python3.5').

4 years agopysetup.mk: Add an explicit `gen' target, and make `all' depend on it.
Mark Wooding [Mon, 14 Oct 2019 10:37:41 +0000 (11:37 +0100)]
pysetup.mk: Add an explicit `gen' target, and make `all' depend on it.

I plan to add support for multiple `python' versions building in
parallel in the same working tree.  But generated files are shared
between `python' versions, and there will be a mess if things happen in
the wrong order.

4 years agomdwsetup.py: Insert a space before direct-superclass lists.
Mark Wooding [Wed, 9 Oct 2019 17:02:49 +0000 (18:02 +0100)]
mdwsetup.py: Insert a space before direct-superclass lists.

4 years agomdwsetup.py: Fixes for Python 3 compatibility.
Mark Wooding [Tue, 1 Oct 2019 22:57:28 +0000 (23:57 +0100)]
mdwsetup.py: Fixes for Python 3 compatibility.

  * Write parentheses around `print' operands.

  * Set `universal_newlines' on in `Popen' to force handling in text
    mode.

  * Use an unpleasant hack to inject the `CommandClass' metaclass,
    because the official syntax is so different between the two
    versions.

4 years agomdwsetup.py (progoutput): Only read one byte to decide whether there is more.
Mark Wooding [Fri, 4 Oct 2019 15:22:15 +0000 (16:22 +0100)]
mdwsetup.py (progoutput): Only read one byte to decide whether there is more.

There's no point in slurping the entire output now that we're closing
the pipe /before/ trying to waitpid(2): the child will hit `SIGPIPE' (or
`EPIPE') rather than blocking on output.

4 years agomdwsetup.py (progoutput): Explicitly close the `stdout' pipe.
Mark Wooding [Fri, 4 Oct 2019 15:10:50 +0000 (16:10 +0100)]
mdwsetup.py (progoutput): Explicitly close the `stdout' pipe.

4 years agomdwsetup.py (pkg_config): Check environment for settings.
Mark Wooding [Tue, 1 Oct 2019 21:57:40 +0000 (22:57 +0100)]
mdwsetup.py (pkg_config): Check environment for settings.

This can override or replace pkg-config(1), similar to the
`PKG_CHECK_MODULES' Autoconf macro.

4 years agomdwsetup.py (pkg_config): Change the token shown in error reports.
Mark Wooding [Tue, 1 Oct 2019 21:57:13 +0000 (22:57 +0100)]
mdwsetup.py (pkg_config): Change the token shown in error reports.

4 years agomdwsetup.py (pkg_config): Rearrange and reformat.
Mark Wooding [Tue, 1 Oct 2019 21:56:27 +0000 (22:56 +0100)]
mdwsetup.py (pkg_config): Rearrange and reformat.

4 years agomdwsetup.py: Don't use the ancient `raise' syntax.
Mark Wooding [Tue, 1 Oct 2019 21:54:45 +0000 (22:54 +0100)]
mdwsetup.py: Don't use the ancient `raise' syntax.

4 years agoauto-version.in: Prefix Git version with mangled `x.y.z~' Debian version.
Mark Wooding [Tue, 1 Oct 2019 11:01:27 +0000 (12:01 +0100)]
auto-version.in: Prefix Git version with mangled `x.y.z~' Debian version.

The mangling is necessary to placate `pkg-config', which doesn't
implement `rpmvercmp' properly.

4 years agoMerge branch '1.3.x'
Mark Wooding [Fri, 8 May 2020 11:29:24 +0000 (12:29 +0100)]
Merge branch '1.3.x'

* 1.3.x:
  Release 1.3.15.
  mdwsetup.py: Adjust exit status from `subprocess'.
  mdwsetup.py: Fix unbound variable reference in error case.
  mdwsetup.py: Add missing `OS.' qualifier on `W...' calls.
  texinice.tex: Cope with new names for page-dimension registers.
  Makefile.am:  Tweak `silent-rules' machinery.
  auto-version.in: Don't insist that `.git' is a directory.

4 years agoRelease 1.3.15.
Mark Wooding [Fri, 8 May 2020 02:00:35 +0000 (03:00 +0100)]
Release 1.3.15.

Release 1.3.16.

4 years agomdwsetup.py: Adjust exit status from `subprocess'.
Mark Wooding [Sat, 19 Oct 2019 16:08:28 +0000 (17:08 +0100)]
mdwsetup.py: Adjust exit status from `subprocess'.

It doesn't return the raw status from `wait', but some kind of
inconvenient cooked status.

4 years agomdwsetup.py: Fix unbound variable reference in error case.
Mark Wooding [Fri, 8 May 2020 11:24:18 +0000 (12:24 +0100)]
mdwsetup.py: Fix unbound variable reference in error case.

This is debris from f74ba2bb507cfeadd5518d5468c7ab7281b581b7 which
changed a function into a class, and the `source' argument into (a) a
list and (b) an instance variable.  Fix this reference which should have
changed along with the rest.

4 years agomdwsetup.py: Add missing `OS.' qualifier on `W...' calls.
Mark Wooding [Sat, 19 Oct 2019 16:07:52 +0000 (17:07 +0100)]
mdwsetup.py: Add missing `OS.' qualifier on `W...' calls.

Evidently this code hasn't been tested before.

4 years agotexinice.tex: Cope with new names for page-dimension registers.
Mark Wooding [Tue, 7 Apr 2020 19:14:44 +0000 (20:14 +0100)]
texinice.tex: Cope with new names for page-dimension registers.

Texinfo 6.2 apparently renamed `\pagewidth' to `\txipagewidth', and
similarly for `\pageheight', to avoid some conflict with LuaTeX.  Fix
`@afourpaper' to with these new names.

(cherry picked from commits 892a9f865ad8baed5c67ddf9d68301c916bfb0f1 and
0b5f869b689a085655df9e1a261eacf8c7facade)

4 years agoMakefile.am: Tweak `silent-rules' machinery.
Mark Wooding [Sat, 22 Jul 2017 10:43:11 +0000 (11:43 +0100)]
Makefile.am:  Tweak `silent-rules' machinery.

Since Automake 1.11, the advice for setting up custom silent-rules
recipes has changed, so use the new machinery.

Also, I'm no longer mainly working on wheezy, and Automake has made the
operation field two spaces wider while I wasn't looking, so make the
output line up properly.

This means that CFD now requires Automake 1.11.2 or later to build from
the Git tree.

(cherry picked from commit 262cdcea7d345a0e523957de46fceed547f2de44)

4 years agoauto-version.in: Don't insist that `.git' is a directory.
Mark Wooding [Sat, 22 Jul 2017 10:35:55 +0000 (11:35 +0100)]
auto-version.in: Don't insist that `.git' is a directory.

Nowadays, `git worktree' can cause this to be a regular file instead,
and it's a shame if we can't spot it properly.

(cherry picked from commit e3bf207c8bde1191c3850debd27ac604305bff31)

4 years agoMerge branch '2.5.x'
Mark Wooding [Wed, 6 May 2020 09:18:58 +0000 (10:18 +0100)]
Merge branch '2.5.x'

* 2.5.x:
  vars.am: Don't build the test programs for installation.

4 years agoMerge branch '2.4.x' into 2.5.x
Mark Wooding [Wed, 6 May 2020 09:18:44 +0000 (10:18 +0100)]
Merge branch '2.4.x' into 2.5.x

* 2.4.x:
  vars.am: Don't build the test programs for installation.

4 years agovars.am: Don't build the test programs for installation.
Mark Wooding [Wed, 6 May 2020 09:16:01 +0000 (10:16 +0100)]
vars.am: Don't build the test programs for installation.

Most importantly, this makes them much easier to attach a debugger to,
because the actual executables are now where you expect, and you don't
have to write ridiculous runes involving `../libtool --mode=execute
...'.

Also, this makes the actual linking step somewhat faster.

4 years agotexinice.tex: Fix bungled change.
Mark Wooding [Mon, 27 Apr 2020 09:19:01 +0000 (10:19 +0100)]
texinice.tex: Fix bungled change.

Alas, `@' is still magical, so comparing against `\@@undefined' is
inadvisable.

4 years agoMerge branch 'master' of git.distorted.org.uk:~mdw/publish/public-git/cfd
Mark Wooding [Mon, 27 Apr 2020 09:07:45 +0000 (10:07 +0100)]
Merge branch 'master' of git.distorted.org.uk:~mdw/publish/public-git/cfd

* 'master' of git.distorted.org.uk:~mdw/publish/public-git/cfd:
  texinice.tex: Cope with new names for page-dimension registers.

4 years agotexinice.tex: Cope with new names for page-dimension registers.
Mark Wooding [Tue, 7 Apr 2020 19:14:44 +0000 (20:14 +0100)]
texinice.tex: Cope with new names for page-dimension registers.

Texinfo 6.2 apparently renamed `\pagewidth' to `\txipagewidth', and
similarly for `\pageheight', to avoid some conflict with LuaTeX.  Fix
`@afourpaper' to with these new names.

4 years agodebian/rules: Don't pass `--without=...' to all Debhelper programs.
Mark Wooding [Sat, 22 Jul 2017 10:40:53 +0000 (11:40 +0100)]
debian/rules: Don't pass `--without=...' to all Debhelper programs.

4 years agoMakefile.am: Tweak `silent-rules' machinery.
Mark Wooding [Sat, 22 Jul 2017 10:43:11 +0000 (11:43 +0100)]
Makefile.am:  Tweak `silent-rules' machinery.

Since Automake 1.11, the advice for setting up custom silent-rules
recipes has changed, so use the new machinery.

Also, I'm no longer mainly working on wheezy, and Automake has made the
operation field two spaces wider while I wasn't looking, so make the
output line up properly.

This means that CFD now requires Automake 1.11.2 or later to build from
the Git tree.

4 years agoauto-version.in: Don't insist that `.git' is a directory.
Mark Wooding [Sat, 22 Jul 2017 10:35:55 +0000 (11:35 +0100)]
auto-version.in: Don't insist that `.git' is a directory.

Nowadays, `git worktree' can cause this to be a regular file instead,
and it's a shame if we can't spot it properly.

4 years agobase/dispatch-x86ish.S: Fix build failure from incompetent cherry-pick.
Mark Wooding [Fri, 27 Mar 2020 17:19:00 +0000 (17:19 +0000)]
base/dispatch-x86ish.S: Fix build failure from incompetent cherry-pick.

The `SP' register-name macro used in 25f3ce6... comes from the future.
Fortunately, we don't actually need it here.

4 years agomath/f25519.c: Fix spelling of `weird'.
Mark Wooding [Fri, 27 Mar 2020 17:09:12 +0000 (17:09 +0000)]
math/f25519.c: Fix spelling of `weird'.

4 years agobase/dispatch.c, etc.: Replace inline assembler for the `rdrand' fix.
Mark Wooding [Tue, 29 Oct 2019 18:59:32 +0000 (18:59 +0000)]
base/dispatch.c, etc.: Replace inline assembler for the `rdrand' fix.

4 years agoMerge branch '2.5.x'
Mark Wooding [Mon, 16 Dec 2019 17:21:25 +0000 (17:21 +0000)]
Merge branch '2.5.x'

* 2.5.x:
  debian/catacomb2.symbols: Bump versions for fixed functions.
  rand/rand.c: Mix the pool key in `rand_gate' and `rand_stretch'.
  rand/lcrand.c: Swap flags and max so generator not advertised as strong.
  pub/dh-kcdsa.c: Free the correct factor.
  math/limlee.c: Don't leak the factor vector on overall failure.
  math/limlee.c: Handle an abort from `pgen' correctly.
  math/pgen.c: Don't free the tester if it's not set up.
  math/ec-exp.h: Fix segfault when base point is at infinity.
  key/key-data.c (key_copydata): Fix catastrophic bug.
  key/key-data.c (key_split): Fix long-standing reference leak.
  key/key-misc.c (key_bytag): Don't give up because a by-id search fails.
  base/dispatch.c, etc.: Check that `rdrand' works.

4 years agodebian/catacomb2.symbols: Bump versions for fixed functions.
Mark Wooding [Mon, 16 Dec 2019 16:48:01 +0000 (16:48 +0000)]
debian/catacomb2.symbols: Bump versions for fixed functions.

I didn't do this for the 2.4.x branch because there's no way to say
`2.4.x with x > 4 or 2.5.x with x > 1'.  But I can be sure that all
releases beyond 2.5.1 will have the fixes.

There's no version-bump for the `rdrand' fix.  I'm not leaning on it
very hard.

4 years agoMerge branch '2.4.x' into 2.5.x
Mark Wooding [Mon, 16 Dec 2019 17:20:15 +0000 (17:20 +0000)]
Merge branch '2.4.x' into 2.5.x

* 2.4.x:
  rand/rand.c: Mix the pool key in `rand_gate' and `rand_stretch'.
  rand/lcrand.c: Swap flags and max so generator not advertised as strong.
  pub/dh-kcdsa.c: Free the correct factor.
  math/limlee.c: Don't leak the factor vector on overall failure.
  math/limlee.c: Handle an abort from `pgen' correctly.
  math/pgen.c: Don't free the tester if it's not set up.
  math/ec-exp.h: Fix segfault when base point is at infinity.
  key/key-data.c (key_copydata): Fix catastrophic bug.
  key/key-data.c (key_split): Fix long-standing reference leak.
  key/key-misc.c (key_bytag): Don't give up because a by-id search fails.
  base/dispatch.c, etc.: Check that `rdrand' works.

4 years agorand/rand.c: Mix the pool key in `rand_gate' and `rand_stretch'.
Mark Wooding [Thu, 12 Dec 2019 19:12:26 +0000 (19:12 +0000)]
rand/rand.c: Mix the pool key in `rand_gate' and `rand_stretch'.

Back in commit d6fab4f6ae209afd6799a2974ce2849123965170, I rearranged
the cryptography to use plain SHA256 rather than RIPEMD160-HMAC for
determining the cipher key for churning the generator state.

I also managed to remove all the points at which the key actually
influences the behaviour of the generator!

This was four years ago, and I can't remember exactly why, but my guess
is that the key was previously inserted as part of `rmd160_macinit',
which was replaced by the unheyed `HASH_INIT' function.

4 years agorand/lcrand.c: Swap flags and max so generator not advertised as strong.
Mark Wooding [Fri, 15 Nov 2019 19:37:29 +0000 (19:37 +0000)]
rand/lcrand.c: Swap flags and max so generator not advertised as strong.

Oh, dear.  This isn't good.

Even worse, this means that `max' was advertised as zero, so the outputs
have been biased.

4 years agopub/dh-kcdsa.c: Free the correct factor.
Mark Wooding [Wed, 23 Oct 2019 03:10:27 +0000 (04:10 +0100)]
pub/dh-kcdsa.c: Free the correct factor.

4 years agomath/limlee.c: Don't leak the factor vector on overall failure.
Mark Wooding [Thu, 14 Nov 2019 20:17:58 +0000 (20:17 +0000)]
math/limlee.c: Don't leak the factor vector on overall failure.

The `done' function doesn't know whether we succeeded or failed, so it
prepares the factor vector for output regardless.  In `limlee', if we
don't have a result, then release the factors.

4 years agomath/limlee.c: Handle an abort from `pgen' correctly.
Mark Wooding [Thu, 14 Nov 2019 19:53:27 +0000 (19:53 +0000)]
math/limlee.c: Handle an abort from `pgen' correctly.

The `llgen' function just tries again if `pgen' reports an abort.  This
is entirely contrary to the intend of the `PGEN_ABORT' protocol, so I've
no idea why I thought this was a good idea.

Instead, leave the prime slot null (because adding a return code to the
`pgen' callback breaks the API), and arrange for the caller to notice
and clean up.  This is annoyingly because there may be an `mpmul' in
progress.

4 years agomath/pgen.c: Don't free the tester if it's not set up.
Mark Wooding [Thu, 14 Nov 2019 19:46:53 +0000 (19:46 +0000)]
math/pgen.c: Don't free the tester if it's not set up.

The problem flow is this:

  * The stepper reports a candidate (`p' is `P_STEP', and `proc' returns
    `PGEN_TRY').

  * We decide to (a) report an event (set `A_EVENT' in `act'), and (b)
    initialize the tester (set `p = P_TEST', `proc = test', and `rq =
    PGEN_BEGIN'.

  * We call the event handler, but it returns `PGEN_ABORT'.  We notice
    that `p == P_TEST', and set `A_ENDTEST'.

  * This causes us to call `test' with `PGEN_DONE'.  Alas, the tester
    hasn't been initialized, because we haven't actually called it with
    `PGEN_BEGIN' yet.  Result: segfault.

We can notice this because `rq == PGEN_BEGIN': don't set `A_ENDTEST'
if this is the case.

4 years agomath/ec-exp.h: Fix segfault when base point is at infinity.
Mark Wooding [Fri, 18 Oct 2019 21:45:01 +0000 (22:45 +0100)]
math/ec-exp.h: Fix segfault when base point is at infinity.

4 years agokey/key-data.c (key_copydata): Fix catastrophic bug.
Mark Wooding [Thu, 21 Nov 2019 17:43:51 +0000 (17:43 +0000)]
key/key-data.c (key_copydata): Fix catastrophic bug.

The fundamental problem is that the key-encoding test has the wrong
sense.  The result is that we end up (only) trying to iterate over non-
structured keys, which results in an assertion failure.

Also, switch things around so that we check the encoding type before
checking the flags.

4 years agokey/key-data.c (key_split): Fix long-standing reference leak.
Mark Wooding [Tue, 8 Oct 2019 19:23:01 +0000 (20:23 +0100)]
key/key-data.c (key_split): Fix long-standing reference leak.

4 years agokey/key-misc.c (key_bytag): Don't give up because a by-id search fails.
Mark Wooding [Sat, 26 Oct 2019 14:38:25 +0000 (15:38 +0100)]
key/key-misc.c (key_bytag): Don't give up because a by-id search fails.

This came to my attention when searching for a key of type `ec' didn't
work because it looks like a hex number.  This obviously sucks.

4 years agobase/dispatch.c, etc.: Check that `rdrand' works.
Mark Wooding [Wed, 30 Oct 2019 00:45:11 +0000 (00:45 +0000)]
base/dispatch.c, etc.: Check that `rdrand' works.

When probing for `rdrand', check to make sure that it doesn't just
return the same thing every time, and that it can reasonably well make
progress.  We check that up to five 32-bit samples are not all the same,
which will mistakenly mark a working CPU as defective with probability
2^-128.

It seems that some processors will return a constant value from `rdrand'
but set the carry flag to indicate that it's properly random anyway.
See

https://arstechnica.com/gadgets/2019/10/how-a-months-old-amd-microcode-bug-destroyed-my-weekend/

as an example.

4 years agoMerge branch '2.5.x'
Mark Wooding [Tue, 8 Oct 2019 10:48:32 +0000 (11:48 +0100)]
Merge branch '2.5.x'

* 2.5.x:
  key/key-io.c: Mark `exptime' function `static'.
  key/key-io.c (key_new): Don't leak attribute `sym_table' on error.

4 years agodebian/.gitignore: Ignore `catacomb-data' directory.
Mark Wooding [Tue, 8 Oct 2019 10:47:53 +0000 (11:47 +0100)]
debian/.gitignore: Ignore `catacomb-data' directory.

4 years agoMerge branch '2.4.x' into 2.5.x
Mark Wooding [Tue, 8 Oct 2019 10:45:56 +0000 (11:45 +0100)]
Merge branch '2.4.x' into 2.5.x

* 2.4.x:
  key/key-io.c: Mark `exptime' function `static'.
  key/key-io.c (key_new): Don't leak attribute `sym_table' on error.

4 years agokey/key-io.c: Mark `exptime' function `static'.
Mark Wooding [Tue, 8 Oct 2019 10:44:19 +0000 (11:44 +0100)]
key/key-io.c: Mark `exptime' function `static'.

I think it was always meant to be so.  It doesn't have a prefix, and
isn't used anywhere else.  Leaking it into the client namespace was just
a mistake.

4 years agokey/key-io.c (key_new): Don't leak attribute `sym_table' on error.
Mark Wooding [Tue, 8 Oct 2019 10:36:34 +0000 (11:36 +0100)]
key/key-io.c (key_new): Don't leak attribute `sym_table' on error.

This is safe: `insert' doesn't do anything with `k->a'.

4 years agodebian/: Bump to Debhelper 10.
Mark Wooding [Tue, 1 Oct 2019 20:28:06 +0000 (21:28 +0100)]
debian/: Bump to Debhelper 10.

4 years agodebian/changelog: Prepare for the next version.
Mark Wooding [Tue, 1 Oct 2019 11:01:08 +0000 (12:01 +0100)]
debian/changelog: Prepare for the next version.

4 years agoMerge branch '2.5.x'
Mark Wooding [Tue, 1 Oct 2019 20:43:41 +0000 (21:43 +0100)]
Merge branch '2.5.x'

* 2.5.x:
  catacomb.pc.in: Update dependency on mLib.

4 years agoMerge branch '2.4.x' into 2.5.x
Mark Wooding [Tue, 1 Oct 2019 20:43:29 +0000 (21:43 +0100)]
Merge branch '2.4.x' into 2.5.x

* 2.4.x:
  catacomb.pc.in: Update dependency on mLib.

4 years agocatacomb.pc.in: Update dependency on mLib.
Mark Wooding [Tue, 1 Oct 2019 11:54:27 +0000 (12:54 +0100)]
catacomb.pc.in: Update dependency on mLib.

The most recent relevant change appears to be

    commit 4d845619c3f21fe19dd7f7b16815281b34de9e33
    Author: Mark Wooding <mdw@distorted.org.uk>
    Date:   Sat, 26 May 2018 23:31:00 +0100

codec/url.c: Always encode whitespace characters.

Vertical whitespace is obviously bad, so this is a longstanding bug; but
all whitespace should really be escaped.

which was first released as part of 2.3.0.

4 years agodebian/changelog: Lower placeholder version for benefit of `pkg-config'.
Mark Wooding [Tue, 1 Oct 2019 20:41:20 +0000 (21:41 +0100)]
debian/changelog: Lower placeholder version for benefit of `pkg-config'.

Because it doesn't implement the convention that `~' sorts before
anything else, even though that's a defined part of the RPM
version-number system which it claims to implement.

4 years agodebian/changelog: Prepare for next release.
Mark Wooding [Mon, 30 Sep 2019 01:19:12 +0000 (02:19 +0100)]
debian/changelog: Prepare for next release.

4 years agosymm/keccak1600.c (keccak1600_extract): Eliminate intermediate state buffer.
Mark Wooding [Sat, 17 Nov 2018 21:08:11 +0000 (21:08 +0000)]
symm/keccak1600.c (keccak1600_extract): Eliminate intermediate state buffer.

Instead, introduce a handy bitmap which identifies which lanes need
complementing and do the whole thing in the loop.

4 years agorand/lcrand.c, rand/rand.c: Replace dynamic assertions with static ones.
Mark Wooding [Sun, 29 Sep 2019 14:44:26 +0000 (15:44 +0100)]
rand/lcrand.c, rand/rand.c: Replace dynamic assertions with static ones.

This adds a dependency on mLib 2.4.1.

4 years agobase/keysz.c: Delete trailing `,' in enum.
Mark Wooding [Sat, 28 Sep 2019 01:05:48 +0000 (02:05 +0100)]
base/keysz.c: Delete trailing `,' in enum.

4 years agomath/mpx.c: Fix function name in header comment.
Mark Wooding [Sat, 28 Sep 2019 01:05:27 +0000 (02:05 +0100)]
math/mpx.c: Fix function name in header comment.

4 years agoMerge branch '2.5.x'
Mark Wooding [Sun, 29 Sep 2019 17:42:35 +0000 (18:42 +0100)]
Merge branch '2.5.x'

* 2.5.x:
  Release 2.5.1.
  Release 2.4.4.
  debian/: Ship correct symbols files.
  debian/: Bump to Debhelper 10.
  debian/rules: Prefix `dh' options with `-O' to prevent sadness.

4 years agoRelease 2.5.1. 2.5.1
Mark Wooding [Sun, 29 Sep 2019 16:57:10 +0000 (17:57 +0100)]
Release 2.5.1.

4 years agoMerge branch '2.4.x' into 2.5.x
Mark Wooding [Sun, 29 Sep 2019 16:52:39 +0000 (17:52 +0100)]
Merge branch '2.4.x' into 2.5.x

* 2.4.x:
  Release 2.4.4.
  debian/: Ship correct symbols files.
  debian/: Bump to Debhelper 10.
  debian/rules: Prefix `dh' options with `-O' to prevent sadness.

Conflicts:
debian/changelog (take both)
debian/control

Also fix debian/catacomb2.symbols to add new symbols; bump `pgen_primep'
to 2.5.0 to ensure that the Baillie--PSW test is used.

4 years agoRelease 2.4.4. 2.4.4
Mark Wooding [Sun, 29 Sep 2019 14:58:57 +0000 (15:58 +0100)]
Release 2.4.4.

4 years agodebian/: Ship correct symbols files.
Mark Wooding [Sat, 28 Sep 2019 00:21:53 +0000 (01:21 +0100)]
debian/: Ship correct symbols files.

4 years agodebian/: Bump to Debhelper 10.
Mark Wooding [Sun, 29 Sep 2019 14:56:38 +0000 (15:56 +0100)]
debian/: Bump to Debhelper 10.

4 years agodebian/rules: Prefix `dh' options with `-O' to prevent sadness.
Mark Wooding [Sun, 29 Sep 2019 15:39:13 +0000 (16:39 +0100)]
debian/rules: Prefix `dh' options with `-O' to prevent sadness.

4 years agoMostly abolish inline assembler code in favour of dedicated files.
Mark Wooding [Thu, 26 Sep 2019 11:11:50 +0000 (12:11 +0100)]
Mostly abolish inline assembler code in favour of dedicated files.

Move the fancy feature probing from `dispatch.c'.  This makes it easier to
understand because it's not covered in `%' sigils and backwards, and
also simplifies things because we have better machinery for papering
over the differences between 32- and 64-bit instruction sets.

Also move the `rdrand' code from `rand.c'.  This makes things
significantly more complicated because it calls back into C, but it does
improve availability of a security feature, so that's good.

That leaves only a use of `rdtsc' in `perftest.c', which is hardly
critical, and the `rbit' in the ARM64 `gcm.c' code, which has a slightly
slower portable alternative.

4 years agobase/regdump.h: Add missing `regfmt.' definitions for `eflags', `rflags'.
Mark Wooding [Thu, 26 Sep 2019 12:50:21 +0000 (13:50 +0100)]
base/regdump.h: Add missing `regfmt.' definitions for `eflags', `rflags'.

Not having these causes GNU `as' to segfault, which is a little
alarming.

4 years agobase/regdump.h: Add missing `F(...)' around `callext' targets.
Mark Wooding [Thu, 26 Sep 2019 12:49:45 +0000 (13:49 +0100)]
base/regdump.h: Add missing `F(...)' around `callext' targets.

Probably broke Windows.

4 years agoMerge branch '2.4.x' into 2.5.x
Mark Wooding [Fri, 27 Sep 2019 00:25:58 +0000 (01:25 +0100)]
Merge branch '2.4.x' into 2.5.x

* 2.4.x:
  base/dispatch.c: Check for XMM registers after CPUID probe.
  rand/noise.c: Fix foolish bug in the `getentropy' code.

4 years agobase/dispatch.c: Check for XMM registers after CPUID probe.
Mark Wooding [Thu, 26 Sep 2019 11:09:10 +0000 (12:09 +0100)]
base/dispatch.c: Check for XMM registers after CPUID probe.

`fxsave' isn't universally available, but if CPUID is reporting that XMM
instructions are available, we can definitely use it.

4 years agorand/noise.c: Fix foolish bug in the `getentropy' code.
Mark Wooding [Thu, 26 Sep 2019 16:03:46 +0000 (17:03 +0100)]
rand/noise.c: Fix foolish bug in the `getentropy' code.

I've probably never built this before. :-/

4 years agoRelease 2.5.0. 2.5.0
Mark Wooding [Sat, 21 Sep 2019 20:29:19 +0000 (21:29 +0100)]
Release 2.5.0.