chiark / gitweb /
sig: Move unmarshalling responsibility into algorithm
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 27 Sep 2019 17:40:42 +0000 (18:40 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 29 Sep 2019 14:58:48 +0000 (15:58 +0100)
commit9fcd759f42a3df955982a753162837d2034e26a8
tree970278948f4a6da2088498a8fca8057140c9393e
parent403cdd364693a05c700f04085fc05dbf575d97ef
sig: Move unmarshalling responsibility into algorithm

Because site wants to first unpick the packet, and only later actually
check the signature, we provide two entrypoints.  The first, `unpick',
basically just computes the length.  So the result of `unpick' is
simply a note of the part of the buffer which contains the signature.

The alternative would be to have site.c handle the length, so there
would be one entrypoint `check' which would get a byte block.  This
would move complexity from the `unpick'/`check' interface to the
`sign' interface (which would have to negotiate about space).  It
would mean that for algorithms where signatures are of fixed size, we
couldn't omit the length field.

rsa.c needs to do some shenanigans: because it wants to use
mpz_set_str (for historical reasons), it needs the buffer to be
nul-terminated.  So `unpick' checks that there will be a spare byte
afterwards into which we can write the nul.  `check' writes the nul -
and puts the previous character back, so that we don't have to write
weird stuff in the algorithm api.  Doing better than this would be
turd-polishing since this algorithm is obsolete.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
rsa.c
secnet.h
site.c