chiark / gitweb /
catacomb-python
6 years agocatacomb/__init__.py: Settle on SHAKE256 for X448 box-key generation.
Mark Wooding [Thu, 11 May 2017 09:42:15 +0000 (10:42 +0100)]
catacomb/__init__.py: Settle on SHAKE256 for X448 box-key generation.

This matches Ed448 hashing, which is probably a good thing.

6 years agopubkey.c: Support the `ed2559ctx' signature scheme from RFC8032.
Mark Wooding [Thu, 11 May 2017 09:42:15 +0000 (10:42 +0100)]
pubkey.c: Support the `ed2559ctx' signature scheme from RFC8032.

Main difference is the addition of a personalization string.

In the wrapper classes, forward unknown keyword arguments on to the
underlying implementation.

6 years agopubkey.c: Capture Ed25519 binding in a macro.
Mark Wooding [Thu, 11 May 2017 09:42:15 +0000 (10:42 +0100)]
pubkey.c: Capture Ed25519 binding in a macro.

Now we can add more EdDSA instances with similar shapes without too much
trouble.

Also, slightly sneakily, make EdDSA verification functions take keyword
arguments.

6 years agocatacomb/__init__.py: Add `beginhash', `endhash' to the EdDSA interface.
Mark Wooding [Thu, 11 May 2017 09:42:15 +0000 (10:42 +0100)]
catacomb/__init__.py: Add `beginhash', `endhash' to the EdDSA interface.

This is consistent with the other DSA-ish classes.

6 years agocatacomb/__init__.py: Refactor the XDH and EdDSA classes.
Mark Wooding [Thu, 11 May 2017 09:42:15 +0000 (10:42 +0100)]
catacomb/__init__.py: Refactor the XDH and EdDSA classes.

  * Introduce `_BasePub' and `_BasePriv' underneath the existing
    classes, and move obvious common functionality like size checking
    and printing into them.  Push key-generation down here too.

  * Use `KeySZ' objects for key length checking rather than just the
    bare constants.  In particular, this means that `Ed25519Priv' isn't
    fussy about key sizes, preserving this feature of the underlying
    implementation.

  * Split the implementation of pretty-printing into more pieces.  In
    particular, now `_BasePriv' only needs to implement the printing of
    the private key rather than the whole lot.  (Plain `__repr__' is
    still duplicated, but the code is smaller and this is more
    tolerable.)

  * Rename `_Boxy...' to `_XDH...', since this appears to be the generic
    term I'm using for such things now.

6 years agopubkey.c: Factor out commonality between X25519 and X448.
Mark Wooding [Thu, 11 May 2017 09:42:15 +0000 (10:42 +0100)]
pubkey.c: Factor out commonality between X25519 and X448.

6 years agoAdd support for SHA3 and related algorithms.
Mark Wooding [Thu, 11 May 2017 09:42:15 +0000 (10:42 +0100)]
Add support for SHA3 and related algorithms.

This comes in three tranches.

  * There are the basic generic-interface algorithms for SHA3-*, SHAKE*,
    KMAC*, etc., which basically just turn up by themselves, and the
    RNGs based on SHAKE and KMAC which took a little more work.

  * There's a full implementation of the cSHAKE128 and cSHAKE256 XOFs as
    a new kind of object.

  * Based on this, there's a full KMAC implementation, with the fiddly
    bits in Python (but all the heavy lifting is done in C), with
    variable-length tag and everything.  Other constructions, e.g.,
    TupleHash, can easily be made in the same way.

Annoyingly, KMAC can't just be made from SHAKE by multiple inheritance
because Python gets confused about how it's supposed to construct the
objects, and, in particular, which `__new__' methods are OK to use.  It
seems that the relevant code is trying to use the `HEAPTYPE' flag as a
proxy for whether a type is implemented in C, which doesn't work for our
classes.  So there's a bunch of ugly delegation to do.

6 years agoalgorithms.c: Add basic support for Keccak[1600, n].
Mark Wooding [Thu, 11 May 2017 09:42:15 +0000 (10:42 +0100)]
algorithms.c: Add basic support for Keccak[1600, n].

This takes the form of a simple object which encapsulates the
Keccak[1600, n] state and allows mix and extract operations (which
correspond to the I/O portions of absorb/squeeze and duplexing) and
step, which actually invokes the permutation to advance the state.

None of this keeps track of rate or capacity limits beyond the obvious
memory-safety checks, so you can really screw yourself if you're not
careful.

6 years agoalgorithms.py: Support SHA512/224 and SHA512/256.
Mark Wooding [Thu, 11 May 2017 09:42:15 +0000 (10:42 +0100)]
algorithms.py: Support SHA512/224 and SHA512/256.

6 years agoalgorithms.py: Cope better with algs with funny characters in their names.
Mark Wooding [Thu, 11 May 2017 09:42:15 +0000 (10:42 +0100)]
algorithms.py: Cope better with algs with funny characters in their names.

Defend against `/' in names when making include-file names, and defend
against `/' and `-' when forming identifier names.

6 years agorand.c, algorithms.py: Change how kinds of RNGs are distinguished.
Mark Wooding [Thu, 11 May 2017 09:42:15 +0000 (10:42 +0100)]
rand.c, algorithms.py: Change how kinds of RNGs are distinguished.

Rather than a set of flags, assign them numbers and use `switch'.  It
doesn't seem like the flags are helpfully marking out sets of RNGs, and
this approach scales better to handling more kinds.

6 years agobytestring.c, catacomb/__init__.py: Introduce and use `zero' method.
Mark Wooding [Thu, 11 May 2017 09:42:15 +0000 (10:42 +0100)]
bytestring.c, catacomb/__init__.py: Introduce and use `zero' method.

Seems like strings of zero bytes are especially useful.  Add a class
method to `ByteString' to generate them efficiently, and use it to make
the magic `Z128' constant.

6 years agocatacomb/__init__.py: Calculate `X25519_BASE' and `X448_BASE'.
Mark Wooding [Thu, 11 May 2017 09:42:15 +0000 (10:42 +0100)]
catacomb/__init__.py: Calculate `X25519_BASE' and `X448_BASE'.

Easier on the eyes and brain.

6 years agoutils.c: Raise exceptions from `convTHING' with null arguments.
Mark Wooding [Thu, 11 May 2017 09:42:15 +0000 (10:42 +0100)]
utils.c: Raise exceptions from `convTHING' with null arguments.

This can happen as a result of using `convTHING' in an attribute `set'
function, and the Python program trying to `del' the attribute.
Unfortunately, these conversion functions are already being used in this
context, and it leads to segfaults, e.g., from

  del C.Key(C.KeyFile('', C.KOPEN_WRITE | C.KOPEN_NOFILE), 0, 'k').exptime

Easy fix.

6 years agobytestring.c: Use `arg' rather than `args' for argument tuples.
Mark Wooding [Thu, 11 May 2017 09:42:15 +0000 (10:42 +0100)]
bytestring.c: Use `arg' rather than `args' for argument tuples.

6 years agocatacomb/__init__.py: Rename stupidly named arguments.
Mark Wooding [Thu, 11 May 2017 09:42:15 +0000 (10:42 +0100)]
catacomb/__init__.py: Rename stupidly named arguments.

I don't know where I got `*kw' from.  Sorry.

6 years agocatacomb/__init__.py: Fix bungled `unbox' method of `_BoxyPriv'.
Mark Wooding [Thu, 11 May 2017 09:42:15 +0000 (10:42 +0100)]
catacomb/__init__.py: Fix bungled `unbox' method of `_BoxyPriv'.

6 years agoMerge branch '1.1.x'
Mark Wooding [Sun, 14 May 2017 03:28:02 +0000 (04:28 +0100)]
Merge branch '1.1.x'

* 1.1.x:
  Release 1.1.2.
  catacomb/__init__.py: Fix up cipher etc. names better.
  algorithms.c: Support the new 16-bit key-size descriptors.
  group.c: Track Catacomb group internals change.
  utils.c: Raise exceptions from `convTHING' with null arguments.
  Return `long' objects when `int' is requested but the value won't fit.
  bytestring.c: Check for cached hash more carefully.
  rand.c: Careful range checking on `block' and `mp'.
  *.c: Fix docstrings for methods.
  Further fixing to use `Py_ssize_t' in place of int.

Conflicts:
debian/control (already wanted later catacomb-dev)
group.c (no need for compatibility with older Catacombs)

6 years agoRelease 1.1.2. 1.1.2
Mark Wooding [Sun, 14 May 2017 03:25:50 +0000 (04:25 +0100)]
Release 1.1.2.

6 years agocatacomb/__init__.py: Fix up cipher etc. names better.
Mark Wooding [Thu, 11 May 2017 09:42:15 +0000 (10:42 +0100)]
catacomb/__init__.py: Fix up cipher etc. names better.

Now `sha512/256', for example, will have the right name.

6 years agoalgorithms.c: Support the new 16-bit key-size descriptors.
Mark Wooding [Thu, 11 May 2017 09:42:15 +0000 (10:42 +0100)]
algorithms.c: Support the new 16-bit key-size descriptors.

6 years agogroup.c: Track Catacomb group internals change.
Mark Wooding [Thu, 20 Apr 2017 00:58:05 +0000 (01:58 +0100)]
group.c: Track Catacomb group internals change.

6 years agoutils.c: Raise exceptions from `convTHING' with null arguments.
Mark Wooding [Thu, 11 May 2017 09:42:15 +0000 (10:42 +0100)]
utils.c: Raise exceptions from `convTHING' with null arguments.

This can happen as a result of using `convTHING' in an attribute `set'
function, and the Python program trying to `del' the attribute.
Unfortunately, these conversion functions are already being used in this
context, and it leads to segfaults, e.g., from

  del C.Key(C.KeyFile('', C.KOPEN_WRITE | C.KOPEN_NOFILE), 0, 'k').exptime

Easy fix.

6 years agoReturn `long' objects when `int' is requested but the value won't fit.
Mark Wooding [Wed, 3 May 2017 11:48:27 +0000 (12:48 +0100)]
Return `long' objects when `int' is requested but the value won't fit.

Mostly, Python handles the error from the `int' conversion and falls
back to long, but there's something weird in iteration, where if you say

for i in ...:
  print '%d' % x

then the loop finishes and /then/ you get an exception for the overflow
from the failed conversion of x to an `int'.

Follow Python's actual behaviour: have `mp_tolong_checked' take an extra
argument indicating whether to throw an exception, and modify most of
the call sites to fall back to a conversion based on `mp_topylong'.

6 years agobytestring.c: Check for cached hash more carefully.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
bytestring.c: Check for cached hash more carefully.

The `CACHE_HASH' symbol has been missing for years because the feature
is always on nowadays.  Amazingly, I never noticed.

6 years agorand.c: Careful range checking on `block' and `mp'.
Mark Wooding [Mon, 12 Sep 2016 21:26:09 +0000 (22:26 +0100)]
rand.c: Careful range checking on `block' and `mp'.

  * For `mp', don't allow the `or' mask to be wider than the requested
    result.

  * For `range', insist that the limit is strictly positive, so that the
    output range is actually inhabited.

These parallel currently unreleased fixes to the underlying library,
which are required for things to work properly; so bump the dependency.

6 years ago*.c: Fix docstrings for methods.
Mark Wooding [Mon, 12 Sep 2016 21:23:38 +0000 (22:23 +0100)]
*.c: Fix docstrings for methods.

Mostly fixing method names andarguments broken by bad copy-and-paste
editing.

6 years agoFurther fixing to use `Py_ssize_t' in place of int.
Mark Wooding [Sun, 11 Sep 2016 23:14:16 +0000 (00:14 +0100)]
Further fixing to use `Py_ssize_t' in place of int.

This addresses the remaining compiler warnings when building for 64-bit
targets.

6 years agoalgorithms.c: Check whether `setiv' and `bdry' are implemented before calling.
Mark Wooding [Sun, 7 May 2017 19:01:47 +0000 (20:01 +0100)]
algorithms.c: Check whether `setiv' and `bdry' are implemented before calling.

Oops, easy segfault.

6 years agocatacomb/__init__.py: Add printing for more key types.
Mark Wooding [Mon, 1 May 2017 00:38:30 +0000 (01:38 +0100)]
catacomb/__init__.py: Add printing for more key types.

Now that we have secret suppression, it's not an attractive nuisance to
print key material for public keys like RSA, DSA, KCDSA, and XDH.  So do
that.

Digging key material out of symmetric crypto objects is really hard, so
we don't try to do that.

6 years agocatacomb/__init__.py: Don't print secret bits of keys by default.
Mark Wooding [Mon, 1 May 2017 00:38:30 +0000 (01:38 +0100)]
catacomb/__init__.py: Don't print secret bits of keys by default.

Introduce a `PRINT_SECRETS' flag which can easily be twiddled (e.g., in
IPython) to control whether obvious secrets are printed literally or
censored (the default).  This is intended to make accidental leakage a
bit less likely, rather than as a security feature.

6 years agocatacomb/__init__.py: Add `_clsname' for printing class names.
Mark Wooding [Mon, 1 May 2017 00:38:30 +0000 (01:38 +0100)]
catacomb/__init__.py: Add `_clsname' for printing class names.

Replace both the ugly `type(me).__name__' rune, and literal class names.

6 years agocatacomb/__init__.py: Abstract out common printing for `KeyData' subclasses.
Mark Wooding [Mon, 1 May 2017 00:38:30 +0000 (01:38 +0100)]
catacomb/__init__.py: Abstract out common printing for `KeyData' subclasses.

Introduce `_guts' to return the thing that each subclass encapsulates.
`KeyDataStructured' is a special snowflake which I'm willing to handle
separately.

6 years agopubkey.c: Change the arguments to {DSA,KCDSA}{Pub,Priv}.
Mark Wooding [Mon, 1 May 2017 00:38:30 +0000 (01:38 +0100)]
pubkey.c: Change the arguments to {DSA,KCDSA}{Pub,Priv}.

  * Don't allow a private-key `u' argument to `*Pub'.

  * Have the private key argument `u' precede the public key `p' to
    `*Priv'.

  * Make the public key optional to `*Priv', and compute it correctly if
    not provided.

This is an incompatible change, but I've resolved not to care.  The old
interface was obviously crazy.

6 years agocatacomb/__init__.py: Print group elements properly.
Mark Wooding [Mon, 1 May 2017 00:38:30 +0000 (01:38 +0100)]
catacomb/__init__.py: Print group elements properly.

Slightly grim: add a method to group objects to export their elements as
some useful type, and then call that from the element print function.

6 years agocatacomb/__init__.py: Print groups properly.
Mark Wooding [Mon, 1 May 2017 00:38:30 +0000 (01:38 +0100)]
catacomb/__init__.py: Print groups properly.

6 years agocatacomb/__init__.py: Add printing for points on known curves.
Mark Wooding [Mon, 1 May 2017 00:38:30 +0000 (01:38 +0100)]
catacomb/__init__.py: Add printing for points on known curves.

Now the coordinates print correctly as field elements.

6 years agogroup.c: Make element `toec()' method return point on correct curve.
Mark Wooding [Mon, 1 May 2017 00:38:30 +0000 (01:38 +0100)]
group.c: Make element `toec()' method return point on correct curve.

Rather than a generic point.  Now it will print correctly.

6 years agocatacomb/__init__.py: Abstract out common pretty-printing patterns.
Mark Wooding [Mon, 1 May 2017 00:38:30 +0000 (01:38 +0100)]
catacomb/__init__.py: Abstract out common pretty-printing patterns.

Don't hardwire indentation levels from header lengths; don't hardwire
type names; hide away the ugly `type(me).__name__' rune.

6 years agocatacomb/__init__.py: Support IPython's pretty-printer.
Mark Wooding [Mon, 1 May 2017 00:38:30 +0000 (01:38 +0100)]
catacomb/__init__.py: Support IPython's pretty-printer.

Add `_repr_pretty_' methods to many types to improve presentation.
Also, sneakily add a bunch of printing methods to the key-management
classes.

6 years agocatacomb/__init__.py: Support `len' on `_groupmap' objects.
Mark Wooding [Mon, 1 May 2017 00:38:30 +0000 (01:38 +0100)]
catacomb/__init__.py: Support `len' on `_groupmap' objects.

6 years agocatacomb/__init__.py: Use `%#x' rather than `hex' now.
Mark Wooding [Mon, 1 May 2017 00:38:30 +0000 (01:38 +0100)]
catacomb/__init__.py: Use `%#x' rather than `hex' now.

The reason `%x' used not to work is the recently-fixed bug whereby
conversions to `int' raised exceptions rather than returning `long'.

6 years agoMerge branches 'mdw/latin-ietf' and 'mdw/curve25519'
Mark Wooding [Wed, 3 May 2017 12:02:54 +0000 (13:02 +0100)]
Merge branches 'mdw/latin-ietf' and 'mdw/curve25519'

* mdw/latin-ietf:
  algorithms.py: Support the IETF versions of ChaCha etc. with 96-bit nonce.

* mdw/curve25519:
  pubkey.c, catacomb/__init__.py: Add bindings for Hamburg's X448.
  pubkey.c, ...: Support Bernstein's `Ed25519' signature scheme.
  pubkey.c, ...: Support Bernstein's `X25519' key-agreement algorithm.

6 years agoalgorithms.py: Support the IETF versions of ChaCha etc. with 96-bit nonce.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
algorithms.py: Support the IETF versions of ChaCha etc. with 96-bit nonce.

6 years agopubkey.c, catacomb/__init__.py: Add bindings for Hamburg's X448.
Mark Wooding [Wed, 26 Apr 2017 10:53:05 +0000 (11:53 +0100)]
pubkey.c, catacomb/__init__.py: Add bindings for Hamburg's X448.

6 years agopubkey.c, ...: Support Bernstein's `Ed25519' signature scheme.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
pubkey.c, ...: Support Bernstein's `Ed25519' signature scheme.

6 years agopubkey.c, ...: Support Bernstein's `X25519' key-agreement algorithm.
Mark Wooding [Wed, 12 Apr 2017 17:39:01 +0000 (18:39 +0100)]
pubkey.c, ...: Support Bernstein's `X25519' key-agreement algorithm.

6 years agoReturn `long' objects when `int' is requested but the value won't fit.
Mark Wooding [Wed, 3 May 2017 11:48:27 +0000 (12:48 +0100)]
Return `long' objects when `int' is requested but the value won't fit.

Mostly, Python handles the error from the `int' conversion and falls
back to long, but there's something weird in iteration, where if you say

for i in ...:
  print '%d' % x

then the loop finishes and /then/ you get an exception for the overflow
from the failed conversion of x to an `int'.

Follow Python's actual behaviour: have `mp_tolong_checked' take an extra
argument indicating whether to throw an exception, and modify most of
the call sites to fall back to a conversion based on `mp_topylong'.

7 years agogroup.c: Track Catacomb group internals change.
Mark Wooding [Thu, 20 Apr 2017 00:58:05 +0000 (01:58 +0100)]
group.c: Track Catacomb group internals change.

7 years agocatacomb/__init__.py: Add a simple implementation of NaCl `secretbox'.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
catacomb/__init__.py: Add a simple implementation of NaCl `secretbox'.

7 years agoalgorithms.c: Add binding for `poly1305_flushzero'.
Mark Wooding [Sat, 15 Apr 2017 13:34:33 +0000 (14:34 +0100)]
algorithms.c: Add binding for `poly1305_flushzero'.

7 years agoalgorithms.c: Fix Poly1305 `hashu...' and `hashbuf...' methods.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
algorithms.c: Fix Poly1305 `hashu...' and `hashbuf...' methods.

Hash the input number or length, not the size of the field.

7 years agobytestring.c, catacomb/__init__.py: Compare for equality in constant time.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
bytestring.c, catacomb/__init__.py: Compare for equality in constant time.

There's an explicit `ctstreq' function which just does what you wanted.
Also, `ByteString' objects now have a rich-compare method which always
compares for equality in constant time.  Ordering comparisons are
variable time still.

There's a little chicanery to retain the hash function from `str'.

Also add a simple `check' method to `GHash' and `Poly1305Hash' which
compares a hsah or MAC tag in constant time and returns a boolean
result.

7 years agobytestring.c: Check for cached hash more carefully.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
bytestring.c: Check for cached hash more carefully.

The `CACHE_HASH' symbol has been missing for years because the feature
is always on nowadays.  Amazingly, I never noticed.

7 years ago*.c: Declare `PY_SSIZE_T_CLEAN'.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
*.c: Declare `PY_SSIZE_T_CLEAN'.

Now we can process large strings on 64-bit targets.  Err, win?

7 years agoalgorithms.c: Add bindings for HSalsa20/r and HChaCha/r.
Mark Wooding [Fri, 7 Apr 2017 18:20:53 +0000 (19:20 +0100)]
algorithms.c: Add bindings for HSalsa20/r and HChaCha/r.

7 years agoalgorithms.c: Add support for Poly1305.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
algorithms.c: Add support for Poly1305.

7 years agocatacomb-python.h, util.c: Support for declaring types with weird metatypes.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
catacomb-python.h, util.c: Support for declaring types with weird metatypes.

7 years agoalgorithms.c: Reorder the `ghash' definitions.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
algorithms.c: Reorder the `ghash' definitions.

7 years agoalgorithms.c: Fix docstring for `GCHash.hashsz'.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
algorithms.c: Fix docstring for `GCHash.hashsz'.

7 years agoalgorithms.c: Set required size on GMAC objects.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
algorithms.c: Set required size on GMAC objects.

The Python interpreter catches this in debug mode.  Also, it's really
bad.

7 years agorand.c, algorithms.py: Support random access protocol of Latin-dance PRFs.
Mark Wooding [Mon, 12 Sep 2016 21:29:09 +0000 (22:29 +0100)]
rand.c, algorithms.py: Support random access protocol of Latin-dance PRFs.

Add a new superclass for random bit generators based on Latin-dance
PRFs (Salsa20, ChaCha, etc.) which exposes the `seek'/`tell' random
access protocol to Python.

7 years agoutil.c: Add conversions between Python objects and `kludge64'.
Mark Wooding [Mon, 12 Sep 2016 21:27:23 +0000 (22:27 +0100)]
util.c: Add conversions between Python objects and `kludge64'.

7 years agocatacomb-python.h: Don't inhibit 64-bit type detection any more.
Mark Wooding [Mon, 12 Sep 2016 21:26:53 +0000 (22:26 +0100)]
catacomb-python.h: Don't inhibit 64-bit type detection any more.

We'll be using `kludge64', and the definition must properly match up
with the library.

7 years agorand.c: Careful range checking on `block' and `mp'.
Mark Wooding [Mon, 12 Sep 2016 21:26:09 +0000 (22:26 +0100)]
rand.c: Careful range checking on `block' and `mp'.

  * For `mp', don't allow the `or' mask to be wider than the requested
    result.

  * For `range', insist that the limit is strictly positive, so that the
    output range is actually inhabited.

These parallel currently unreleased fixes to the underlying library,
which are required for things to work properly; so bump the dependency.

7 years agoutil.c: Zap spurious whitespace.
Mark Wooding [Mon, 12 Sep 2016 21:23:58 +0000 (22:23 +0100)]
util.c: Zap spurious whitespace.

7 years ago*.c: Fix docstrings for methods.
Mark Wooding [Mon, 12 Sep 2016 21:23:38 +0000 (22:23 +0100)]
*.c: Fix docstrings for methods.

Mostly fixing method names andarguments broken by bad copy-and-paste
editing.

7 years agoFurther fixing to use `Py_ssize_t' in place of int.
Mark Wooding [Sun, 11 Sep 2016 23:14:16 +0000 (00:14 +0100)]
Further fixing to use `Py_ssize_t' in place of int.

This addresses the remaining compiler warnings when building for 64-bit
targets.

7 years agoRelease 1.1.1. 1.1.1
Mark Wooding [Sat, 4 Jun 2016 00:17:35 +0000 (01:17 +0100)]
Release 1.1.1.

7 years agobytestring.c: Use `Py_ssize_t' for collecting buffer lengths.
Mark Wooding [Fri, 3 Jun 2016 20:27:36 +0000 (21:27 +0100)]
bytestring.c: Use `Py_ssize_t' for collecting buffer lengths.

On 64-bit platforms, this is a 64-bit long, so if we pass an int to
`PyObject_AsReadBuffer', it will clobber the next word too.

8 years agoRelease 1.1.0.1. 1.1.0.1
Mark Wooding [Fri, 19 Feb 2016 19:39:40 +0000 (19:39 +0000)]
Release 1.1.0.1.

8 years agodebian/control: Fix the Build-Depends.
Mark Wooding [Fri, 19 Feb 2016 09:00:49 +0000 (09:00 +0000)]
debian/control: Fix the Build-Depends.

8 years agodebian/source/format: Apparently we need one of these nowadays.
Mark Wooding [Fri, 19 Feb 2016 08:58:06 +0000 (08:58 +0000)]
debian/source/format: Apparently we need one of these nowadays.

8 years agoRelease 1.1.0. 1.1.0
Mark Wooding [Mon, 20 Jul 2015 15:11:21 +0000 (16:11 +0100)]
Release 1.1.0.

8 years agoRequire a shiny new library version.
Mark Wooding [Mon, 20 Jul 2015 13:44:43 +0000 (14:44 +0100)]
Require a shiny new library version.

8 years agoMerge branches 'mdw/pwsafe' and 'mdw/ec-ptcmpr'
Mark Wooding [Mon, 20 Jul 2015 13:40:18 +0000 (14:40 +0100)]
Merge branches 'mdw/pwsafe' and 'mdw/ec-ptcmpr'

* mdw/pwsafe:
  pwsafe: New command `xfer' to transfer data to a new database backend.
  catacomb/pwsafe.py: Add a backend based on SQLite.
  catacomb/pwsafe.py, pwsafe: Make GDBM support conditional.
  catacomb/pwsafe.py: New Git-friendly `DirectoryStorageBackend'.
  catacomb/pwsafe.py: New FlatFileStorageBackend class.
  catacomb/pwsafe.py: Add a new ABRUPTP argument to `close' methods.
  catacomb/pwsafe.py, pwsafe: Dispatching for multiple backends.
  catacomb/pwsafe.py: Split out the GDBM-specifics from StorageBackend.
  catacomb/pwsafe.py: Factor database handling out into a StorageBackend.
  catacomb/pwsafe.py: Commentary fix.
  pwsafe: Abolish the `chomp' function, and only chomp when reading stdin.
  catacomb/pwsafe.py: Make `PW' be a context manager, and use it.
  pwsafe: Get the master passphrase before the new password.
  pwsafe: Report password mismatch as an error, not an exception.
  pwsafe: Some simple reformatting.
  catacomb/pwsafe.py, pwsafe: Replace `PW''s MODE parameter with WRITEP flag.
  catacomb/pwsafe.py: Abolish the `PWIter' class.
  pwsafe: Eliminate the `dump' subcommand.
  pwsafe: Present the list of commands in alphabetical order.
  pwsafe: Don't produce a backtrace on decryption failure.

* mdw/ec-ptcmpr:
  catacomb.c, ec.c: Bindings for the new EC2OSP/OS2ECP functions.

8 years agopwsafe: New command `xfer' to transfer data to a new database backend.
Mark Wooding [Thu, 28 May 2015 09:58:06 +0000 (10:58 +0100)]
pwsafe: New command `xfer' to transfer data to a new database backend.

This works at the StorageBackend level, and doesn't require any secrets
to do its thing.

8 years agocatacomb/pwsafe.py: Add a backend based on SQLite.
Mark Wooding [Sun, 24 May 2015 18:33:21 +0000 (19:33 +0100)]
catacomb/pwsafe.py: Add a backend based on SQLite.

8 years agocatacomb/pwsafe.py, pwsafe: Make GDBM support conditional.
Mark Wooding [Sun, 24 May 2015 18:32:37 +0000 (19:32 +0100)]
catacomb/pwsafe.py, pwsafe: Make GDBM support conditional.

Only offer the GDBM backend if the module is actually available.  Also,
make the new `flat file' backend be the default, since it's the only one
which is guaranteed to exist.

8 years agocatacomb/pwsafe.py: New Git-friendly `DirectoryStorageBackend'.
Mark Wooding [Thu, 28 May 2015 10:09:26 +0000 (11:09 +0100)]
catacomb/pwsafe.py: New Git-friendly `DirectoryStorageBackend'.

8 years agocatacomb/pwsafe.py: New FlatFileStorageBackend class.
Mark Wooding [Sun, 24 May 2015 18:33:50 +0000 (19:33 +0100)]
catacomb/pwsafe.py: New FlatFileStorageBackend class.

No external dependencies required.

8 years agocatacomb/pwsafe.py: Add a new ABRUPTP argument to `close' methods.
Mark Wooding [Sun, 24 May 2015 18:26:36 +0000 (19:26 +0100)]
catacomb/pwsafe.py: Add a new ABRUPTP argument to `close' methods.

New backends might want to commit changes at close time, and an abrupt
close shouldn't do that.

8 years agocatacomb/pwsafe.py, pwsafe: Dispatching for multiple backends.
Mark Wooding [Sun, 24 May 2015 18:22:29 +0000 (19:22 +0100)]
catacomb/pwsafe.py, pwsafe: Dispatching for multiple backends.

This commit introduces a number of tightly related changes.

  * Have concrete backends declare a `NAME' attribute.  This lets users
    name them, and lets us determine which classes are concrete.

  * Introduce a metaclass which registers concrete StorageClass
    subclasses.

  * Extend the `_open' protocol, so that it can raise the new
    StorageBackendRefusal exception to indicate that some other backend
    should try to open the given file.

  * Introduce a `StorageBackend.open' method which examines all
    registered backends and gives each of them an opportunity to open
    the file in some priority order.

  * Add a new method for looking up backends by name.

  * introduce a new DBCLS parameter to `PW.create', which is the backend
    class to use when creating a new database.

  * Introduce a new option to the `create' command to choose the
    database backend by name.

There's only one backend at the moment, though that will change soon.

8 years agocatacomb/pwsafe.py: Split out the GDBM-specifics from StorageBackend.
Mark Wooding [Sun, 24 May 2015 17:59:55 +0000 (18:59 +0100)]
catacomb/pwsafe.py: Split out the GDBM-specifics from StorageBackend.

For now, use the GDBM-based backend explicitly and unconditionally,
because there isn't another one anyway.

8 years agocatacomb/pwsafe.py: Factor database handling out into a StorageBackend.
Mark Wooding [Sun, 24 May 2015 17:49:44 +0000 (18:49 +0100)]
catacomb/pwsafe.py: Factor database handling out into a StorageBackend.

This doesn't (currently) affect the external interface.

8 years agocatacomb/pwsafe.py: Commentary fix.
Mark Wooding [Sun, 24 May 2015 17:06:54 +0000 (18:06 +0100)]
catacomb/pwsafe.py: Commentary fix.

8 years agopwsafe: Abolish the `chomp' function, and only chomp when reading stdin.
Mark Wooding [Sun, 24 May 2015 17:02:31 +0000 (18:02 +0100)]
pwsafe: Abolish the `chomp' function, and only chomp when reading stdin.

We have `S.rstrip()' instead.

8 years agocatacomb.c, ec.c: Bindings for the new EC2OSP/OS2ECP functions.
Mark Wooding [Mon, 22 Dec 2014 20:32:58 +0000 (20:32 +0000)]
catacomb.c, ec.c: Bindings for the new EC2OSP/OS2ECP functions.

8 years agoUse ValueError instead of SyntaxError throughout.
Mark Wooding [Fri, 29 May 2015 08:34:09 +0000 (09:34 +0100)]
Use ValueError instead of SyntaxError throughout.

SyntaxError has a much more specific meaning, and some software, such as
`ipython', expect it to carry lots of other detailed information.

So abolish the `SYNERR' macro, and use `VALERR' instead consistently.  I
wish I had an excuse for this blunder, but I don't.

8 years agocatacomb/pwsafe.py: Make `PW' be a context manager, and use it.
Mark Wooding [Sun, 24 May 2015 15:45:32 +0000 (16:45 +0100)]
catacomb/pwsafe.py: Make `PW' be a context manager, and use it.

8 years agopwsafe: Get the master passphrase before the new password.
Mark Wooding [Sun, 24 May 2015 15:49:40 +0000 (16:49 +0100)]
pwsafe: Get the master passphrase before the new password.

This saves lots of repeating the new password if the user is prone to
typing the master password wrongly.  Like I am.

8 years agopwsafe: Report password mismatch as an error, not an exception.
Mark Wooding [Sun, 24 May 2015 15:46:39 +0000 (16:46 +0100)]
pwsafe: Report password mismatch as an error, not an exception.

8 years agopwsafe: Some simple reformatting.
Mark Wooding [Sun, 24 May 2015 15:45:32 +0000 (16:45 +0100)]
pwsafe: Some simple reformatting.

8 years agocatacomb/pwsafe.py, pwsafe: Replace `PW''s MODE parameter with WRITEP flag.
Mark Wooding [Sun, 24 May 2015 15:38:11 +0000 (16:38 +0100)]
catacomb/pwsafe.py, pwsafe: Replace `PW''s MODE parameter with WRITEP flag.

This abstracts away from the GDBM interface slightly, and makes it a bit
more convenient for other implementations.

8 years agocatacomb/pwsafe.py: Abolish the `PWIter' class.
Mark Wooding [Sun, 24 May 2015 17:06:03 +0000 (18:06 +0100)]
catacomb/pwsafe.py: Abolish the `PWIter' class.

There's no identifiable advantage to writing all of that out longhand
over a simple generator.  So do that instead.

8 years agopwsafe: Eliminate the `dump' subcommand.
Mark Wooding [Sun, 24 May 2015 10:47:02 +0000 (11:47 +0100)]
pwsafe: Eliminate the `dump' subcommand.

Its functionality will be replaced later.

Also, remove some functions which existed only to support `dump'.

8 years agopwsafe: Present the list of commands in alphabetical order.
Mark Wooding [Thu, 28 May 2015 09:57:28 +0000 (10:57 +0100)]
pwsafe: Present the list of commands in alphabetical order.

Previously they were in whatever dictionary order.  Hopeless.

8 years agoalgorithms.py, rand.c: Support `Latin dances' stream ciphers.
Mark Wooding [Tue, 26 May 2015 14:13:23 +0000 (15:13 +0100)]
algorithms.py, rand.c: Support `Latin dances' stream ciphers.

8 years agocatacomb/__init__.py: Trim `/' from identifiers names.
Mark Wooding [Tue, 26 May 2015 15:03:11 +0000 (16:03 +0100)]
catacomb/__init__.py: Trim `/' from identifiers names.

8 years agoalgorithms.py, rand.c: Move constant definitions and so on to `rand.c'.
Mark Wooding [Tue, 26 May 2015 13:06:36 +0000 (14:06 +0100)]
algorithms.py, rand.c: Move constant definitions and so on to `rand.c'.