chiark / gitweb /
server/{keymgmt.c,tripe.h}: Unify public and private key handling.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 25 Jan 2012 10:30:11 +0000 (10:30 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 7 May 2012 14:35:10 +0000 (15:35 +0100)
commit799e58b96ef4948629d5e1b5401f537d74082ab7
treee6821d5783926f94a99641c60df6eb7de31edc4e
parent61682d3405e6b7c72ec8295fec1467333e336b65
server/{keymgmt.c,tripe.h}: Unify public and private key handling.

We introduce a new `kdata' object which represents a particular instance
of a key and remembers all sorts of useful things about it including its
name, associated algorithms, and so on.  It can represent either a
public or private key, since the only difference is whether it has a
private scalar.  These kdata objects are reference counted and exposed
to callers, though the old interface is, for now, retained for
compatibility.

Internally, the private/public split is pushed quite far down using a
`keyhalf' structure to keep track of the differences between the two
kinds.

There's a layer of caching and continuity management.  Each key tag maps
to a `knode' object which represents all the versions (i.e., different
kdata representations) of that key, and allows you to find the current
version.  A kdata object has a reference back to its home knode.

Since private keys are handled (mostly) in the same way as public keys,
there can also be multiple versions of private keys, and multiple
different private keys.  The code maintains a `preferred' private key,
and exports a pointer to its kdata as `master'.

As mentioned, there are some compatibility interfaces in place at the
moment, which maintain the old global key information and prevent
inconsistencies.  For example, currently the `master' kdata is only
allowed to advance if its group matches the previous one.  The plan is
to remove this global information, and allow peers to use different
versions of different private keys; peers will be responsible for
ensuring the consistency of the keys they use, and will be able to do
this without interfering with each other.
server/keymgmt.c
server/tripe.h