1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-10 07:43:48 -05:00

Make ssh_hash and ssh_mac expose a BinarySink.

Just as I did a few commits ago with the low-level SHA_Bytes type
functions, the ssh_hash and ssh_mac abstract types now no longer have
a direct foo->bytes() update method at all. Instead, each one has a
foo->sink() function that returns a BinarySink with the same lifetime
as the hash context, and then the caller can feed data into that in
the usual way.

This lets me get rid of a couple more duplicate marshalling routines
in ssh.c: hash_string(), hash_uint32(), hash_mpint().
This commit is contained in:
Simon Tatham
2018-05-24 13:05:48 +01:00
parent 67de463cca
commit e27ddf6d28
9 changed files with 105 additions and 133 deletions

4
ssh.h
View File

@ -365,7 +365,7 @@ struct ssh_mac {
int (*verify) (void *, unsigned char *blk, int len, unsigned long seq);
/* partial-packet operations */
void (*start) (void *);
void (*bytes) (void *, unsigned char const *, int);
BinarySink *(*sink) (void *);
void (*genresult) (void *, unsigned char *);
int (*verresult) (void *, unsigned char const *);
const char *name, *etm_name;
@ -376,7 +376,7 @@ struct ssh_mac {
struct ssh_hash {
void *(*init)(void); /* also allocates context */
void *(*copy)(const void *);
void (*bytes)(void *, const void *, int);
BinarySink *(*sink) (void *);
void (*final)(void *, unsigned char *); /* also frees context */
void (*free)(void *);
int hlen; /* output length in bytes */