chiark / gitweb /
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>