chiark / gitweb /
catacomb
3 years agoRelease 2.6.1. 2.6.1
Mark Wooding [Mon, 25 May 2020 16:45:24 +0000 (17:45 +0100)]
Release 2.6.1.

3 years agorand/rand-x86ish.S: Establish GOT pointer before making an i386 PLT call.
Mark Wooding [Mon, 25 May 2020 16:36:13 +0000 (17:36 +0100)]
rand/rand-x86ish.S: Establish GOT pointer before making an i386 PLT call.

Otherwise you just get a segfault.

3 years agoRelease 2.6.0. 2.6.0
Mark Wooding [Sat, 9 May 2020 16:39:28 +0000 (17:39 +0100)]
Release 2.6.0.

3 years agobase/dispatch.c, rand/rand.c, and asm: Support `rdseed' for quick noise.
Mark Wooding [Mon, 6 Apr 2020 00:07:41 +0000 (00:07 +0000)]
base/dispatch.c, rand/rand.c, and asm: Support `rdseed' for quick noise.

Prefer the `rdseed' instruction over `rdrand' for quick randomness, if
it's available.

3 years agorand/rand-x86ish.S: Hoist argument register allocation outside.
Mark Wooding [Mon, 6 Apr 2020 00:06:27 +0000 (00:06 +0000)]
rand/rand-x86ish.S: Hoist argument register allocation outside.

This will soon be shared with another entry point for `rdseed'.

3 years agorand/rand-x86ish.S: Add missing `undef' of the `COUNT' register.
Mark Wooding [Mon, 6 Apr 2020 00:04:57 +0000 (00:04 +0000)]
rand/rand-x86ish.S: Add missing `undef' of the `COUNT' register.

3 years agobase/dispatch.c, base/dispatch-x86ish.S: Add opcode to `rdrand_works_p'.
Mark Wooding [Mon, 6 Apr 2020 00:02:41 +0000 (00:02 +0000)]
base/dispatch.c, base/dispatch-x86ish.S: Add opcode to `rdrand_works_p'.

I want to add support foer the `rdseed' instruction, but this might be
broken on AMD64 like `rdrand'.  Rather than duplicate this logic, add an
opcode argument to the checking functions.

3 years agobase/dispatch.c: Make `cpuid_feature_p' more easily extensible.
Mark Wooding [Sun, 5 Apr 2020 23:52:56 +0000 (23:52 +0000)]
base/dispatch.c: Make `cpuid_feature_p' more easily extensible.

It turns out that Intel scatter feature flags throughout the various
CPUID leaves.  Change the interface for checking these flags so that we
can cover more ground without too much extra work.

  * Firstly, rename the function to `cpuid_feature_p' because it's only
    really useful for checking one feature at a time.

  * Secondly, make the first argument be a code indicating which
    particular `cpuid' output we're interested in; the second is still a
    mask used to check for the bit we're interested in.

Obviously this involves changing all of the callers too.

3 years agorand/dsarand.c: Return the old number of passes from `DSARAND_PASSES'.
Mark Wooding [Sat, 16 Nov 2019 17:12:16 +0000 (17:12 +0000)]
rand/dsarand.c: Return the old number of passes from `DSARAND_PASSES'.

Also, don't update if the input operand is zero.

3 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).

3 years agobase/dispatch.c: Reformat an ugly line-break.
Mark Wooding [Fri, 15 Nov 2019 17:08:30 +0000 (17:08 +0000)]
base/dispatch.c: Reformat an ugly line-break.

3 years agomath/mpx-mul4-{arm-neon,arm64-simd}.S, etc.: Add ARM versions of `mul4'.
Mark Wooding [Mon, 4 Nov 2019 12:22:00 +0000 (12:22 +0000)]
math/mpx-mul4-{arm-neon,arm64-simd}.S, etc.: Add ARM versions of `mul4'.

With this, I think we (finally) have parity across the various premier
target platforms.

3 years agobase/regdump.[ch]: Add a feature for printing plain messages.
Mark Wooding [Thu, 7 Nov 2019 01:34:06 +0000 (01:34 +0000)]
base/regdump.[ch]: Add a feature for printing plain messages.

Introduce a `REGSRC_NONE' which just prints the message, and add a `msg'
macro which invokes this.

3 years agomath/mpmont.c: Fix comment title for `mulcore'.
Mark Wooding [Thu, 7 Nov 2019 01:41:55 +0000 (01:41 +0000)]
math/mpmont.c: Fix comment title for `mulcore'.

3 years agomath/mpx-mul4-*.S: Output expanded Montgomery factor in a sensible order.
Mark Wooding [Tue, 5 Nov 2019 11:13:03 +0000 (11:13 +0000)]
math/mpx-mul4-*.S: Output expanded Montgomery factor in a sensible order.

The current order is (y'_0, y'_1; y''_0, y''_1), (y'_2, y'_3; y''_2,
y''_3), but while this makes sense in the context of SSE2, it's not
really very satisfactory as a common currency.  (In particular, if we
want to resolve the expanded factor into a value then we'll have to do
it by steam because the limb placements are irregular.)

Instead, fix the ordering in the test stubs so that the pieces come out
as (y'_0, y''_0; y'_1, y''_1), (y'_2, y''_2; y'_3, y''_3), which is
generally much better to work with outside of SSE2.

Of course, this only affects testing, not the actual code, so
performance is unchanged.

3 years agomath/mpx-mul4-amd64-sse2.S: Improve the end-of-loop condition testing.
Mark Wooding [Thu, 7 Nov 2019 01:54:57 +0000 (01:54 +0000)]
math/mpx-mul4-amd64-sse2.S: Improve the end-of-loop condition testing.

Previously, I waited until `rdi' was set up for the next iteration
before comparing it against the limit.  But in fact, `DV' already has
the right value, so we can compare earlier.

3 years agomath/mpx-mul4-amd64-sse2.S: Save a spill by better register allocation.
Mark Wooding [Thu, 7 Nov 2019 01:51:37 +0000 (01:51 +0000)]
math/mpx-mul4-amd64-sse2.S: Save a spill by better register allocation.

The Windows code doesn't need to spill r12, because we don't need the
`mi' register after we've loaded and expanded the Montgomery factor.
This doesn't save any stack space because we need 16-byte alignment, but
it does avoid saving and restoring the register.

3 years agomath/mpx-mul4-*-sse2.S (mpxmont_redc4): Fix end-of-outer-loop commentary.
Mark Wooding [Thu, 7 Nov 2019 01:46:50 +0000 (01:46 +0000)]
math/mpx-mul4-*-sse2.S (mpxmont_redc4): Fix end-of-outer-loop commentary.

  * The carry loop is wrong if the destination is an exact multiple of
    four limbs.  Fortunately, it isn't.

  * The initial pass feeds into the main loop unconditionally, unlike
    `mpxmont_mul4_...' (from which I think the commentary was
    uncritically copied), so being at the end of it doesn't tell you
    anything about whether to start another.  And, indeed, we do indeed
    check the loop-end condition.

3 years agomath/mpx-mul4-*-sse2.S: Remove an unhelpful comment.
Mark Wooding [Thu, 7 Nov 2019 01:43:46 +0000 (01:43 +0000)]
math/mpx-mul4-*-sse2.S: Remove an unhelpful comment.

It's not actually wrong, but it's misleading because we don't actually
care that the flags are preserved at this point, because the next
instruction clobbers them anyway.  I think this was cut-and-paste
lossage from the earlier code which relies on `mov' preserving the carry
flag.

3 years agomath/mpx-mul4-*.S: Fix up some of the commentary.
Mark Wooding [Mon, 4 Nov 2019 12:01:42 +0000 (12:01 +0000)]
math/mpx-mul4-*.S: Fix up some of the commentary.

  * Fix bogus formatting.

  * Fill in the `...' in the AMD64 version.

  * Explain the common notation and register allocation conventions.

3 years agobase/asm-common.h: Decorate pseudoregister `nil' as `nil'.
Mark Wooding [Mon, 4 Nov 2019 12:20:16 +0000 (12:20 +0000)]
base/asm-common.h: Decorate pseudoregister `nil' as `nil'.

This allows `nil' to be passed through macros which want to apply
decoration transforms to their register arguments through to other
macros which treat `nil' as a special marker that a register is absent
or otherwise not to be used.

3 years agomath/t/mpx-mul4: Fix comment markers.
Mark Wooding [Mon, 4 Nov 2019 12:19:33 +0000 (12:19 +0000)]
math/t/mpx-mul4: Fix comment markers.

3 years agomath/: Delete some unnecessary blank lines.
Mark Wooding [Thu, 7 Nov 2019 01:41:26 +0000 (01:41 +0000)]
math/: Delete some unnecessary blank lines.

3 years agoInitialize the register dumping machinery while testing assembler code.
Mark Wooding [Mon, 4 Nov 2019 12:04:16 +0000 (12:04 +0000)]
Initialize the register dumping machinery while testing assembler code.

3 years agosymm/blkc.h: Add a hook for cipher-specific initialization.
Mark Wooding [Mon, 4 Nov 2019 12:18:01 +0000 (12:18 +0000)]
symm/blkc.h: Add a hook for cipher-specific initialization.

You'll see what this is for soon.

3 years agomath/mpx-mul4-test.c: Compare and print test outputs by value.
Mark Wooding [Mon, 4 Nov 2019 11:57:53 +0000 (11:57 +0000)]
math/mpx-mul4-test.c: Compare and print test outputs by value.

Different implementations may find it useful to calculate redundant-
representation outputs in different ways.  Compare these by value rather
than by raw representation.

3 years agox86ish *.S: Use `stalloc' consistently to allocate space on the stack.
Mark Wooding [Wed, 30 Oct 2019 23:10:51 +0000 (23:10 +0000)]
x86ish *.S: Use `stalloc' consistently to allocate space on the stack.

Also, prefer aligning afterwards, except where that won't work.

3 years agobase/dispatch-x86ish.S: Capture the `xmm0' address in a register.
Mark Wooding [Tue, 29 Oct 2019 18:58:15 +0000 (18:58 +0000)]
base/dispatch-x86ish.S: Capture the `xmm0' address in a register.

This saves 16 bytes overall, and makes for slightly more readable code.

3 years agobase/asm-common.h (x86), and knock-on: Add macros for full-size regs.
Mark Wooding [Tue, 29 Oct 2019 18:55:16 +0000 (18:55 +0000)]
base/asm-common.h (x86), and knock-on: Add macros for full-size regs.

These registers get used a lot as pointers, so it's useful to be able to
refer to them as full-width registers more conveniently than `R_sp(r)'.
Introduce (C preprocessor) macros `AX', ..., for this purpose, and use
them extensively.

(Delete the existing `SI' and `DI' macros from `rijndael-x86ish-aesni.S'
which had the same purpose.)

3 years agobase/regdump.h: Pass cooked register index to `REGDEF_GPX86_COMMON'.
Mark Wooding [Tue, 29 Oct 2019 18:38:27 +0000 (18:38 +0000)]
base/regdump.h: Pass cooked register index to `REGDEF_GPX86_COMMON'.

I want to define `BP' and `SP' as macros, but they'll expand in the
calls to `REGDEF_GPX86_COMMON', which will break things.  They don't
expand directly in the body of `REGDEF_GPX86_XP' because `##' inhibits
this.  Alas, this means we have to do this token-gluing in the interface
macros rather than the common core.

3 years agosymm/poly1305.c, etc.: Convert the Monte-Carlo tests to incremental form.
Mark Wooding [Tue, 29 Oct 2019 23:41:37 +0000 (23:41 +0000)]
symm/poly1305.c, etc.: Convert the Monte-Carlo tests to incremental form.

Similarly to the way 1e4c26653e52aa4c4b06e345617135a6ff271ab5 modified
the X25519 and X448 tests, arrange that each Monte-Carlo test vector
continues from where the previous one left off.  This is considerably
trickier to pull off because there's so much more state to maintain in
these tests, and changes to the processing code was necessary to make it
work.

Again, as in 1e4c2665..., move the very slow high-iteration-count tests
into a separate file, and arrange for it to be distributed.

Note that the outputs are unchanged by all of this.

3 years agosymm/poly1305.c: Keep the working buffers in `dstr' buffers.
Mark Wooding [Tue, 29 Oct 2019 10:26:11 +0000 (10:26 +0000)]
symm/poly1305.c: Keep the working buffers in `dstr' buffers.

This way, they can be printed easily using the testrig type machinery.

3 years agosymm/poly1305.c: Use explicit sizes in the Monte-Carlo test.
Mark Wooding [Tue, 29 Oct 2019 10:19:49 +0000 (10:19 +0000)]
symm/poly1305.c: Use explicit sizes in the Monte-Carlo test.

The indirect `sizeof' expressions weren't always of the right variable,
and I'm going to replace the vectors with pointers soon.

3 years agoprogs/key.c: Don't print secret parts of keys at verbosity 3.
Mark Wooding [Sat, 26 Oct 2019 14:46:20 +0000 (15:46 +0100)]
progs/key.c: Don't print secret parts of keys at verbosity 3.

Print them at level 4.  Push printing of locked portions to level 5.

3 years agoprogs/key.c: Use `HASH' rather than `HASHALG' to denote a hash-function name.
Mark Wooding [Sat, 26 Oct 2019 14:43:23 +0000 (15:43 +0100)]
progs/key.c: Use `HASH' rather than `HASHALG' to denote a hash-function name.

I noticed that the synopses were inconsistent between `fingerprint' and
`verify'.  Resolve this in favour of the shorter `HASH', despite the
1--3 minority.  (Note that the manual already uses `hash' consistently.)

3 years agokey/key-misc.c (key_bytag): Accept `tag:', `id:' and `type:' prefixes.
Mark Wooding [Sat, 26 Oct 2019 14:40:19 +0000 (15:40 +0100)]
key/key-misc.c (key_bytag): Accept `tag:', `id:' and `type:' prefixes.

Further to the fix 079836cc4d21b355c8b58a4624ef85df0ac6c21a, allow the
user to attach a disambiguating prefix to the label.  Using the colon is
safe here, since it's obviously not acceptable in a hex id, and
`key_chkident' rejects colons in tag and type strings.

3 years agoDeploy the new <ctype.h> and `foocmp' macros from mLib.
Mark Wooding [Tue, 1 Oct 2019 19:01:20 +0000 (20:01 +0100)]
Deploy the new <ctype.h> and `foocmp' macros from mLib.

3 years agosymm/t/poly1305: Spell Dan Bernstein's name correctly.
Mark Wooding [Wed, 23 Oct 2019 22:42:12 +0000 (23:42 +0100)]
symm/t/poly1305: Spell Dan Bernstein's name correctly.

Sorry, Dan.

3 years agopub/dh-kcdsa.c: Retry or fail if we don't get the target sizes.
Mark Wooding [Wed, 23 Oct 2019 03:12:44 +0000 (04:12 +0100)]
pub/dh-kcdsa.c: Retry or fail if we don't get the target sizes.

Following the usual convention, we retry unless the caller gave us a
bounded number of steps, and otherwise fail.

I think failure is fairly unlikely now.  To find an N-bit prime, we
expect to take about 4 N steps (see analysis in `math/strongprime.c').
But we're trying to find two primes simultaneously, one of N bits, and
one of M bits, so this will take about 16 M N steps in total.  We start
with v < 2^{N-M-1}, and choose 2^{M-1} <= q_0 < 2^M such that 2^{N-1} <
p_0 = 2 q_0 v + 1 < 2^N (nearly true).  We'll fail if 2^M - q_0 < 16 M N,
which seems unlikely, or if 2^N - p_0 < 32 M N v, i.e., 2^M - p_0/(2 v) <
16 M N, which is basically the same condition.

3 years agopub/dh-kcdsa.c: Choose the starting point for the right result size.
Mark Wooding [Wed, 23 Oct 2019 03:11:55 +0000 (04:11 +0100)]
pub/dh-kcdsa.c: Choose the starting point for the right result size.

And try again until it's actually likely to work.

3 years agopub/dh-kcdsa.c: Choose the cofactor size correctly.
Mark Wooding [Wed, 23 Oct 2019 03:11:05 +0000 (04:11 +0100)]
pub/dh-kcdsa.c: Choose the cofactor size correctly.

Considering that we're going to have to multiply in a factor of 2 at
some point.

3 years agopub/dh-kcdsa.c: Make the cleanup flow less crazy.
Mark Wooding [Wed, 23 Oct 2019 03:09:05 +0000 (04:09 +0100)]
pub/dh-kcdsa.c: Make the cleanup flow less crazy.

I'm pretty sure I've fixed bugs in here.

3 years agopub/dh-kcdsa.c: Fix commentary blunder.
Mark Wooding [Wed, 23 Oct 2019 03:05:21 +0000 (04:05 +0100)]
pub/dh-kcdsa.c: Fix commentary blunder.

3 years agoutils/advmodes, utils/gcm-ref: Make conversions from `int' to `GF' explicit.
Mark Wooding [Fri, 18 Oct 2019 21:59:02 +0000 (22:59 +0100)]
utils/advmodes, utils/gcm-ref: Make conversions from `int' to `GF' explicit.

This anticipates a Catacomb/Python change which breaks implicit
conversions to `GF'.

3 years agosymm/hmac-def.h: Base key sizes on the hash size, not state size.
Mark Wooding [Sat, 12 Oct 2019 20:49:48 +0000 (21:49 +0100)]
symm/hmac-def.h: Base key sizes on the hash size, not state size.

Back in c850c0da81ad9f72315f8e6e26bdfbd98daf9d89 (`Support HMAC mode for
hash functions which need to store more state than the hash output
size'), there was only a single key-size specification shared between
HMAC and NMAC.  This nearly makes sense, because an NMAC key is a /pair/
of hash states, for the outer and inner hash applications, but the key
size at this time was only the size of /single/ state.  At this time,
only HMAC had a `gcmac' definition, so the key size had to be right for
HMAC, which may explain this, but it seems rather unconvincing.

Later, 2a62e96dc602cf6ec0e5a489b18262ae6abb29be (`Provide correct key
sizes for NMAC, HMAC and SSLMAC') splits this single key-size
specification into three, and adds a `gcmac' definition for the NMAC
variant.  The new key-size specification for NMAC correctly reports
double the state size, and uses `KSZ_SET' rather than `KSZ_ANY'.  I
think the other two should have been based on the hash size at this
point, but weren't: I suspect that I just propagated the previous
mistake without thinking about it very hard.

Even later, c148759dc94794db3faa3ed556583b65d40ae799 (`symm/hmac-def.h:
Report key sizes as 16-bit quantities') changes the key-size
specifications to use the new 16-bit format, but shies away from fixing
the HMAC and SSLMAC key sizes.

I'm now going to bite this bullet and declare that the HMAC and SSLMAC
key sizes should be based on the hash size.  This changes the default
key sizes for: MD2, SHA224, SHA384, SHA512/224, SHA512/256, SHA3 (all
variants), and Whirlpool256.  I think it's probably a mistake to have
used any of these hash functions with HMAC: MD2 is slow and weak; the
SHA2 variants are all worse than truncating SHA256 or SHA512; similarly,
using Whirlpool256 rather than truncating plain Whirlpool is
bizarre (and Whirlpool is slow and rarely used anyway); and SHA3 is just
a terrible fit for HMAC, and you should be using KMAC instead.

This will break interoperability in `catcrypt' if HMAC based on any of
the above hash functions is used as the `mac'.  TrIPE (sensibly) doesn't
use the default key size, so isn't affected by this change.

3 years agomath/mpgen, symm/multigen: Fix the various build scripts for Python 3.
Mark Wooding [Fri, 4 Oct 2019 14:43:27 +0000 (15:43 +0100)]
math/mpgen, symm/multigen: Fix the various build scripts for Python 3.

  * Put parentheses around `print' arguments.

  * Write `raise EXC(VALUE)' rather than `raise EXC, VALUE' to raise
    exceptions.

  * Cope with `xrange' being renamed to `range' in Python 3.

  * Cope with `long' not being a type name in Python 3.

  * Cope with `execfile' not being available in Python 3.

  * Cope with function-object attribute names being renamed in Python 3.

  * Cope with `StringIO' being in `io' rather than `cStringIO' in Python
    3, and with `StringIO.reset' not being available any more.

  * Cope with `itertools.izip' not being available in Python 3.

  * Cope with `OBJ.next' not being available in Python 3.

  * Use an unpleasant hack to inject metaclasses, because the official
    syntax is so different between the two versions.

3 years agosymm/multigen (SequenceTemplate): Don't try to pass `seq' initarg.
Mark Wooding [Tue, 8 Oct 2019 11:09:48 +0000 (12:09 +0100)]
symm/multigen (SequenceTemplate): Don't try to pass `seq' initarg.

I have no idea how this ever worked.  Certainly Python 3 complains, but
Python 2 should have done too.

3 years agokey/key-io.c: Add low-level `key_mergeline' and `key_extractline' functions.
Mark Wooding [Thu, 3 Oct 2019 13:33:36 +0000 (14:33 +0100)]
key/key-io.c: Add low-level `key_mergeline' and `key_extractline' functions.

Python 3 doesn't use C `stdio' streams.  In order to integrate properly,
we need to provide some other way to do I/O of key material.  Introduce
new functions which work in terms of lines in the keyring, which a
Python wrapper can transfer between us and a Python file.

3 years agosymm/strobe.c: Implement Hamburg's STROBE framework.
Mark Wooding [Sun, 25 Nov 2018 11:40:32 +0000 (11:40 +0000)]
symm/strobe.c: Implement Hamburg's STROBE framework.

3 years agosymm/keccak1600.c: Add new function to overwrite the state.
Mark Wooding [Sat, 17 Nov 2018 22:32:32 +0000 (22:32 +0000)]
symm/keccak1600.c: Add new function to overwrite the state.

This is somewhat more useful for implementing duplex-style
constructions.

3 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'.

3 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.

3 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.

3 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.

3 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.

3 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'.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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).

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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 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 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.