From 65b65bb8ef8e35cc700d0883d344a361f04d3927 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Thu, 13 Sep 2018 13:00:56 +0100 Subject: [PATCH] Expose the structure tag 'crcda_ctx'. This one isn't used in many places, but it's another 'void *' pointer that ought to come with an identifying structure tag. --- ssh.h | 7 ++++--- ssh1bpp.c | 2 +- sshcrcda.c | 8 +++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ssh.h b/ssh.h index 2d285d23..1026a90b 100644 --- a/ssh.h +++ b/ssh.h @@ -322,9 +322,10 @@ unsigned long crc32_compute(const void *s, size_t len); unsigned long crc32_update(unsigned long crc_input, const void *s, size_t len); /* SSH CRC compensation attack detector */ -void *crcda_make_context(void); -void crcda_free_context(void *handle); -int detect_attack(void *handle, unsigned char *buf, uint32 len, +struct crcda_ctx; +struct crcda_ctx *crcda_make_context(void); +void crcda_free_context(struct crcda_ctx *ctx); +int detect_attack(struct crcda_ctx *ctx, unsigned char *buf, uint32 len, unsigned char *IV); /* diff --git a/ssh1bpp.c b/ssh1bpp.c index 7f5b72f6..5ace35fd 100644 --- a/ssh1bpp.c +++ b/ssh1bpp.c @@ -20,7 +20,7 @@ struct ssh1_bpp_state { const struct ssh_cipher *cipher; void *cipher_ctx; - void *crcda_ctx; + struct crcda_ctx *crcda_ctx; void *compctx, *decompctx; diff --git a/sshcrcda.c b/sshcrcda.c index 8d77cbb6..fe6598d3 100644 --- a/sshcrcda.c +++ b/sshcrcda.c @@ -55,7 +55,7 @@ struct crcda_ctx { uint32 n; }; -void *crcda_make_context(void) +struct crcda_ctx *crcda_make_context(void) { struct crcda_ctx *ret = snew(struct crcda_ctx); ret->h = NULL; @@ -63,9 +63,8 @@ void *crcda_make_context(void) return ret; } -void crcda_free_context(void *handle) +void crcda_free_context(struct crcda_ctx *ctx) { - struct crcda_ctx *ctx = (struct crcda_ctx *)handle; if (ctx) { sfree(ctx->h); ctx->h = NULL; @@ -102,9 +101,8 @@ static int check_crc(uchar *S, uchar *buf, uint32 len, uchar *IV) } /* Detect a crc32 compensation attack on a packet */ -int detect_attack(void *handle, uchar *buf, uint32 len, uchar *IV) +int detect_attack(struct crcda_ctx *ctx, uchar *buf, uint32 len, uchar *IV) { - struct crcda_ctx *ctx = (struct crcda_ctx *)handle; register uint32 i, j; uint32 l; register uchar *c;