1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-24 08:42:25 +00:00

Further void * / const fixes.

Yet more of these that commits 7babe66a8 and 8d882756b didn't spot. I
bet these still aren't the last, either.
This commit is contained in:
Simon Tatham 2018-06-08 19:07:47 +01:00
parent 0df6303bb5
commit be6fed13fa
7 changed files with 38 additions and 25 deletions

2
misc.c
View File

@ -485,7 +485,7 @@ struct strbuf_impl {
((buf)->visible.s = (ptr), \
(buf)->visible.u = (unsigned char *)(buf)->visible.s)
char *strbuf_append(strbuf *buf_o, size_t len)
void *strbuf_append(strbuf *buf_o, size_t len)
{
struct strbuf_impl *buf = FROMFIELD(buf_o, struct strbuf_impl, visible);
char *toret;

2
misc.h
View File

@ -40,7 +40,7 @@ struct strbuf {
};
strbuf *strbuf_new(void);
void strbuf_free(strbuf *buf);
char *strbuf_append(strbuf *buf, size_t len);
void *strbuf_append(strbuf *buf, size_t len);
char *strbuf_to_str(strbuf *buf); /* does free buf, but you must free result */
void strbuf_catf(strbuf *buf, const char *fmt, ...);
void strbuf_catfv(strbuf *buf, const char *fmt, va_list ap);

6
ssh.h
View File

@ -350,10 +350,10 @@ struct ssh_mac {
/* Passes in the cipher context */
void *(*make_context)(void *);
void (*free_context)(void *);
void (*setkey) (void *, unsigned char *key);
void (*setkey) (void *, const void *key);
/* whole-packet operations */
void (*generate) (void *, unsigned char *blk, int len, unsigned long seq);
int (*verify) (void *, unsigned char *blk, int len, unsigned long seq);
void (*generate) (void *, void *blk, int len, unsigned long seq);
int (*verify) (void *, const void *blk, int len, unsigned long seq);
/* partial-packet operations */
void (*start) (void *);
BinarySink *(*sink) (void *);

View File

@ -878,7 +878,7 @@ static void poly_free_context(void *ctx)
/* Not allocated, just forwarded, no need to free */
}
static void poly_setkey(void *ctx, unsigned char *key)
static void poly_setkey(void *ctx, const void *key)
{
/* Uses the same context as ChaCha20, so ignore */
}
@ -948,7 +948,8 @@ static int poly_verresult(void *handle, unsigned char const *blk)
}
/* The generic poly operation used before generate and verify */
static void poly_op(void *handle, unsigned char *blk, int len, unsigned long seq)
static void poly_op(void *handle, const unsigned char *blk, int len,
unsigned long seq)
{
struct ccp_context *ctx = (struct ccp_context *)handle;
poly_start(ctx);
@ -957,14 +958,17 @@ static void poly_op(void *handle, unsigned char *blk, int len, unsigned long seq
put_data(ctx, blk, len);
}
static void poly_generate(void *handle, unsigned char *blk, int len, unsigned long seq)
static void poly_generate(void *handle, void *vblk, int len, unsigned long seq)
{
unsigned char *blk = (unsigned char *)vblk;
poly_op(handle, blk, len, seq);
poly_genresult(handle, blk+len);
}
static int poly_verify(void *handle, unsigned char *blk, int len, unsigned long seq)
static int poly_verify(void *handle, const void *vblk, int len,
unsigned long seq)
{
const unsigned char *blk = (const unsigned char *)vblk;
poly_op(handle, blk, len, seq);
return poly_verresult(handle, blk+len);
}

View File

@ -261,7 +261,7 @@ void hmacmd5_key(void *handle, void const *keyv, int len)
smemclr(foo, 64); /* burn the evidence */
}
static void hmacmd5_key_16(void *handle, unsigned char *key)
static void hmacmd5_key_16(void *handle, const void *key)
{
hmacmd5_key(handle, key, 16);
}
@ -329,15 +329,17 @@ static void hmacmd5_do_hmac_ssh(void *handle, unsigned char const *blk, int len,
hmacmd5_do_hmac_internal(handle, seqbuf, 4, blk, len, hmac);
}
static void hmacmd5_generate(void *handle, unsigned char *blk, int len,
static void hmacmd5_generate(void *handle, void *vblk, int len,
unsigned long seq)
{
unsigned char *blk = (unsigned char *)vblk;
hmacmd5_do_hmac_ssh(handle, blk, len, seq, blk + len);
}
static int hmacmd5_verify(void *handle, unsigned char *blk, int len,
static int hmacmd5_verify(void *handle, const void *vblk, int len,
unsigned long seq)
{
const unsigned char *blk = (const unsigned char *)vblk;
unsigned char correct[16];
hmacmd5_do_hmac_ssh(handle, blk, len, seq, correct);
return smemeq(correct, blk + len, 16);

View File

@ -267,7 +267,8 @@ static void sha256_free_context(void *handle)
sfree(handle);
}
static void sha256_key_internal(void *handle, unsigned char *key, int len)
static void sha256_key_internal(void *handle,
const unsigned char *key, int len)
{
SHA256_State *keys = (SHA256_State *)handle;
unsigned char foo[64];
@ -288,7 +289,7 @@ static void sha256_key_internal(void *handle, unsigned char *key, int len)
smemclr(foo, 64); /* burn the evidence */
}
static void sha256_key(void *handle, unsigned char *key)
static void sha256_key(void *handle, const void *key)
{
sha256_key_internal(handle, key, 32);
}
@ -322,7 +323,7 @@ static void hmacsha256_genresult(void *handle, unsigned char *hmac)
SHA256_Final(&s, hmac);
}
static void sha256_do_hmac(void *handle, unsigned char *blk, int len,
static void sha256_do_hmac(void *handle, const unsigned char *blk, int len,
unsigned long seq, unsigned char *hmac)
{
BinarySink *bs = hmacsha256_sink(handle);
@ -332,9 +333,10 @@ static void sha256_do_hmac(void *handle, unsigned char *blk, int len,
hmacsha256_genresult(handle, hmac);
}
static void sha256_generate(void *handle, unsigned char *blk, int len,
static void sha256_generate(void *handle, void *vblk, int len,
unsigned long seq)
{
unsigned char *blk = (unsigned char *)vblk;
sha256_do_hmac(handle, blk, len, seq, blk + len);
}
@ -345,9 +347,10 @@ static int hmacsha256_verresult(void *handle, unsigned char const *hmac)
return smemeq(correct, hmac, 32);
}
static int sha256_verify(void *handle, unsigned char *blk, int len,
static int sha256_verify(void *handle, const void *vblk, int len,
unsigned long seq)
{
const unsigned char *blk = (const unsigned char *)vblk;
unsigned char correct[32];
sha256_do_hmac(handle, blk, len, seq, correct);
return smemeq(correct, blk + len, 32);

View File

@ -294,7 +294,7 @@ static void sha1_free_context(void *handle)
sfree(handle);
}
static void sha1_key_internal(void *handle, unsigned char *key, int len)
static void sha1_key_internal(void *handle, const unsigned char *key, int len)
{
SHA_State *keys = (SHA_State *)handle;
unsigned char foo[64];
@ -315,12 +315,12 @@ static void sha1_key_internal(void *handle, unsigned char *key, int len)
smemclr(foo, 64); /* burn the evidence */
}
static void sha1_key(void *handle, unsigned char *key)
static void sha1_key(void *handle, const void *key)
{
sha1_key_internal(handle, key, 20);
}
static void sha1_key_buggy(void *handle, unsigned char *key)
static void sha1_key_buggy(void *handle, const void *key)
{
sha1_key_internal(handle, key, 16);
}
@ -354,7 +354,7 @@ static void hmacsha1_genresult(void *handle, unsigned char *hmac)
SHA_Final(&s, hmac);
}
static void sha1_do_hmac(void *handle, unsigned char *blk, int len,
static void sha1_do_hmac(void *handle, const unsigned char *blk, int len,
unsigned long seq, unsigned char *hmac)
{
BinarySink *bs = hmacsha1_sink(handle);
@ -364,9 +364,10 @@ static void sha1_do_hmac(void *handle, unsigned char *blk, int len,
hmacsha1_genresult(handle, hmac);
}
static void sha1_generate(void *handle, unsigned char *blk, int len,
static void sha1_generate(void *handle, void *vblk, int len,
unsigned long seq)
{
unsigned char *blk = (unsigned char *)vblk;
sha1_do_hmac(handle, blk, len, seq, blk + len);
}
@ -377,9 +378,10 @@ static int hmacsha1_verresult(void *handle, unsigned char const *hmac)
return smemeq(correct, hmac, 20);
}
static int sha1_verify(void *handle, unsigned char *blk, int len,
static int sha1_verify(void *handle, const void *vblk, int len,
unsigned long seq)
{
const unsigned char *blk = (const unsigned char *)vblk;
unsigned char correct[20];
sha1_do_hmac(handle, blk, len, seq, correct);
return smemeq(correct, blk + len, 20);
@ -392,9 +394,10 @@ static void hmacsha1_96_genresult(void *handle, unsigned char *hmac)
memcpy(hmac, full, 12);
}
static void sha1_96_generate(void *handle, unsigned char *blk, int len,
static void sha1_96_generate(void *handle, void *vblk, int len,
unsigned long seq)
{
unsigned char *blk = (unsigned char *)vblk;
unsigned char full[20];
sha1_do_hmac(handle, blk, len, seq, full);
memcpy(blk + len, full, 12);
@ -407,9 +410,10 @@ static int hmacsha1_96_verresult(void *handle, unsigned char const *hmac)
return smemeq(correct, hmac, 12);
}
static int sha1_96_verify(void *handle, unsigned char *blk, int len,
static int sha1_96_verify(void *handle, const void *vblk, int len,
unsigned long seq)
{
const unsigned char *blk = (const unsigned char *)vblk;
unsigned char correct[20];
sha1_do_hmac(handle, blk, len, seq, correct);
return smemeq(correct, blk + len, 12);