From 7babe66a839fecfe5d8b3db901b06d2fb7672cfc Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 26 May 2018 08:31:34 +0100 Subject: [PATCH] Make lots of generic data parameters into 'void *'. This is a cleanup I started to notice a need for during the BinarySink work. It removes a lot of faffing about casting things to char * or unsigned char * so that some API will accept them, even though lots of such APIs really take a plain 'block of raw binary data' argument and don't care what C thinks the signedness of that data might be - they may well reinterpret it back and forth internally. So I've tried to arrange for all the function call APIs that ought to have a void * (or const void *) to have one, and those that need to do pointer arithmetic on the parameter internally can cast it back at the top of the function. That saves endless ad-hoc casts at the call sites. --- contrib/cygtermd/telnet.c | 6 ++-- cproxy.c | 2 +- fuzzterm.c | 4 +-- import.c | 10 +++--- ldisc.c | 7 ++-- network.h | 4 +-- pageant.c | 2 +- portfwd.c | 8 ++--- proxy.c | 4 +-- pscp.c | 24 ++++++------- psftp.c | 4 +-- putty.h | 10 +++--- raw.c | 2 +- rlogin.c | 2 +- sftp.c | 2 +- sftp.h | 2 +- ssh.c | 15 ++++---- ssh.h | 76 +++++++++++++++++++-------------------- sshaes.c | 43 +++++++++++----------- ssharcf.c | 9 ++--- sshblowf.c | 40 ++++++++++----------- sshblowf.h | 7 ++-- sshbn.c | 6 ++-- sshccp.c | 15 ++++---- sshdes.c | 66 ++++++++++++++++++++-------------- sshdss.c | 22 ++++++------ sshecc.c | 29 ++++++++------- sshrsa.c | 22 ++++++------ telnet.c | 46 ++++++++++++------------ terminal.c | 5 +-- unix/gtkwin.c | 4 +-- unix/uxnet.c | 8 ++--- unix/uxpgnt.c | 5 +-- unix/uxplink.c | 4 +-- unix/uxproxy.c | 4 +-- windows/window.c | 6 ++-- windows/winhsock.c | 4 +-- windows/winnet.c | 8 ++--- windows/winplink.c | 4 +-- x11fwd.c | 5 ++- 40 files changed, 283 insertions(+), 263 deletions(-) diff --git a/contrib/cygtermd/telnet.c b/contrib/cygtermd/telnet.c index 08487374..ce0bc5fb 100644 --- a/contrib/cygtermd/telnet.c +++ b/contrib/cygtermd/telnet.c @@ -210,7 +210,7 @@ static void send_opt(Telnet telnet, int cmd, int option) b[0] = IAC; b[1] = cmd; b[2] = option; - sel_write(telnet->net, (char *)b, 3); + sel_write(telnet->net, b, 3); } static void deactivate_option(Telnet telnet, const struct Opt *o) @@ -554,10 +554,10 @@ void telnet_from_pty(Telnet telnet, char *buf, int len) while (p < end && iswritable(*p)) p++; - sel_write(telnet->net, (char *)q, p - q); + sel_write(telnet->net, q, p - q); while (p < end && !iswritable(*p)) { - sel_write(telnet->net, (char *)(*p == IAC ? iac : cr), 2); + sel_write(telnet->net, *p == IAC ? iac : cr, 2); p++; } } diff --git a/cproxy.c b/cproxy.c index d5bf1c60..dedfef2a 100644 --- a/cproxy.c +++ b/cproxy.c @@ -132,7 +132,7 @@ int proxy_socks5_handlechap (Proxy_Socket p) hmacmd5_chap(data, p->chap_current_datalen, conf_get_str(p->conf, CONF_proxy_password), &outbuf[4]); - sk_write(p->sub_socket, (char *)outbuf, 20); + sk_write(p->sub_socket, outbuf, 20); break; case 0x11: /* Chose a protocol */ diff --git a/fuzzterm.c b/fuzzterm.c index 667d2eea..21246069 100644 --- a/fuzzterm.c +++ b/fuzzterm.c @@ -38,7 +38,7 @@ int main(int argc, char **argv) return 0; } -int from_backend(void *frontend, int is_stderr, const char *data, int len) +int from_backend(void *frontend, int is_stderr, const void *data, int len) { return 0; } /* functions required by terminal.c */ @@ -71,7 +71,7 @@ void set_title(void *frontend, char *t) { } void set_icon(void *frontend, char *t) { } void set_sbar(void *frontend, int a, int b, int c) { } -void ldisc_send(void *handle, const char *buf, int len, int interactive) {} +void ldisc_send(void *handle, const void *buf, int len, int interactive) {} void ldisc_echoedit_update(void *handle) {} Context get_ctx(void *frontend) { static char x; diff --git a/import.c b/import.c index e63282d4..93f3c75d 100644 --- a/import.c +++ b/import.c @@ -585,14 +585,14 @@ struct ssh2_userkey *openssh_pem_read(const Filename *filename, * Now decrypt the key blob. */ if (key->encryption == OP_E_3DES) - des3_decrypt_pubkey_ossh(keybuf, (unsigned char *)key->iv, + des3_decrypt_pubkey_ossh(keybuf, key->iv, key->keyblob, key->keyblob_len); else { void *ctx; assert(key->encryption == OP_E_AES); ctx = aes_make_context(); aes128_key(ctx, keybuf); - aes_iv(ctx, (unsigned char *)key->iv); + aes_iv(ctx, key->iv); aes_ssh2_decrypt_blk(ctx, key->keyblob, key->keyblob_len); aes_free_context(ctx); } @@ -2219,8 +2219,7 @@ struct ssh2_userkey *sshcom_read(const Filename *filename, char *passphrase, * Now decrypt the key blob. */ memset(iv, 0, sizeof(iv)); - des3_decrypt_pubkey_ossh(keybuf, iv, (unsigned char *)ciphertext, - cipherlen); + des3_decrypt_pubkey_ossh(keybuf, iv, ciphertext, cipherlen); smemclr(&md5c, sizeof(md5c)); smemclr(keybuf, sizeof(keybuf)); @@ -2478,8 +2477,7 @@ int sshcom_write(const Filename *filename, struct ssh2_userkey *key, * Now decrypt the key blob. */ memset(iv, 0, sizeof(iv)); - des3_encrypt_pubkey_ossh(keybuf, iv, (unsigned char *)ciphertext, - cipherlen); + des3_encrypt_pubkey_ossh(keybuf, iv, ciphertext, cipherlen); smemclr(&md5c, sizeof(md5c)); smemclr(keybuf, sizeof(keybuf)); diff --git a/ldisc.c b/ldisc.c index 320a9360..06c5e90f 100644 --- a/ldisc.c +++ b/ldisc.c @@ -22,7 +22,7 @@ (ldisc->back->ldisc(ldisc->backhandle, LD_EDIT) || \ term_ldisc(ldisc->term, LD_EDIT)))) -static void c_write(Ldisc ldisc, const char *buf, int len) +static void c_write(Ldisc ldisc, const void *buf, int len) { from_backend(ldisc->frontend, 0, buf, len); } @@ -47,7 +47,7 @@ static void pwrite(Ldisc ldisc, unsigned char c) if ((c >= 32 && c <= 126) || (!in_utf(ldisc->term) && c >= 0xA0) || (in_utf(ldisc->term) && c >= 0x80)) { - c_write(ldisc, (char *)&c, 1); + c_write(ldisc, &c, 1); } else if (c < 128) { char cc[2]; cc[1] = (c == 127 ? '?' : c + 0x40); @@ -134,8 +134,9 @@ void ldisc_echoedit_update(void *handle) frontend_echoedit_update(ldisc->frontend, ECHOING, EDITING); } -void ldisc_send(void *handle, const char *buf, int len, int interactive) +void ldisc_send(void *handle, const void *vbuf, int len, int interactive) { + const char *buf = (const char *)vbuf; Ldisc ldisc = (Ldisc) handle; int keyflag = 0; diff --git a/network.h b/network.h index 669424ad..680d3f04 100644 --- a/network.h +++ b/network.h @@ -26,8 +26,8 @@ struct socket_function_table { /* if p is NULL, it doesn't change the plug */ /* but it does return the one it's using */ void (*close) (Socket s); - int (*write) (Socket s, const char *data, int len); - int (*write_oob) (Socket s, const char *data, int len); + int (*write) (Socket s, const void *data, int len); + int (*write_oob) (Socket s, const void *data, int len); void (*write_eof) (Socket s); void (*flush) (Socket s); void (*set_frozen) (Socket s, int is_frozen); diff --git a/pageant.c b/pageant.c index ba2d42de..dcee20c6 100644 --- a/pageant.c +++ b/pageant.c @@ -403,7 +403,7 @@ void pageant_handle_msg(BinarySink *bs, put_byte(bs, SSH2_AGENT_SIGN_RESPONSE); signature = strbuf_new(); - key->alg->sign(key->data, (const char *)data, datalen, + key->alg->sign(key->data, data, datalen, BinarySink_UPCAST(signature)); put_stringsb(bs, signature); diff --git a/portfwd.c b/portfwd.c index f2652557..80c2f4b4 100644 --- a/portfwd.c +++ b/portfwd.c @@ -308,7 +308,7 @@ static void pfd_receive(Plug plug, int urgent, char *data, int len) if (pf->socksbuf[1] != 1 || pf->socksbuf[2] != 0) { /* Not CONNECT or reserved field nonzero - error */ reply[1] = 1; /* generic failure */ - sk_write(pf->s, (char *) reply, lenof(reply)); + sk_write(pf->s, reply, lenof(reply)); pfd_close(pf); return; } @@ -319,7 +319,7 @@ static void pfd_receive(Plug plug, int urgent, char *data, int len) pf->port = GET_16BIT_MSB_FIRST(pf->socksbuf+4+alen); if (atype == 1) { /* REP=0 (success) already */ - sk_write(pf->s, (char *) reply, lenof(reply)); + sk_write(pf->s, reply, lenof(reply)); pf->hostname = dupprintf("%d.%d.%d.%d", (unsigned char)pf->socksbuf[4], (unsigned char)pf->socksbuf[5], @@ -328,7 +328,7 @@ static void pfd_receive(Plug plug, int urgent, char *data, int len) goto connect; } else if (atype == 3) { /* REP=0 (success) already */ - sk_write(pf->s, (char *) reply, lenof(reply)); + sk_write(pf->s, reply, lenof(reply)); pf->hostname = snewn(alen, char); pf->hostname[alen-1] = '\0'; memcpy(pf->hostname, pf->socksbuf + 5, alen-1); @@ -338,7 +338,7 @@ static void pfd_receive(Plug plug, int urgent, char *data, int len) * Unknown address type. (FIXME: support IPv6!) */ reply[1] = 8; /* atype not supported */ - sk_write(pf->s, (char *) reply, lenof(reply)); + sk_write(pf->s, reply, lenof(reply)); pfd_close(pf); return; } diff --git a/proxy.c b/proxy.c index 7ff9b249..3fe36e12 100644 --- a/proxy.c +++ b/proxy.c @@ -96,7 +96,7 @@ static void sk_proxy_close (Socket s) sfree(ps); } -static int sk_proxy_write (Socket s, const char *data, int len) +static int sk_proxy_write (Socket s, const void *data, int len) { Proxy_Socket ps = (Proxy_Socket) s; @@ -107,7 +107,7 @@ static int sk_proxy_write (Socket s, const char *data, int len) return sk_write(ps->sub_socket, data, len); } -static int sk_proxy_write_oob (Socket s, const char *data, int len) +static int sk_proxy_write_oob (Socket s, const void *data, int len) { Proxy_Socket ps = (Proxy_Socket) s; diff --git a/pscp.c b/pscp.c index 87a760c2..22cbf57e 100644 --- a/pscp.c +++ b/pscp.c @@ -158,7 +158,7 @@ static unsigned char *outptr; /* where to put the data */ static unsigned outlen; /* how much data required */ static unsigned char *pending = NULL; /* any spare data */ static unsigned pendlen = 0, pendsize = 0; /* length and phys. size of buffer */ -int from_backend(void *frontend, int is_stderr, const char *data, int datalen) +int from_backend(void *frontend, int is_stderr, const void *data, int datalen) { unsigned char *p = (unsigned char *) data; unsigned len = (unsigned) datalen; @@ -196,7 +196,7 @@ int from_backend(void *frontend, int is_stderr, const char *data, int datalen) return 0; } -int from_backend_untrusted(void *frontend_handle, const char *data, int len) +int from_backend_untrusted(void *frontend_handle, const void *data, int len) { /* * No "untrusted" output should get here (the way the code is @@ -219,7 +219,7 @@ int from_backend_eof(void *frontend) } return FALSE; } -static int ssh_scp_recv(unsigned char *buf, int len) +static int ssh_scp_recv(void *buf, int len) { outptr = buf; outlen = len; @@ -304,7 +304,7 @@ static void bump(const char *fmt, ...) char ch; back->special(backhandle, TS_EOF); sent_eof = TRUE; - ssh_scp_recv((unsigned char *) &ch, 1); + ssh_scp_recv(&ch, 1); } cleanup_exit(1); @@ -611,7 +611,7 @@ static int response(void) char ch, resp, rbuf[2048]; int p; - if (ssh_scp_recv((unsigned char *) &resp, 1) <= 0) + if (ssh_scp_recv(&resp, 1) <= 0) bump("Lost connection"); p = 0; @@ -624,7 +624,7 @@ static int response(void) case 1: /* error */ case 2: /* fatal error */ do { - if (ssh_scp_recv((unsigned char *) &ch, 1) <= 0) + if (ssh_scp_recv(&ch, 1) <= 0) bump("Protocol error: Lost connection"); rbuf[p++] = ch; } while (p < sizeof(rbuf) && ch != '\n'); @@ -640,7 +640,7 @@ static int response(void) int sftp_recvdata(char *buf, int len) { - return ssh_scp_recv((unsigned char *) buf, len); + return ssh_scp_recv(buf, len); } int sftp_senddata(char *buf, int len) { @@ -1433,14 +1433,14 @@ int scp_get_sink_action(struct scp_sink_action *act) bufsize = 0; while (!done) { - if (ssh_scp_recv((unsigned char *) &ch, 1) <= 0) + if (ssh_scp_recv(&ch, 1) <= 0) return 1; if (ch == '\n') bump("Protocol error: Unexpected newline"); i = 0; action = ch; do { - if (ssh_scp_recv((unsigned char *) &ch, 1) <= 0) + if (ssh_scp_recv(&ch, 1) <= 0) bump("Lost connection"); if (i >= bufsize) { bufsize = i + 128; @@ -1567,7 +1567,7 @@ int scp_recv_filedata(char *data, int len) return actuallen; } else { - return ssh_scp_recv((unsigned char *) data, len); + return ssh_scp_recv(data, len); } } @@ -2204,7 +2204,7 @@ static void get_dir_list(int argc, char *argv[]) if (using_sftp) { scp_sftp_listdir(src); } else { - while (ssh_scp_recv((unsigned char *) &c, 1) > 0) + while (ssh_scp_recv(&c, 1) > 0) tell_char(stdout, c); } } @@ -2379,7 +2379,7 @@ int psftp_main(int argc, char *argv[]) char ch; back->special(backhandle, TS_EOF); sent_eof = TRUE; - ssh_scp_recv((unsigned char *) &ch, 1); + ssh_scp_recv(&ch, 1); } random_save_seed(); diff --git a/psftp.c b/psftp.c index 643389da..46eeeb40 100644 --- a/psftp.c +++ b/psftp.c @@ -2508,7 +2508,7 @@ static unsigned char *outptr; /* where to put the data */ static unsigned outlen; /* how much data required */ static unsigned char *pending = NULL; /* any spare data */ static unsigned pendlen = 0, pendsize = 0; /* length and phys. size of buffer */ -int from_backend(void *frontend, int is_stderr, const char *data, int datalen) +int from_backend(void *frontend, int is_stderr, const void *data, int datalen) { unsigned char *p = (unsigned char *) data; unsigned len = (unsigned) datalen; @@ -2552,7 +2552,7 @@ int from_backend(void *frontend, int is_stderr, const char *data, int datalen) return 0; } -int from_backend_untrusted(void *frontend_handle, const char *data, int len) +int from_backend_untrusted(void *frontend_handle, const void *data, int len) { /* * No "untrusted" output should get here (the way the code is diff --git a/putty.h b/putty.h index c81b6307..d7301509 100644 --- a/putty.h +++ b/putty.h @@ -685,8 +685,8 @@ void frontend_echoedit_update(void *frontend, int echo, int edit); * special commands changes. It does not need to invoke it at session * shutdown. */ void update_specials_menu(void *frontend); -int from_backend(void *frontend, int is_stderr, const char *data, int len); -int from_backend_untrusted(void *frontend, const char *data, int len); +int from_backend(void *frontend, int is_stderr, const void *data, int len); +int from_backend_untrusted(void *frontend, const void *data, int len); /* Called when the back end wants to indicate that EOF has arrived on * the server-to-client stream. Returns FALSE to indicate that we * intend to keep the session open in the other direction, or TRUE to @@ -1103,8 +1103,8 @@ void term_reconfig(Terminal *, Conf *); void term_request_copy(Terminal *, const int *clipboards, int n_clipboards); void term_request_paste(Terminal *, int clipboard); void term_seen_key_event(Terminal *); -int term_data(Terminal *, int is_stderr, const char *data, int len); -int term_data_untrusted(Terminal *, const char *data, int len); +int term_data(Terminal *, int is_stderr, const void *data, int len); +int term_data_untrusted(Terminal *, const void *data, int len); void term_provide_resize_fn(Terminal *term, void (*resize_fn)(void *, int, int), void *resize_ctx); @@ -1175,7 +1175,7 @@ extern Backend ssh_backend; void *ldisc_create(Conf *, Terminal *, Backend *, void *, void *); void ldisc_configure(void *, Conf *); void ldisc_free(void *); -void ldisc_send(void *handle, const char *buf, int len, int interactive); +void ldisc_send(void *handle, const void *buf, int len, int interactive); void ldisc_echoedit_update(void *handle); /* diff --git a/raw.c b/raw.c index d0840a1a..47454de0 100644 --- a/raw.c +++ b/raw.c @@ -25,7 +25,7 @@ typedef struct raw_backend_data { static void raw_size(void *handle, int width, int height); -static void c_write(Raw raw, char *buf, int len) +static void c_write(Raw raw, const void *buf, int len) { int backlog = from_backend(raw->frontend, 0, buf, len); sk_set_frozen(raw->s, backlog > RAW_MAX_BACKLOG); diff --git a/rlogin.c b/rlogin.c index ccb75119..92660b86 100644 --- a/rlogin.c +++ b/rlogin.c @@ -31,7 +31,7 @@ typedef struct rlogin_tag { static void rlogin_size(void *handle, int width, int height); -static void c_write(Rlogin rlogin, char *buf, int len) +static void c_write(Rlogin rlogin, const void *buf, int len) { int backlog = from_backend(rlogin->frontend, 0, buf, len); sk_set_frozen(rlogin->s, backlog > RLOGIN_MAX_BACKLOG); diff --git a/sftp.c b/sftp.c index 665bbe12..77162157 100644 --- a/sftp.c +++ b/sftp.c @@ -993,7 +993,7 @@ struct fxp_names *fxp_readdir_recv(struct sftp_packet *pktin, * Write to a file. Returns 0 on error, 1 on OK. */ struct sftp_request *fxp_write_send(struct fxp_handle *handle, - char *buffer, uint64 offset, int len) + void *buffer, uint64 offset, int len) { struct sftp_request *req = sftp_alloc_request(); struct sftp_packet *pktout; diff --git a/sftp.h b/sftp.h index d9fa6939..b30e49f4 100644 --- a/sftp.h +++ b/sftp.h @@ -211,7 +211,7 @@ int fxp_read_recv(struct sftp_packet *pktin, struct sftp_request *req, * Write to a file. Returns 0 on error, 1 on OK. */ struct sftp_request *fxp_write_send(struct fxp_handle *handle, - char *buffer, uint64 offset, int len); + void *buffer, uint64 offset, int len); int fxp_write_recv(struct sftp_packet *pktin, struct sftp_request *req); /* diff --git a/ssh.c b/ssh.c index f220d5df..0e690e1d 100644 --- a/ssh.c +++ b/ssh.c @@ -1352,15 +1352,16 @@ static int alloc_channel_id(Ssh ssh) return low + 1 + CHANNEL_NUMBER_OFFSET; } -static void c_write_stderr(int trusted, const char *buf, int len) +static void c_write_stderr(int trusted, const void *vbuf, int len) { + const char *buf = (const char *)vbuf; int i; for (i = 0; i < len; i++) if (buf[i] != '\r' && (trusted || buf[i] == '\n' || (buf[i] & 0x60))) fputc(buf[i], stderr); } -static void c_write(Ssh ssh, const char *buf, int len) +static void c_write(Ssh ssh, const void *buf, int len) { if (flags & FLAG_STDERR) c_write_stderr(1, buf, len); @@ -1368,7 +1369,7 @@ static void c_write(Ssh ssh, const char *buf, int len) from_backend(ssh->frontend, 1, buf, len); } -static void c_write_untrusted(Ssh ssh, const char *buf, int len) +static void c_write_untrusted(Ssh ssh, const void *buf, int len) { if (flags & FLAG_STDERR) c_write_stderr(0, buf, len); @@ -2175,7 +2176,7 @@ static int s_write(Ssh ssh, void *data, int len) 0, NULL, NULL, 0, NULL); if (!ssh->s) return 0; - return sk_write(ssh->s, (char *)data, len); + return sk_write(ssh->s, data, len); } static void s_wrpkt(Ssh ssh, struct Packet *pkt) @@ -2808,7 +2809,7 @@ static Bignum ssh2_pkt_getmp(struct Packet *pkt) return NULL; if (p[0] & 0x80) return NULL; - b = bignum_from_bytes((unsigned char *)p, length); + b = bignum_from_bytes(p, length); return b; } @@ -5219,7 +5220,7 @@ void sshfwd_unclean_close(struct ssh_channel *c, const char *err) ssh2_channel_check_close(c); } -int sshfwd_write(struct ssh_channel *c, char *buf, int len) +int sshfwd_write(struct ssh_channel *c, const void *buf, int len) { Ssh ssh = c->ssh; @@ -7898,7 +7899,7 @@ static void do_ssh2_transport(void *vctx) } if (!ssh->hostkey->verifysig(s->hkey, s->sigdata, s->siglen, - (char *)s->exchange_hash, + s->exchange_hash, ssh->kex->hash->hlen)) { #ifndef FUZZING bombout(("Server's host key did not match the signature " diff --git a/ssh.h b/ssh.h index e11e2cf8..523419e7 100644 --- a/ssh.h +++ b/ssh.h @@ -10,7 +10,7 @@ struct ssh_channel; typedef struct ssh_tag *Ssh; -extern int sshfwd_write(struct ssh_channel *c, char *, int); +extern int sshfwd_write(struct ssh_channel *c, const void *, int); extern void sshfwd_write_eof(struct ssh_channel *c); extern void sshfwd_unclean_close(struct ssh_channel *c, const char *err); extern void sshfwd_unthrottle(struct ssh_channel *c, int bufsize); @@ -203,7 +203,7 @@ int detect_attack(void *handle, unsigned char *buf, uint32 len, * SSH2 RSA key exchange functions */ struct ssh_hash; -void *ssh_rsakex_newkey(char *data, int len); +void *ssh_rsakex_newkey(const void *data, int len); void ssh_rsakex_freekey(void *key); int ssh_rsakex_klen(void *key); void ssh_rsakex_encrypt(const struct ssh_hash *h, unsigned char *in, int inlen, @@ -295,9 +295,9 @@ struct ssh_mac; struct ssh_cipher { void *(*make_context)(void); void (*free_context)(void *); - void (*sesskey) (void *, unsigned char *key); /* for SSH-1 */ - void (*encrypt) (void *, unsigned char *blk, int len); - void (*decrypt) (void *, unsigned char *blk, int len); + void (*sesskey) (void *, const void *key); /* for SSH-1 */ + void (*encrypt) (void *, void *blk, int len); + void (*decrypt) (void *, void *blk, int len); int blksize; const char *text_name; }; @@ -305,13 +305,13 @@ struct ssh_cipher { struct ssh2_cipher { void *(*make_context)(void); void (*free_context)(void *); - void (*setiv) (void *, unsigned char *key); /* for SSH-2 */ - void (*setkey) (void *, unsigned char *key);/* for SSH-2 */ - void (*encrypt) (void *, unsigned char *blk, int len); - void (*decrypt) (void *, unsigned char *blk, int len); + void (*setiv) (void *, const void *iv); /* for SSH-2 */ + void (*setkey) (void *, const void *key);/* for SSH-2 */ + void (*encrypt) (void *, void *blk, int len); + void (*decrypt) (void *, void *blk, int len); /* Ignored unless SSH_CIPHER_SEPARATE_LENGTH flag set */ - void (*encrypt_length) (void *, unsigned char *blk, int len, unsigned long seq); - void (*decrypt_length) (void *, unsigned char *blk, int len, unsigned long seq); + void (*encrypt_length) (void *, void *blk, int len, unsigned long seq); + void (*decrypt_length) (void *, void *blk, int len, unsigned long seq); const char *name; int blksize; /* real_keybits is the number of bits of entropy genuinely used by @@ -382,14 +382,14 @@ struct ssh_kexes { struct ssh_signkey { void *(*newkey) (const struct ssh_signkey *self, - const char *data, int len); + const void *data, int len); void (*freekey) (void *key); char *(*fmtkey) (void *key); void (*public_blob)(void *key, BinarySink *); void (*private_blob)(void *key, BinarySink *); void *(*createkey) (const struct ssh_signkey *self, - const unsigned char *pub_blob, int pub_len, - const unsigned char *priv_blob, int priv_len); + const void *pub_blob, int pub_len, + const void *priv_blob, int priv_len); void *(*openssh_createkey) (const struct ssh_signkey *self, const unsigned char **blob, int *len); void (*openssh_fmtkey) (void *key, BinarySink *); @@ -404,9 +404,9 @@ struct ssh_signkey { int openssh_private_npieces; int (*pubkey_bits) (const struct ssh_signkey *self, const void *blob, int len); - int (*verifysig) (void *key, const char *sig, int siglen, - const char *data, int datalen); - void (*sign) (void *key, const char *data, int datalen, BinarySink *); + int (*verifysig) (void *key, const void *sig, int siglen, + const void *data, int datalen); + void (*sign) (void *key, const void *data, int datalen, BinarySink *); const char *name; const char *keytype; /* for host key cache */ const void *extra; /* private to the public key methods */ @@ -472,13 +472,13 @@ extern const struct ssh_mac ssh_hmac_sha256; void *aes_make_context(void); void aes_free_context(void *handle); -void aes128_key(void *handle, unsigned char *key); -void aes192_key(void *handle, unsigned char *key); -void aes256_key(void *handle, unsigned char *key); -void aes_iv(void *handle, unsigned char *iv); -void aes_ssh2_encrypt_blk(void *handle, unsigned char *blk, int len); -void aes_ssh2_decrypt_blk(void *handle, unsigned char *blk, int len); -void aes_ssh2_sdctr(void *handle, unsigned char *blk, int len); +void aes128_key(void *handle, const void *key); +void aes192_key(void *handle, const void *key); +void aes256_key(void *handle, const void *key); +void aes_iv(void *handle, const void *iv); +void aes_ssh2_encrypt_blk(void *handle, void *blk, int len); +void aes_ssh2_decrypt_blk(void *handle, void *blk, int len); +void aes_ssh2_sdctr(void *handle, void *blk, int len); /* * PuTTY version number formatted as an SSH version string. @@ -657,8 +657,8 @@ Bignum modmul(Bignum a, Bignum b, Bignum mod); Bignum modsub(const Bignum a, const Bignum b, const Bignum n); void decbn(Bignum n); extern Bignum Zero, One; -Bignum bignum_from_bytes(const unsigned char *data, int nbytes); -Bignum bignum_from_bytes_le(const unsigned char *data, int nbytes); +Bignum bignum_from_bytes(const void *data, int nbytes); +Bignum bignum_from_bytes_le(const void *data, int nbytes); Bignum bignum_random_in_range(const Bignum lower, const Bignum upper); int ssh1_read_bignum(const unsigned char *data, int len, Bignum * result); int bignum_bitcount(Bignum bn); @@ -796,21 +796,17 @@ int export_ssh1(const Filename *filename, int type, int export_ssh2(const Filename *filename, int type, struct ssh2_userkey *key, char *passphrase); -void des3_decrypt_pubkey(unsigned char *key, unsigned char *blk, int len); -void des3_encrypt_pubkey(unsigned char *key, unsigned char *blk, int len); -void des3_decrypt_pubkey_ossh(unsigned char *key, unsigned char *iv, - unsigned char *blk, int len); -void des3_encrypt_pubkey_ossh(unsigned char *key, unsigned char *iv, - unsigned char *blk, int len); -void aes256_encrypt_pubkey(unsigned char *key, unsigned char *blk, - int len); -void aes256_decrypt_pubkey(unsigned char *key, unsigned char *blk, - int len); +void des3_decrypt_pubkey(const void *key, void *blk, int len); +void des3_encrypt_pubkey(const void *key, void *blk, int len); +void des3_decrypt_pubkey_ossh(const void *key, const void *iv, + void *blk, int len); +void des3_encrypt_pubkey_ossh(const void *key, const void *iv, + void *blk, int len); +void aes256_encrypt_pubkey(const void *key, void *blk, int len); +void aes256_decrypt_pubkey(const void *key, void *blk, int len); -void des_encrypt_xdmauth(const unsigned char *key, - unsigned char *blk, int len); -void des_decrypt_xdmauth(const unsigned char *key, - unsigned char *blk, int len); +void des_encrypt_xdmauth(const void *key, void *blk, int len); +void des_decrypt_xdmauth(const void *key, void *blk, int len); void openssh_bcrypt(const char *passphrase, const unsigned char *salt, int saltbytes, diff --git a/sshaes.c b/sshaes.c index 7a2fa135..759593d7 100644 --- a/sshaes.c +++ b/sshaes.c @@ -67,7 +67,8 @@ static void aes_decrypt_cbc_sw(unsigned char*, int, AESContext*); static void aes_sdctr_sw(unsigned char*, int, AESContext*); INLINE static int supports_aes_ni(); -static void aes_setup_ni(AESContext * ctx, unsigned char *key, int keylen); +static void aes_setup_ni(AESContext * ctx, + const unsigned char *key, int keylen); INLINE static void aes_encrypt_cbc(unsigned char *blk, int len, AESContext * ctx) { @@ -691,7 +692,7 @@ static const word32 D3[256] = { * bytes; it can be either 16 (128-bit), 24 (192-bit), or 32 * (256-bit). */ -static void aes_setup(AESContext * ctx, unsigned char *key, int keylen) +static void aes_setup(AESContext * ctx, const unsigned char *key, int keylen) { int i, j, Nk, rconst; size_t bufaddr; @@ -979,26 +980,27 @@ void aes_free_context(void *handle) sfree(handle); } -void aes128_key(void *handle, unsigned char *key) +void aes128_key(void *handle, const void *key) { AESContext *ctx = (AESContext *)handle; aes_setup(ctx, key, 16); } -void aes192_key(void *handle, unsigned char *key) +void aes192_key(void *handle, const void *key) { AESContext *ctx = (AESContext *)handle; aes_setup(ctx, key, 24); } -void aes256_key(void *handle, unsigned char *key) +void aes256_key(void *handle, const void *key) { AESContext *ctx = (AESContext *)handle; aes_setup(ctx, key, 32); } -void aes_iv(void *handle, unsigned char *iv) +void aes_iv(void *handle, const void *viv) { + const unsigned char *iv = (const unsigned char *)viv; AESContext *ctx = (AESContext *)handle; if (ctx->isNI) { memcpy(ctx->iv, iv, sizeof(ctx->iv)); @@ -1010,25 +1012,25 @@ void aes_iv(void *handle, unsigned char *iv) } } -void aes_ssh2_encrypt_blk(void *handle, unsigned char *blk, int len) +void aes_ssh2_encrypt_blk(void *handle, void *blk, int len) { AESContext *ctx = (AESContext *)handle; aes_encrypt_cbc(blk, len, ctx); } -void aes_ssh2_decrypt_blk(void *handle, unsigned char *blk, int len) +void aes_ssh2_decrypt_blk(void *handle, void *blk, int len) { AESContext *ctx = (AESContext *)handle; aes_decrypt_cbc(blk, len, ctx); } -void aes_ssh2_sdctr(void *handle, unsigned char *blk, int len) +void aes_ssh2_sdctr(void *handle, void *blk, int len) { AESContext *ctx = (AESContext *)handle; aes_sdctr(blk, len, ctx); } -void aes256_encrypt_pubkey(unsigned char *key, unsigned char *blk, int len) +void aes256_encrypt_pubkey(const void *key, void *blk, int len) { AESContext ctx; aes_setup(&ctx, key, 32); @@ -1037,7 +1039,7 @@ void aes256_encrypt_pubkey(unsigned char *key, unsigned char *blk, int len) smemclr(&ctx, sizeof(ctx)); } -void aes256_decrypt_pubkey(unsigned char *key, unsigned char *blk, int len) +void aes256_decrypt_pubkey(const void *key, void *blk, int len) { AESContext ctx; aes_setup(&ctx, key, 32); @@ -1295,10 +1297,10 @@ INLINE static void KEY_256_ASSIST_2(__m128i* temp1, __m128i * temp3) * AES-NI key expansion core */ FUNC_ISA -static void AES_128_Key_Expansion (unsigned char *userkey, __m128i *key) +static void AES_128_Key_Expansion (const unsigned char *userkey, __m128i *key) { __m128i temp1, temp2; - temp1 = _mm_loadu_si128((__m128i*)userkey); + temp1 = _mm_loadu_si128((const __m128i*)userkey); key[0] = temp1; temp2 = _mm_aeskeygenassist_si128 (temp1 ,0x1); temp1 = AES_128_ASSIST(temp1, temp2); @@ -1333,11 +1335,11 @@ static void AES_128_Key_Expansion (unsigned char *userkey, __m128i *key) } FUNC_ISA -static void AES_192_Key_Expansion (unsigned char *userkey, __m128i *key) +static void AES_192_Key_Expansion (const unsigned char *userkey, __m128i *key) { __m128i temp1, temp2, temp3; - temp1 = _mm_loadu_si128((__m128i*)userkey); - temp3 = _mm_loadu_si128((__m128i*)(userkey+16)); + temp1 = _mm_loadu_si128((const __m128i*)userkey); + temp3 = _mm_loadu_si128((const __m128i*)(userkey+16)); key[0]=temp1; key[1]=temp3; temp2=_mm_aeskeygenassist_si128 (temp3,0x1); @@ -1375,11 +1377,11 @@ static void AES_192_Key_Expansion (unsigned char *userkey, __m128i *key) } FUNC_ISA -static void AES_256_Key_Expansion (unsigned char *userkey, __m128i *key) +static void AES_256_Key_Expansion (const unsigned char *userkey, __m128i *key) { __m128i temp1, temp2, temp3; - temp1 = _mm_loadu_si128((__m128i*)userkey); - temp3 = _mm_loadu_si128((__m128i*)(userkey+16)); + temp1 = _mm_loadu_si128((const __m128i*)userkey); + temp3 = _mm_loadu_si128((const __m128i*)(userkey+16)); key[0] = temp1; key[1] = temp3; temp2 = _mm_aeskeygenassist_si128 (temp3,0x01); @@ -1659,7 +1661,8 @@ static void aes_inv_key_14(AESContext * ctx) * (256-bit). */ FUNC_ISA -static void aes_setup_ni(AESContext * ctx, unsigned char *key, int keylen) +static void aes_setup_ni(AESContext * ctx, + const unsigned char *key, int keylen) { __m128i *keysched = (__m128i*)ctx->keysched; diff --git a/ssharcf.c b/ssharcf.c index d16ce225..336e4d06 100644 --- a/ssharcf.c +++ b/ssharcf.c @@ -11,8 +11,9 @@ typedef struct { unsigned char i, j, s[256]; } ArcfourContext; -static void arcfour_block(void *handle, unsigned char *blk, int len) +static void arcfour_block(void *handle, void *vblk, int len) { + unsigned char *blk = (unsigned char *)vblk; ArcfourContext *ctx = (ArcfourContext *)handle; unsigned k; unsigned char tmp, i, j, *s; @@ -79,21 +80,21 @@ static void arcfour_stir(ArcfourContext *ctx) sfree(junk); } -static void arcfour128_key(void *handle, unsigned char *key) +static void arcfour128_key(void *handle, const void *key) { ArcfourContext *ctx = (ArcfourContext *)handle; arcfour_setkey(ctx, key, 16); arcfour_stir(ctx); } -static void arcfour256_key(void *handle, unsigned char *key) +static void arcfour256_key(void *handle, const void *key) { ArcfourContext *ctx = (ArcfourContext *)handle; arcfour_setkey(ctx, key, 32); arcfour_stir(ctx); } -static void arcfour_iv(void *handle, unsigned char *key) +static void arcfour_iv(void *handle, const void *iv) { } diff --git a/sshblowf.c b/sshblowf.c index 353116a6..24421059 100644 --- a/sshblowf.c +++ b/sshblowf.c @@ -300,7 +300,7 @@ static void blowfish_decrypt(word32 xL, word32 xR, word32 * output, } static void blowfish_lsb_encrypt_cbc(unsigned char *blk, int len, - BlowfishContext * ctx) + BlowfishContext * ctx) { word32 xL, xR, out[2], iv0, iv1; @@ -327,9 +327,9 @@ static void blowfish_lsb_encrypt_cbc(unsigned char *blk, int len, ctx->iv1 = iv1; } -void blowfish_lsb_encrypt_ecb(unsigned char *blk, int len, - BlowfishContext * ctx) +void blowfish_lsb_encrypt_ecb(void *vblk, int len, BlowfishContext * ctx) { + unsigned char *blk = (unsigned char *)vblk; word32 xL, xR, out[2]; assert((len & 7) == 0); @@ -472,9 +472,11 @@ void blowfish_initkey(BlowfishContext *ctx) } void blowfish_expandkey(BlowfishContext * ctx, - const unsigned char *key, short keybytes, - const unsigned char *salt, short saltbytes) + const void *vkey, short keybytes, + const void *vsalt, short saltbytes) { + const unsigned char *key = (const unsigned char *)vkey; + const unsigned char *salt = (const unsigned char *)vsalt; word32 *S0 = ctx->S0; word32 *S1 = ctx->S1; word32 *S2 = ctx->S2; @@ -570,26 +572,27 @@ void blowfish_free_context(void *handle) sfree(handle); } -static void blowfish_key(void *handle, unsigned char *key) +static void blowfish_key(void *handle, const void *key) { BlowfishContext *ctx = (BlowfishContext *)handle; blowfish_setkey(ctx, key, 16); } -static void blowfish256_key(void *handle, unsigned char *key) +static void blowfish256_key(void *handle, const void *key) { BlowfishContext *ctx = (BlowfishContext *)handle; blowfish_setkey(ctx, key, 32); } -static void blowfish_iv(void *handle, unsigned char *key) +static void blowfish_iv(void *handle, const void *viv) { + const unsigned char *iv = (const unsigned char *)viv; BlowfishContext *ctx = (BlowfishContext *)handle; - ctx->iv0 = GET_32BIT_MSB_FIRST(key); - ctx->iv1 = GET_32BIT_MSB_FIRST(key + 4); + ctx->iv0 = GET_32BIT_MSB_FIRST(iv); + ctx->iv1 = GET_32BIT_MSB_FIRST(iv + 4); } -static void blowfish_sesskey(void *handle, unsigned char *key) +static void blowfish_sesskey(void *handle, const void *key) { BlowfishContext *ctx = (BlowfishContext *)handle; blowfish_setkey(ctx, key, SSH_SESSION_KEY_LENGTH); @@ -598,36 +601,31 @@ static void blowfish_sesskey(void *handle, unsigned char *key) ctx[1] = ctx[0]; /* structure copy */ } -static void blowfish_ssh1_encrypt_blk(void *handle, unsigned char *blk, - int len) +static void blowfish_ssh1_encrypt_blk(void *handle, void *blk, int len) { BlowfishContext *ctx = (BlowfishContext *)handle; blowfish_lsb_encrypt_cbc(blk, len, ctx); } -static void blowfish_ssh1_decrypt_blk(void *handle, unsigned char *blk, - int len) +static void blowfish_ssh1_decrypt_blk(void *handle, void *blk, int len) { BlowfishContext *ctx = (BlowfishContext *)handle; blowfish_lsb_decrypt_cbc(blk, len, ctx+1); } -static void blowfish_ssh2_encrypt_blk(void *handle, unsigned char *blk, - int len) +static void blowfish_ssh2_encrypt_blk(void *handle, void *blk, int len) { BlowfishContext *ctx = (BlowfishContext *)handle; blowfish_msb_encrypt_cbc(blk, len, ctx); } -static void blowfish_ssh2_decrypt_blk(void *handle, unsigned char *blk, - int len) +static void blowfish_ssh2_decrypt_blk(void *handle, void *blk, int len) { BlowfishContext *ctx = (BlowfishContext *)handle; blowfish_msb_decrypt_cbc(blk, len, ctx); } -static void blowfish_ssh2_sdctr(void *handle, unsigned char *blk, - int len) +static void blowfish_ssh2_sdctr(void *handle, void *blk, int len) { BlowfishContext *ctx = (BlowfishContext *)handle; blowfish_msb_sdctr(blk, len, ctx); diff --git a/sshblowf.h b/sshblowf.h index eb6a48c1..e2364521 100644 --- a/sshblowf.h +++ b/sshblowf.h @@ -9,7 +9,6 @@ void *blowfish_make_context(void); void blowfish_free_context(void *handle); void blowfish_initkey(BlowfishContext *ctx); void blowfish_expandkey(BlowfishContext *ctx, - const unsigned char *key, short keybytes, - const unsigned char *salt, short saltbytes); -void blowfish_lsb_encrypt_ecb(unsigned char *blk, int len, - BlowfishContext *ctx); + const void *key, short keybytes, + const void *salt, short saltbytes); +void blowfish_lsb_encrypt_ecb(void *blk, int len, BlowfishContext *ctx); diff --git a/sshbn.c b/sshbn.c index 5b918100..39f8dfd8 100644 --- a/sshbn.c +++ b/sshbn.c @@ -1404,8 +1404,9 @@ void decbn(Bignum bn) bn[i]--; } -Bignum bignum_from_bytes(const unsigned char *data, int nbytes) +Bignum bignum_from_bytes(const void *vdata, int nbytes) { + const unsigned char *data = (const unsigned char *)vdata; Bignum result; int w, i; @@ -1426,8 +1427,9 @@ Bignum bignum_from_bytes(const unsigned char *data, int nbytes) return result; } -Bignum bignum_from_bytes_le(const unsigned char *data, int nbytes) +Bignum bignum_from_bytes_le(const void *vdata, int nbytes) { + const unsigned char *data = (const unsigned char *)vdata; Bignum result; int w, i; diff --git a/sshccp.c b/sshccp.c index be5e9acf..9345c6fa 100644 --- a/sshccp.c +++ b/sshccp.c @@ -1000,14 +1000,15 @@ static void ccp_free_context(void *vctx) sfree(ctx); } -static void ccp_iv(void *vctx, unsigned char *iv) +static void ccp_iv(void *vctx, const void *iv) { /* struct ccp_context *ctx = (struct ccp_context *)vctx; */ /* IV is set based on the sequence number */ } -static void ccp_key(void *vctx, unsigned char *key) +static void ccp_key(void *vctx, const void *vkey) { + const unsigned char *key = (const unsigned char *)vkey; struct ccp_context *ctx = (struct ccp_context *)vctx; /* Initialise the a_cipher (for decrypting lengths) with the first 256 bits */ chacha20_key(&ctx->a_cipher, key + 32); @@ -1015,19 +1016,19 @@ static void ccp_key(void *vctx, unsigned char *key) chacha20_key(&ctx->b_cipher, key); } -static void ccp_encrypt(void *vctx, unsigned char *blk, int len) +static void ccp_encrypt(void *vctx, void *blk, int len) { struct ccp_context *ctx = (struct ccp_context *)vctx; chacha20_encrypt(&ctx->b_cipher, blk, len); } -static void ccp_decrypt(void *vctx, unsigned char *blk, int len) +static void ccp_decrypt(void *vctx, void *blk, int len) { struct ccp_context *ctx = (struct ccp_context *)vctx; chacha20_decrypt(&ctx->b_cipher, blk, len); } -static void ccp_length_op(struct ccp_context *ctx, unsigned char *blk, int len, +static void ccp_length_op(struct ccp_context *ctx, void *blk, int len, unsigned long seq) { unsigned char iv[8]; @@ -1044,7 +1045,7 @@ static void ccp_length_op(struct ccp_context *ctx, unsigned char *blk, int len, smemclr(iv, sizeof(iv)); } -static void ccp_encrypt_length(void *vctx, unsigned char *blk, int len, +static void ccp_encrypt_length(void *vctx, void *blk, int len, unsigned long seq) { struct ccp_context *ctx = (struct ccp_context *)vctx; @@ -1052,7 +1053,7 @@ static void ccp_encrypt_length(void *vctx, unsigned char *blk, int len, chacha20_encrypt(&ctx->a_cipher, blk, len); } -static void ccp_decrypt_length(void *vctx, unsigned char *blk, int len, +static void ccp_decrypt_length(void *vctx, void *blk, int len, unsigned long seq) { struct ccp_context *ctx = (struct ccp_context *)vctx; diff --git a/sshdes.c b/sshdes.c index 13487fcd..585deb7f 100644 --- a/sshdes.c +++ b/sshdes.c @@ -774,8 +774,9 @@ static void des3_free_context(void *handle) /* used for both 3DES and DES */ sfree(handle); } -static void des3_key(void *handle, unsigned char *key) +static void des3_key(void *handle, const void *vkey) { + const unsigned char *key = (const unsigned char *)vkey; DESContext *keys = (DESContext *) handle; des_key_setup(GET_32BIT_MSB_FIRST(key), GET_32BIT_MSB_FIRST(key + 4), &keys[0]); @@ -785,71 +786,75 @@ static void des3_key(void *handle, unsigned char *key) GET_32BIT_MSB_FIRST(key + 20), &keys[2]); } -static void des3_iv(void *handle, unsigned char *key) +static void des3_iv(void *handle, const void *viv) { + const unsigned char *iv = (const unsigned char *)viv; DESContext *keys = (DESContext *) handle; - keys[0].iv0 = GET_32BIT_MSB_FIRST(key); - keys[0].iv1 = GET_32BIT_MSB_FIRST(key + 4); + keys[0].iv0 = GET_32BIT_MSB_FIRST(iv); + keys[0].iv1 = GET_32BIT_MSB_FIRST(iv + 4); } -static void des_key(void *handle, unsigned char *key) +static void des_key(void *handle, const void *vkey) { + const unsigned char *key = (const unsigned char *)vkey; DESContext *keys = (DESContext *) handle; des_key_setup(GET_32BIT_MSB_FIRST(key), GET_32BIT_MSB_FIRST(key + 4), &keys[0]); } -static void des3_sesskey(void *handle, unsigned char *key) +static void des3_sesskey(void *handle, const void *key) { DESContext *keys = (DESContext *) handle; des3_key(keys, key); des3_key(keys+3, key); } -static void des3_encrypt_blk(void *handle, unsigned char *blk, int len) +static void des3_encrypt_blk(void *handle, void *blk, int len) { DESContext *keys = (DESContext *) handle; des_3cbc_encrypt(blk, len, keys); } -static void des3_decrypt_blk(void *handle, unsigned char *blk, int len) +static void des3_decrypt_blk(void *handle, void *blk, int len) { DESContext *keys = (DESContext *) handle; des_3cbc_decrypt(blk, len, keys+3); } -static void des3_ssh2_encrypt_blk(void *handle, unsigned char *blk, int len) +static void des3_ssh2_encrypt_blk(void *handle, void *blk, int len) { DESContext *keys = (DESContext *) handle; des_cbc3_encrypt(blk, len, keys); } -static void des3_ssh2_decrypt_blk(void *handle, unsigned char *blk, int len) +static void des3_ssh2_decrypt_blk(void *handle, void *blk, int len) { DESContext *keys = (DESContext *) handle; des_cbc3_decrypt(blk, len, keys); } -static void des3_ssh2_sdctr(void *handle, unsigned char *blk, int len) +static void des3_ssh2_sdctr(void *handle, void *blk, int len) { DESContext *keys = (DESContext *) handle; des_sdctr3(blk, len, keys); } -static void des_ssh2_encrypt_blk(void *handle, unsigned char *blk, int len) +static void des_ssh2_encrypt_blk(void *handle, void *blk, int len) { DESContext *keys = (DESContext *) handle; des_cbc_encrypt(blk, len, keys); } -static void des_ssh2_decrypt_blk(void *handle, unsigned char *blk, int len) +static void des_ssh2_decrypt_blk(void *handle, void *blk, int len) { DESContext *keys = (DESContext *) handle; des_cbc_decrypt(blk, len, keys); } -void des3_decrypt_pubkey(unsigned char *key, unsigned char *blk, int len) +void des3_decrypt_pubkey(const void *vkey, void *vblk, int len) { + const unsigned char *key = (const unsigned char *)vkey; + unsigned char *blk = (unsigned char *)vblk; DESContext ourkeys[3]; des_key_setup(GET_32BIT_MSB_FIRST(key), GET_32BIT_MSB_FIRST(key + 4), &ourkeys[0]); @@ -861,8 +866,10 @@ void des3_decrypt_pubkey(unsigned char *key, unsigned char *blk, int len) smemclr(ourkeys, sizeof(ourkeys)); } -void des3_encrypt_pubkey(unsigned char *key, unsigned char *blk, int len) +void des3_encrypt_pubkey(const void *vkey, void *vblk, int len) { + const unsigned char *key = (const unsigned char *)vkey; + unsigned char *blk = (unsigned char *)vblk; DESContext ourkeys[3]; des_key_setup(GET_32BIT_MSB_FIRST(key), GET_32BIT_MSB_FIRST(key + 4), &ourkeys[0]); @@ -874,9 +881,12 @@ void des3_encrypt_pubkey(unsigned char *key, unsigned char *blk, int len) smemclr(ourkeys, sizeof(ourkeys)); } -void des3_decrypt_pubkey_ossh(unsigned char *key, unsigned char *iv, - unsigned char *blk, int len) +void des3_decrypt_pubkey_ossh(const void *vkey, const void *viv, + void *vblk, int len) { + const unsigned char *key = (const unsigned char *)vkey; + const unsigned char *iv = (const unsigned char *)viv; + unsigned char *blk = (unsigned char *)vblk; DESContext ourkeys[3]; des_key_setup(GET_32BIT_MSB_FIRST(key), GET_32BIT_MSB_FIRST(key + 4), &ourkeys[0]); @@ -890,9 +900,12 @@ void des3_decrypt_pubkey_ossh(unsigned char *key, unsigned char *iv, smemclr(ourkeys, sizeof(ourkeys)); } -void des3_encrypt_pubkey_ossh(unsigned char *key, unsigned char *iv, - unsigned char *blk, int len) +void des3_encrypt_pubkey_ossh(const void *vkey, const void *viv, + void *vblk, int len) { + const unsigned char *key = (const unsigned char *)vkey; + const unsigned char *iv = (const unsigned char *)viv; + unsigned char *blk = (unsigned char *)vblk; DESContext ourkeys[3]; des_key_setup(GET_32BIT_MSB_FIRST(key), GET_32BIT_MSB_FIRST(key + 4), &ourkeys[0]); @@ -906,8 +919,9 @@ void des3_encrypt_pubkey_ossh(unsigned char *key, unsigned char *iv, smemclr(ourkeys, sizeof(ourkeys)); } -static void des_keysetup_xdmauth(const unsigned char *keydata, DESContext *dc) +static void des_keysetup_xdmauth(const void *vkeydata, DESContext *dc) { + const unsigned char *keydata = (const unsigned char *)vkeydata; unsigned char key[8]; int i, nbits, j; unsigned int bits; @@ -929,16 +943,14 @@ static void des_keysetup_xdmauth(const unsigned char *keydata, DESContext *dc) des_key_setup(GET_32BIT_MSB_FIRST(key), GET_32BIT_MSB_FIRST(key + 4), dc); } -void des_encrypt_xdmauth(const unsigned char *keydata, - unsigned char *blk, int len) +void des_encrypt_xdmauth(const void *keydata, void *blk, int len) { DESContext dc; des_keysetup_xdmauth(keydata, &dc); des_cbc_encrypt(blk, len, &dc); } -void des_decrypt_xdmauth(const unsigned char *keydata, - unsigned char *blk, int len) +void des_decrypt_xdmauth(const void *keydata, void *blk, int len) { DESContext dc; des_keysetup_xdmauth(keydata, &dc); @@ -1011,20 +1023,20 @@ const struct ssh_cipher ssh_3des = { 8, "triple-DES inner-CBC" }; -static void des_sesskey(void *handle, unsigned char *key) +static void des_sesskey(void *handle, const void *key) { DESContext *keys = (DESContext *) handle; des_key(keys, key); des_key(keys+1, key); } -static void des_encrypt_blk(void *handle, unsigned char *blk, int len) +static void des_encrypt_blk(void *handle, void *blk, int len) { DESContext *keys = (DESContext *) handle; des_cbc_encrypt(blk, len, keys); } -static void des_decrypt_blk(void *handle, unsigned char *blk, int len) +static void des_decrypt_blk(void *handle, void *blk, int len) { DESContext *keys = (DESContext *) handle; des_cbc_decrypt(blk, len, keys+1); diff --git a/sshdss.c b/sshdss.c index 5c53be82..d0f54f6e 100644 --- a/sshdss.c +++ b/sshdss.c @@ -37,7 +37,7 @@ static Bignum getmp(const char **data, int *datalen) return NULL; if (p[0] & 0x80) return NULL; /* negative mp */ - b = bignum_from_bytes((const unsigned char *)p, length); + b = bignum_from_bytes(p, length); return b; } @@ -48,7 +48,7 @@ static Bignum get160(const char **data, int *datalen) if (*datalen < 20) return NULL; - b = bignum_from_bytes((const unsigned char *)*data, 20); + b = bignum_from_bytes(*data, 20); *data += 20; *datalen -= 20; @@ -58,8 +58,9 @@ static Bignum get160(const char **data, int *datalen) static void dss_freekey(void *key); /* forward reference */ static void *dss_newkey(const struct ssh_signkey *self, - const char *data, int len) + const void *vdata, int len) { + const char *data = (const char *)vdata; const char *p; int slen; struct dss_key *dss; @@ -163,10 +164,11 @@ static char *dss_fmtkey(void *key) return p; } -static int dss_verifysig(void *key, const char *sig, int siglen, - const char *data, int datalen) +static int dss_verifysig(void *key, const void *vsig, int siglen, + const void *data, int datalen) { struct dss_key *dss = (struct dss_key *) key; + const char *sig = (const char *)vsig; const char *p; int slen; char hash[20]; @@ -290,8 +292,8 @@ static void dss_private_blob(void *key, BinarySink *bs) } static void *dss_createkey(const struct ssh_signkey *self, - const unsigned char *pub_blob, int pub_len, - const unsigned char *priv_blob, int priv_len) + const void *pub_blob, int pub_len, + const void *priv_blob, int priv_len) { struct dss_key *dss; const char *pb = (const char *) priv_blob; @@ -301,7 +303,7 @@ static void *dss_createkey(const struct ssh_signkey *self, unsigned char digest[20]; Bignum ytest; - dss = dss_newkey(self, (char *) pub_blob, pub_len); + dss = dss_newkey(self, pub_blob, pub_len); if (!dss) return NULL; dss->x = getmp(&pb, &priv_len); @@ -382,7 +384,7 @@ static int dss_pubkey_bits(const struct ssh_signkey *self, struct dss_key *dss; int ret; - dss = dss_newkey(self, (const char *) blob, len); + dss = dss_newkey(self, blob, len); if (!dss) return -1; ret = bignum_bitcount(dss->p); @@ -511,7 +513,7 @@ Bignum *dss_gen_k(const char *id_string, Bignum modulus, Bignum private_key, } } -static void dss_sign(void *key, const char *data, int datalen, +static void dss_sign(void *key, const void *data, int datalen, BinarySink *bs) { struct dss_key *dss = (struct dss_key *) key; diff --git a/sshecc.c b/sshecc.c index 41b8b6cf..b9d53e61 100644 --- a/sshecc.c +++ b/sshecc.c @@ -1618,7 +1618,7 @@ static Bignum getmp(const char **data, int *datalen) return NULL; if (p[0] & 0x80) return NULL; /* negative mp */ - return bignum_from_bytes((unsigned char *)p, length); + return bignum_from_bytes(p, length); } static Bignum getmp_le(const char **data, int *datalen) @@ -1629,7 +1629,7 @@ static Bignum getmp_le(const char **data, int *datalen) getstring(data, datalen, &p, &length); if (!p) return NULL; - return bignum_from_bytes_le((const unsigned char *)p, length); + return bignum_from_bytes_le(p, length); } static int decodepoint_ed(const char *p, int length, struct ec_point *point) @@ -1692,9 +1692,9 @@ static int decodepoint(const char *p, int length, struct ec_point *point) return 0; } length = length / 2; - point->x = bignum_from_bytes((const unsigned char *)p, length); + point->x = bignum_from_bytes(p, length); p += length; - point->y = bignum_from_bytes((const unsigned char *)p, length); + point->y = bignum_from_bytes(p, length); point->z = NULL; /* Verify the point is on the curve */ @@ -1749,10 +1749,11 @@ static void ecdsa_freekey(void *key) } static void *ecdsa_newkey(const struct ssh_signkey *self, - const char *data, int len) + const void *vdata, int len) { const struct ecsign_extra *extra = (const struct ecsign_extra *)self->extra; + const char *data = (const char *)vdata; const char *p; int slen; struct ec_key *ec; @@ -1905,14 +1906,14 @@ static void ecdsa_private_blob(void *key, BinarySink *bs) } static void *ecdsa_createkey(const struct ssh_signkey *self, - const unsigned char *pub_blob, int pub_len, - const unsigned char *priv_blob, int priv_len) + const void *pub_blob, int pub_len, + const void *priv_blob, int priv_len) { struct ec_key *ec; struct ec_point *publicKey; const char *pb = (const char *) priv_blob; - ec = (struct ec_key*)ecdsa_newkey(self, (const char *) pub_blob, pub_len); + ec = (struct ec_key*)ecdsa_newkey(self, pub_blob, pub_len); if (!ec) { return NULL; } @@ -1984,7 +1985,7 @@ static void *ed25519_openssh_createkey(const struct ssh_signkey *self, return NULL; } - ec->privateKey = bignum_from_bytes_le((const unsigned char *)q, 32); + ec->privateKey = bignum_from_bytes_le(q, 32); /* Check that private key generates public key */ publicKey = ec_public(ec->privateKey, ec->publicKey.curve); @@ -2148,7 +2149,7 @@ static int ecdsa_pubkey_bits(const struct ssh_signkey *self, struct ec_key *ec; int ret; - ec = (struct ec_key*)ecdsa_newkey(self, (const char *) blob, len); + ec = (struct ec_key*)ecdsa_newkey(self, blob, len); if (!ec) return -1; ret = ec->publicKey.curve->fieldBits; @@ -2157,10 +2158,12 @@ static int ecdsa_pubkey_bits(const struct ssh_signkey *self, return ret; } -static int ecdsa_verifysig(void *key, const char *sig, int siglen, - const char *data, int datalen) +static int ecdsa_verifysig(void *key, const void *vsig, int siglen, + const void *vdata, int datalen) { struct ec_key *ec = (struct ec_key *) key; + const char *sig = (const char *)vsig; + const char *data = (const char *)vdata; const struct ecsign_extra *extra = (const struct ecsign_extra *)ec->signalg->extra; const char *p; @@ -2307,7 +2310,7 @@ static int ecdsa_verifysig(void *key, const char *sig, int siglen, return ret; } -static void ecdsa_sign(void *key, const char *data, int datalen, +static void ecdsa_sign(void *key, const void *data, int datalen, BinarySink *bs) { struct ec_key *ec = (struct ec_key *) key; diff --git a/sshrsa.c b/sshrsa.c index da5cebbf..e8ea5014 100644 --- a/sshrsa.c +++ b/sshrsa.c @@ -524,16 +524,17 @@ static Bignum getmp(const char **data, int *datalen) getstring(data, datalen, &p, &length); if (!p) return NULL; - b = bignum_from_bytes((unsigned char *)p, length); + b = bignum_from_bytes(p, length); return b; } static void rsa2_freekey(void *key); /* forward reference */ static void *rsa2_newkey(const struct ssh_signkey *self, - const char *data, int len) + const void *vdata, int len) { const char *p; + const char *data = (const char *)vdata; int slen; struct RSAKey *rsa; @@ -597,13 +598,13 @@ static void rsa2_private_blob(void *key, BinarySink *bs) } static void *rsa2_createkey(const struct ssh_signkey *self, - const unsigned char *pub_blob, int pub_len, - const unsigned char *priv_blob, int priv_len) + const void *pub_blob, int pub_len, + const void *priv_blob, int priv_len) { struct RSAKey *rsa; const char *pb = (const char *) priv_blob; - rsa = rsa2_newkey(self, (char *) pub_blob, pub_len); + rsa = rsa2_newkey(self, pub_blob, pub_len); rsa->private_exponent = getmp(&pb, &priv_len); rsa->p = getmp(&pb, &priv_len); rsa->q = getmp(&pb, &priv_len); @@ -665,7 +666,7 @@ static int rsa2_pubkey_bits(const struct ssh_signkey *self, struct RSAKey *rsa; int ret; - rsa = rsa2_newkey(self, (const char *) blob, len); + rsa = rsa2_newkey(self, blob, len); if (!rsa) return -1; ret = bignum_bitcount(rsa->modulus); @@ -705,10 +706,11 @@ static const unsigned char asn1_weird_stuff[] = { #define ASN1_LEN ( (int) sizeof(asn1_weird_stuff) ) -static int rsa2_verifysig(void *key, const char *sig, int siglen, - const char *data, int datalen) +static int rsa2_verifysig(void *key, const void *vsig, int siglen, + const void *data, int datalen) { struct RSAKey *rsa = (struct RSAKey *) key; + const char *sig = (const char *)vsig; Bignum in, out; const char *p; int slen; @@ -755,7 +757,7 @@ static int rsa2_verifysig(void *key, const char *sig, int siglen, return ret; } -static void rsa2_sign(void *key, const char *data, int datalen, +static void rsa2_sign(void *key, const void *data, int datalen, BinarySink *bs) { struct RSAKey *rsa = (struct RSAKey *) key; @@ -812,7 +814,7 @@ const struct ssh_signkey ssh_rsa = { NULL, }; -void *ssh_rsakex_newkey(char *data, int len) +void *ssh_rsakex_newkey(const void *data, int len) { return rsa2_newkey(&ssh_rsa, data, len); } diff --git a/telnet.c b/telnet.c index 0857113c..eaaa48c7 100644 --- a/telnet.c +++ b/telnet.c @@ -206,7 +206,7 @@ typedef struct telnet_tag { #define SB_DELTA 1024 -static void c_write(Telnet telnet, const char *buf, int len) +static void c_write(Telnet telnet, const void *buf, int len) { int backlog; backlog = from_backend(telnet->frontend, 0, buf, len); @@ -236,7 +236,7 @@ static void send_opt(Telnet telnet, int cmd, int option) b[0] = IAC; b[1] = cmd; b[2] = option; - telnet->bufsize = sk_write(telnet->s, (char *)b, 3); + telnet->bufsize = sk_write(telnet->s, b, 3); log_option(telnet, "client", cmd, option); } @@ -377,7 +377,7 @@ static void process_subneg(Telnet telnet) n = 4 + strlen(termspeed); b[n] = IAC; b[n + 1] = SE; - telnet->bufsize = sk_write(telnet->s, (char *)b, n + 2); + telnet->bufsize = sk_write(telnet->s, b, n + 2); logevent(telnet->frontend, "server:\tSB TSPEED SEND"); logbuf = dupprintf("client:\tSB TSPEED IS %s", termspeed); logevent(telnet->frontend, logbuf); @@ -401,7 +401,7 @@ static void process_subneg(Telnet telnet) termtype[n]); b[n + 4] = IAC; b[n + 5] = SE; - telnet->bufsize = sk_write(telnet->s, (char *)b, n + 6); + telnet->bufsize = sk_write(telnet->s, b, n + 6); b[n + 4] = 0; logevent(telnet->frontend, "server:\tSB TTYPE SEND"); logbuf = dupprintf("client:\tSB TTYPE IS %s", b + 4); @@ -491,7 +491,7 @@ static void process_subneg(Telnet telnet) } b[n++] = IAC; b[n++] = SE; - telnet->bufsize = sk_write(telnet->s, (char *)b, n); + telnet->bufsize = sk_write(telnet->s, b, n); if (n == 6) { logbuf = dupprintf("client:\tSB %s IS ", telopt(telnet->sb_opt)); @@ -853,11 +853,11 @@ static int telnet_send(void *handle, const char *buf, int len) while (p < end && iswritable(*p)) p++; - telnet->bufsize = sk_write(telnet->s, (char *)q, p - q); + telnet->bufsize = sk_write(telnet->s, q, p - q); while (p < end && !iswritable(*p)) { telnet->bufsize = - sk_write(telnet->s, (char *)(*p == IAC ? iac : cr), 2); + sk_write(telnet->s, *p == IAC ? iac : cr, 2); p++; } } @@ -903,7 +903,7 @@ static void telnet_size(void *handle, int width, int height) if (b[n-1] == IAC) b[n++] = IAC; /* duplicate any IAC byte occurs */ b[n++] = IAC; b[n++] = SE; - telnet->bufsize = sk_write(telnet->s, (char *)b, n); + telnet->bufsize = sk_write(telnet->s, b, n); logbuf = dupprintf("client:\tSB NAWS %d,%d", telnet->term_width, telnet->term_height); logevent(telnet->frontend, logbuf); @@ -925,51 +925,51 @@ static void telnet_special(void *handle, Telnet_Special code) switch (code) { case TS_AYT: b[1] = AYT; - telnet->bufsize = sk_write(telnet->s, (char *)b, 2); + telnet->bufsize = sk_write(telnet->s, b, 2); break; case TS_BRK: b[1] = BREAK; - telnet->bufsize = sk_write(telnet->s, (char *)b, 2); + telnet->bufsize = sk_write(telnet->s, b, 2); break; case TS_EC: b[1] = EC; - telnet->bufsize = sk_write(telnet->s, (char *)b, 2); + telnet->bufsize = sk_write(telnet->s, b, 2); break; case TS_EL: b[1] = EL; - telnet->bufsize = sk_write(telnet->s, (char *)b, 2); + telnet->bufsize = sk_write(telnet->s, b, 2); break; case TS_GA: b[1] = GA; - telnet->bufsize = sk_write(telnet->s, (char *)b, 2); + telnet->bufsize = sk_write(telnet->s, b, 2); break; case TS_NOP: b[1] = NOP; - telnet->bufsize = sk_write(telnet->s, (char *)b, 2); + telnet->bufsize = sk_write(telnet->s, b, 2); break; case TS_ABORT: b[1] = ABORT; - telnet->bufsize = sk_write(telnet->s, (char *)b, 2); + telnet->bufsize = sk_write(telnet->s, b, 2); break; case TS_AO: b[1] = AO; - telnet->bufsize = sk_write(telnet->s, (char *)b, 2); + telnet->bufsize = sk_write(telnet->s, b, 2); break; case TS_IP: b[1] = IP; - telnet->bufsize = sk_write(telnet->s, (char *)b, 2); + telnet->bufsize = sk_write(telnet->s, b, 2); break; case TS_SUSP: b[1] = SUSP; - telnet->bufsize = sk_write(telnet->s, (char *)b, 2); + telnet->bufsize = sk_write(telnet->s, b, 2); break; case TS_EOR: b[1] = EOR; - telnet->bufsize = sk_write(telnet->s, (char *)b, 2); + telnet->bufsize = sk_write(telnet->s, b, 2); break; case TS_EOF: b[1] = xEOF; - telnet->bufsize = sk_write(telnet->s, (char *)b, 2); + telnet->bufsize = sk_write(telnet->s, b, 2); break; case TS_EOL: /* In BINARY mode, CR-LF becomes just CR - @@ -981,8 +981,8 @@ static void telnet_special(void *handle, Telnet_Special code) break; case TS_SYNCH: b[1] = DM; - telnet->bufsize = sk_write(telnet->s, (char *)b, 1); - telnet->bufsize = sk_write_oob(telnet->s, (char *)(b + 1), 1); + telnet->bufsize = sk_write(telnet->s, b, 1); + telnet->bufsize = sk_write_oob(telnet->s, b + 1, 1); break; case TS_RECHO: if (telnet->opt_states[o_echo.index] == INACTIVE || @@ -1000,7 +1000,7 @@ static void telnet_special(void *handle, Telnet_Special code) case TS_PING: if (telnet->opt_states[o_they_sga.index] == ACTIVE) { b[1] = NOP; - telnet->bufsize = sk_write(telnet->s, (char *)b, 2); + telnet->bufsize = sk_write(telnet->s, b, 2); } break; default: diff --git a/terminal.c b/terminal.c index e52e20d8..a368b23f 100644 --- a/terminal.c +++ b/terminal.c @@ -6629,7 +6629,7 @@ int term_ldisc(Terminal *term, int option) return FALSE; } -int term_data(Terminal *term, int is_stderr, const char *data, int len) +int term_data(Terminal *term, int is_stderr, const void *data, int len) { bufchain_add(&term->inbuf, data, len); @@ -6673,8 +6673,9 @@ int term_data(Terminal *term, int is_stderr, const char *data, int len) * The only control character that should be honoured is \n (which * will behave as a CRLF). */ -int term_data_untrusted(Terminal *term, const char *data, int len) +int term_data_untrusted(Terminal *term, const void *vdata, int len) { + const char *data = (const char *)vdata; int i; /* FIXME: more sophisticated checking? */ for (i = 0; i < len; i++) { diff --git a/unix/gtkwin.c b/unix/gtkwin.c index 6638f0b3..5b84c7c9 100644 --- a/unix/gtkwin.c +++ b/unix/gtkwin.c @@ -304,13 +304,13 @@ char *get_ttymode(void *frontend, const char *mode) return term_get_ttymode(inst->term, mode); } -int from_backend(void *frontend, int is_stderr, const char *data, int len) +int from_backend(void *frontend, int is_stderr, const void *data, int len) { struct gui_data *inst = (struct gui_data *)frontend; return term_data(inst->term, is_stderr, data, len); } -int from_backend_untrusted(void *frontend, const char *data, int len) +int from_backend_untrusted(void *frontend, const void *data, int len) { struct gui_data *inst = (struct gui_data *)frontend; return term_data_untrusted(inst->term, data, len); diff --git a/unix/uxnet.c b/unix/uxnet.c index e4782652..66fa208a 100644 --- a/unix/uxnet.c +++ b/unix/uxnet.c @@ -509,8 +509,8 @@ static void sk_tcp_flush(Socket s) } static void sk_tcp_close(Socket s); -static int sk_tcp_write(Socket s, const char *data, int len); -static int sk_tcp_write_oob(Socket s, const char *data, int len); +static int sk_tcp_write(Socket s, const void *data, int len); +static int sk_tcp_write_oob(Socket s, const void *data, int len); static void sk_tcp_write_eof(Socket s); static void sk_tcp_set_frozen(Socket s, int is_frozen); static char *sk_tcp_peer_info(Socket s); @@ -1189,7 +1189,7 @@ void try_send(Actual_Socket s) uxsel_tell(s); } -static int sk_tcp_write(Socket sock, const char *buf, int len) +static int sk_tcp_write(Socket sock, const void *buf, int len) { Actual_Socket s = (Actual_Socket) sock; @@ -1215,7 +1215,7 @@ static int sk_tcp_write(Socket sock, const char *buf, int len) return bufchain_size(&s->output_data); } -static int sk_tcp_write_oob(Socket sock, const char *buf, int len) +static int sk_tcp_write_oob(Socket sock, const void *buf, int len) { Actual_Socket s = (Actual_Socket) sock; diff --git a/unix/uxpgnt.c b/unix/uxpgnt.c index b8244cec..277d31d2 100644 --- a/unix/uxpgnt.c +++ b/unix/uxpgnt.c @@ -93,7 +93,7 @@ FontSpec *platform_default_fontspec(const char *name) { return fontspec_new(""); Filename *platform_default_filename(const char *name) { return filename_from_str(""); } char *x_get_default(const char *key) { return NULL; } void log_eventlog(void *handle, const char *event) {} -int from_backend(void *frontend, int is_stderr, const char *data, int datalen) +int from_backend(void *frontend, int is_stderr, const void *data, int datalen) { assert(!"only here to satisfy notional call from backend_socket_log"); } /* @@ -156,7 +156,8 @@ static int time_to_die = FALSE; * used, because in LIFE_X11 mode we connect to the X server using a * straightforward Socket and don't try to create an ersatz SSH * forwarding too. */ -int sshfwd_write(struct ssh_channel *c, char *data, int len) { return 0; } +int sshfwd_write(struct ssh_channel *c, const void *data, int len) +{ return 0; } void sshfwd_write_eof(struct ssh_channel *c) { } void sshfwd_unclean_close(struct ssh_channel *c, const char *err) { } void sshfwd_unthrottle(struct ssh_channel *c, int bufsize) {} diff --git a/unix/uxplink.c b/unix/uxplink.c index c042f459..a8d35b7a 100644 --- a/unix/uxplink.c +++ b/unix/uxplink.c @@ -402,7 +402,7 @@ int try_output(int is_stderr) } int from_backend(void *frontend_handle, int is_stderr, - const char *data, int len) + const void *data, int len) { if (is_stderr) { bufchain_add(&stderr_data, data, len); @@ -414,7 +414,7 @@ int from_backend(void *frontend_handle, int is_stderr, } } -int from_backend_untrusted(void *frontend_handle, const char *data, int len) +int from_backend_untrusted(void *frontend_handle, const void *data, int len) { /* * No "untrusted" output should get here (the way the code is diff --git a/unix/uxproxy.c b/unix/uxproxy.c index d3a82fa4..95426e3e 100644 --- a/unix/uxproxy.c +++ b/unix/uxproxy.c @@ -175,7 +175,7 @@ static int localproxy_try_send(Local_Proxy_Socket ps) return sent; } -static int sk_localproxy_write (Socket s, const char *data, int len) +static int sk_localproxy_write (Socket s, const void *data, int len) { Local_Proxy_Socket ps = (Local_Proxy_Socket) s; @@ -188,7 +188,7 @@ static int sk_localproxy_write (Socket s, const char *data, int len) return bufchain_size(&ps->pending_output_data); } -static int sk_localproxy_write_oob (Socket s, const char *data, int len) +static int sk_localproxy_write_oob (Socket s, const void *data, int len) { /* * oob data is treated as inband; nasty, but nothing really diff --git a/windows/window.c b/windows/window.c index 126a0440..d6a67d42 100644 --- a/windows/window.c +++ b/windows/window.c @@ -3083,7 +3083,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, */ term_seen_key_event(term); if (ldisc) - ldisc_send(ldisc, (char *)buf, len, 1); + ldisc_send(ldisc, buf, len, 1); show_mouseptr(0); } } @@ -5921,12 +5921,12 @@ void frontend_keypress(void *handle) return; } -int from_backend(void *frontend, int is_stderr, const char *data, int len) +int from_backend(void *frontend, int is_stderr, const void *data, int len) { return term_data(term, is_stderr, data, len); } -int from_backend_untrusted(void *frontend, const char *data, int len) +int from_backend_untrusted(void *frontend, const void *data, int len) { return term_data_untrusted(term, data, len); } diff --git a/windows/winhsock.c b/windows/winhsock.c index 4cd4744a..9b725332 100644 --- a/windows/winhsock.c +++ b/windows/winhsock.c @@ -137,14 +137,14 @@ static void sk_handle_close(Socket s) sfree(ps); } -static int sk_handle_write(Socket s, const char *data, int len) +static int sk_handle_write(Socket s, const void *data, int len) { Handle_Socket ps = (Handle_Socket) s; return handle_write(ps->send_h, data, len); } -static int sk_handle_write_oob(Socket s, const char *data, int len) +static int sk_handle_write_oob(Socket s, const void *data, int len) { /* * oob data is treated as inband; nasty, but nothing really diff --git a/windows/winnet.c b/windows/winnet.c index dc52efe5..3f2fe4cc 100644 --- a/windows/winnet.c +++ b/windows/winnet.c @@ -931,8 +931,8 @@ static void sk_tcp_flush(Socket s) } static void sk_tcp_close(Socket s); -static int sk_tcp_write(Socket s, const char *data, int len); -static int sk_tcp_write_oob(Socket s, const char *data, int len); +static int sk_tcp_write(Socket s, const void *data, int len); +static int sk_tcp_write_oob(Socket s, const void *data, int len); static void sk_tcp_write_eof(Socket s); static void sk_tcp_set_frozen(Socket s, int is_frozen); static const char *sk_tcp_socket_error(Socket s); @@ -1568,7 +1568,7 @@ void try_send(Actual_Socket s) } } -static int sk_tcp_write(Socket sock, const char *buf, int len) +static int sk_tcp_write(Socket sock, const void *buf, int len) { Actual_Socket s = (Actual_Socket) sock; @@ -1588,7 +1588,7 @@ static int sk_tcp_write(Socket sock, const char *buf, int len) return bufchain_size(&s->output_data); } -static int sk_tcp_write_oob(Socket sock, const char *buf, int len) +static int sk_tcp_write_oob(Socket sock, const void *buf, int len) { Actual_Socket s = (Actual_Socket) sock; diff --git a/windows/winplink.c b/windows/winplink.c index 5b026b52..a940677f 100644 --- a/windows/winplink.c +++ b/windows/winplink.c @@ -104,7 +104,7 @@ void frontend_echoedit_update(void *frontend, int echo, int edit) char *get_ttymode(void *frontend, const char *mode) { return NULL; } int from_backend(void *frontend_handle, int is_stderr, - const char *data, int len) + const void *data, int len) { if (is_stderr) { handle_write(stderr_handle, data, len); @@ -115,7 +115,7 @@ int from_backend(void *frontend_handle, int is_stderr, return handle_backlog(stdout_handle) + handle_backlog(stderr_handle); } -int from_backend_untrusted(void *frontend_handle, const char *data, int len) +int from_backend_untrusted(void *frontend_handle, const void *data, int len) { /* * No "untrusted" output should get here (the way the code is diff --git a/x11fwd.c b/x11fwd.c index 9d0a58de..8b8d4850 100644 --- a/x11fwd.c +++ b/x11fwd.c @@ -787,7 +787,7 @@ static void x11_send_init_error(struct X11Connection *xconn, PUT_16BIT(xconn->firstpkt[0], reply + 6, msgsize >> 2);/* data len */ memset(reply + 8, 0, msgsize); memcpy(reply + 8, full_message, msglen); - sshfwd_write(xconn->c, (char *)reply, 8 + msgsize); + sshfwd_write(xconn->c, reply, 8 + msgsize); sshfwd_write_eof(xconn->c); xconn->no_data_sent_to_x_client = FALSE; sfree(reply); @@ -1057,8 +1057,7 @@ void *x11_make_greeting(int endian, int protomajor, int protominor, t = time(NULL); PUT_32BIT_MSB_FIRST(realauthdata+14, t); - des_encrypt_xdmauth((const unsigned char *)auth_data + 9, - realauthdata, authdatalen); + des_encrypt_xdmauth(auth_data + 9, realauthdata, authdatalen); } else { authdata = realauthdata; authdatalen = 0;