Skip to content
Snippets Groups Projects
Unverified Commit b93c40a6 authored by Matt Johnston's avatar Matt Johnston Committed by GitHub
Browse files

Merge pull request #49 from fperrad/20170812_lint

Some linting, const parameters
parents ba23b823 598056d1
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -56,7 +56,7 @@ extern int debug_trace;
 
char * stripcontrol(const char * text);
 
int spawn_command(void(*exec_fn)(void *user_data), void *exec_data,
int spawn_command(void(*exec_fn)(const void *user_data), const void *exec_data,
int *writefd, int *readfd, int *errfd, pid_t *pid);
void run_shell_command(const char* cmd, unsigned int maxfd, char* usershell);
#ifdef ENABLE_CONNECT_UNIX
Loading
Loading
Loading
Loading
@@ -241,7 +241,7 @@ int main(int argc, char ** argv) {
}
 
genbits = signkey_generate_get_bits(keytype, bits);
fprintf(stderr, "Generating %d bit %s key, this may take a while...\n", genbits, typetext);
fprintf(stderr, "Generating %u bit %s key, this may take a while...\n", genbits, typetext);
if (signkey_generate(keytype, bits, filename, 0) == DROPBEAR_FAILURE)
{
dropbear_exit("Failed to generate key.\n");
Loading
Loading
Loading
Loading
@@ -127,7 +127,7 @@ void dss_key_free(dropbear_dss_key *key) {
* mpint g
* mpint y
*/
void buf_put_dss_pub_key(buffer* buf, dropbear_dss_key *key) {
void buf_put_dss_pub_key(buffer* buf, const dropbear_dss_key *key) {
 
dropbear_assert(key != NULL);
buf_putstring(buf, SSH_SIGNKEY_DSS, SSH_SIGNKEY_DSS_LEN);
Loading
Loading
@@ -139,7 +139,7 @@ void buf_put_dss_pub_key(buffer* buf, dropbear_dss_key *key) {
}
 
/* Same as buf_put_dss_pub_key, but with the private "x" key appended */
void buf_put_dss_priv_key(buffer* buf, dropbear_dss_key *key) {
void buf_put_dss_priv_key(buffer* buf, const dropbear_dss_key *key) {
 
dropbear_assert(key != NULL);
buf_put_dss_pub_key(buf, key);
Loading
Loading
@@ -150,7 +150,7 @@ void buf_put_dss_priv_key(buffer* buf, dropbear_dss_key *key) {
#if DROPBEAR_SIGNKEY_VERIFY
/* Verify a DSS signature (in buf) made on data by the key given.
* returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
int buf_dss_verify(buffer* buf, dropbear_dss_key *key, buffer *data_buf) {
int buf_dss_verify(buffer* buf, const dropbear_dss_key *key, const buffer *data_buf) {
unsigned char msghash[SHA1_HASH_SIZE];
hash_state hs;
int ret = DROPBEAR_FAILURE;
Loading
Loading
@@ -255,7 +255,7 @@ out:
 
/* Sign the data presented with key, writing the signature contents
* to the buffer */
void buf_put_dss_sign(buffer* buf, dropbear_dss_key *key, buffer *data_buf) {
void buf_put_dss_sign(buffer* buf, const dropbear_dss_key *key, const buffer *data_buf) {
unsigned char msghash[SHA1_HASH_SIZE];
unsigned int writelen;
unsigned int i;
Loading
Loading
Loading
Loading
@@ -44,14 +44,14 @@ typedef struct {
#define DSS_P_BITS 1024
#define DSS_Q_BITS 160
 
void buf_put_dss_sign(buffer* buf, dropbear_dss_key *key, buffer *data_buf);
void buf_put_dss_sign(buffer* buf, const dropbear_dss_key *key, const buffer *data_buf);
#if DROPBEAR_SIGNKEY_VERIFY
int buf_dss_verify(buffer* buf, dropbear_dss_key *key, buffer *data_buf);
int buf_dss_verify(buffer* buf, const dropbear_dss_key *key, const buffer *data_buf);
#endif
int buf_get_dss_pub_key(buffer* buf, dropbear_dss_key *key);
int buf_get_dss_priv_key(buffer* buf, dropbear_dss_key *key);
void buf_put_dss_pub_key(buffer* buf, dropbear_dss_key *key);
void buf_put_dss_priv_key(buffer* buf, dropbear_dss_key *key);
void buf_put_dss_pub_key(buffer* buf, const dropbear_dss_key *key);
void buf_put_dss_priv_key(buffer* buf, const dropbear_dss_key *key);
void dss_key_free(dropbear_dss_key *key);
 
#endif /* DROPBEAR_DSS */
Loading
Loading
Loading
Loading
@@ -82,7 +82,7 @@ ecc_key * new_ecc_key(void) {
 
/* Copied from libtomcrypt ecc_import.c (version there is static), modified
for different mp_int pointer without LTC_SOURCE */
static int ecc_is_point(ecc_key *key)
static int ecc_is_point(const ecc_key *key)
{
mp_int *prime, *b, *t1, *t2;
int err;
Loading
Loading
@@ -213,7 +213,7 @@ ecc_key * buf_get_ecc_raw_pubkey(buffer *buf, const struct dropbear_ecc_curve *c
 
/* a modified version of libtomcrypt's "ecc_shared_secret" to output
a mp_int instead. */
mp_int * dropbear_ecc_shared_secret(ecc_key *public_key, ecc_key *private_key)
mp_int * dropbear_ecc_shared_secret(ecc_key *public_key, const ecc_key *private_key)
{
ecc_point *result = NULL;
mp_int *prime = NULL, *shared_secret = NULL;
Loading
Loading
Loading
Loading
@@ -29,7 +29,7 @@ void buf_put_ecc_raw_pubkey_string(buffer *buf, ecc_key *key);
ecc_key * buf_get_ecc_raw_pubkey(buffer *buf, const struct dropbear_ecc_curve *curve);
int buf_get_ecc_privkey_string(buffer *buf, ecc_key *key);
 
mp_int * dropbear_ecc_shared_secret(ecc_key *pub_key, ecc_key *priv_key);
mp_int * dropbear_ecc_shared_secret(ecc_key *pub_key, const ecc_key *priv_key);
 
#endif
 
Loading
Loading
Loading
Loading
@@ -15,7 +15,7 @@ int signkey_is_ecdsa(enum signkey_type type)
|| type == DROPBEAR_SIGNKEY_ECDSA_NISTP521;
}
 
enum signkey_type ecdsa_signkey_type(ecc_key * key) {
enum signkey_type ecdsa_signkey_type(const ecc_key * key) {
#if DROPBEAR_ECC_256
if (key->dp == ecc_curve_nistp256.dp) {
return DROPBEAR_SIGNKEY_ECDSA_NISTP256;
Loading
Loading
@@ -154,7 +154,7 @@ void buf_put_ecdsa_priv_key(buffer *buf, ecc_key *key) {
buf_putmpint(buf, key->k);
}
 
void buf_put_ecdsa_sign(buffer *buf, ecc_key *key, buffer *data_buf) {
void buf_put_ecdsa_sign(buffer *buf, const ecc_key *key, const buffer *data_buf) {
/* Based on libtomcrypt's ecc_sign_hash but without the asn1 */
int err = DROPBEAR_FAILURE;
struct dropbear_ecc_curve *curve = NULL;
Loading
Loading
@@ -272,7 +272,7 @@ out:
}
 
 
int buf_ecdsa_verify(buffer *buf, ecc_key *key, buffer *data_buf) {
int buf_ecdsa_verify(buffer *buf, const ecc_key *key, const buffer *data_buf) {
/* Based on libtomcrypt's ecc_verify_hash but without the asn1 */
int ret = DROPBEAR_FAILURE;
hash_state hs;
Loading
Loading
Loading
Loading
@@ -23,10 +23,10 @@ ecc_key *buf_get_ecdsa_pub_key(buffer* buf);
ecc_key *buf_get_ecdsa_priv_key(buffer *buf);
void buf_put_ecdsa_pub_key(buffer *buf, ecc_key *key);
void buf_put_ecdsa_priv_key(buffer *buf, ecc_key *key);
enum signkey_type ecdsa_signkey_type(ecc_key * key);
enum signkey_type ecdsa_signkey_type(const ecc_key * key);
 
void buf_put_ecdsa_sign(buffer *buf, ecc_key *key, buffer *data_buf);
int buf_ecdsa_verify(buffer *buf, ecc_key *key, buffer *data_buf);
void buf_put_ecdsa_sign(buffer *buf, const ecc_key *key, const buffer *data_buf);
int buf_ecdsa_verify(buffer *buf, const ecc_key *key, const buffer *data_buf);
/* Returns 1 on success */
int signkey_is_ecdsa(enum signkey_type type);
 
Loading
Loading
Loading
Loading
@@ -37,11 +37,11 @@
 
#if DROPBEAR_DSS
 
static void getq(dropbear_dss_key *key);
static void getp(dropbear_dss_key *key, unsigned int size);
static void getg(dropbear_dss_key *key);
static void getx(dropbear_dss_key *key);
static void gety(dropbear_dss_key *key);
static void getq(const dropbear_dss_key *key);
static void getp(const dropbear_dss_key *key, unsigned int size);
static void getg(const dropbear_dss_key *key);
static void getx(const dropbear_dss_key *key);
static void gety(const dropbear_dss_key *key);
 
dropbear_dss_key * gen_dss_priv_key(unsigned int size) {
 
Loading
Loading
@@ -65,7 +65,7 @@ dropbear_dss_key * gen_dss_priv_key(unsigned int size) {
}
 
static void getq(dropbear_dss_key *key) {
static void getq(const dropbear_dss_key *key) {
 
unsigned char buf[QSIZE];
 
Loading
Loading
@@ -83,7 +83,7 @@ static void getq(dropbear_dss_key *key) {
}
}
 
static void getp(dropbear_dss_key *key, unsigned int size) {
static void getp(const dropbear_dss_key *key, unsigned int size) {
 
DEF_MP_INT(tempX);
DEF_MP_INT(tempC);
Loading
Loading
@@ -142,7 +142,7 @@ static void getp(dropbear_dss_key *key, unsigned int size) {
m_free(buf);
}
 
static void getg(dropbear_dss_key * key) {
static void getg(const dropbear_dss_key * key) {
 
DEF_MP_INT(div);
DEF_MP_INT(h);
Loading
Loading
@@ -179,12 +179,12 @@ static void getg(dropbear_dss_key * key) {
mp_clear_multi(&div, &h, &val, NULL);
}
 
static void getx(dropbear_dss_key *key) {
static void getx(const dropbear_dss_key *key) {
 
gen_random_mpint(key->q, key->x);
}
 
static void gety(dropbear_dss_key *key) {
static void gety(const dropbear_dss_key *key) {
 
if (mp_exptmod(key->g, key->x, key->p, key->y) != MP_OKAY) {
fprintf(stderr, "DSS key generation failed\n");
Loading
Loading
Loading
Loading
@@ -50,7 +50,7 @@ void kexecdh_comb_key(struct kex_ecdh_param *param, buffer *pub_them,
#if DROPBEAR_CURVE25519
struct kex_curve25519_param *gen_kexcurve25519_param(void);
void free_kexcurve25519_param(struct kex_curve25519_param *param);
void kexcurve25519_comb_key(struct kex_curve25519_param *param, buffer *pub_them,
void kexcurve25519_comb_key(const struct kex_curve25519_param *param, const buffer *pub_them,
sign_key *hostkey);
#endif
 
Loading
Loading
Loading
Loading
@@ -55,9 +55,9 @@ static const unsigned char OID_SEC521R1_BLOB[] = {0x2b, 0x81, 0x04, 0x00, 0x23};
((unsigned long)(unsigned char)(cp)[3]))
 
static int openssh_encrypted(const char *filename);
static sign_key *openssh_read(const char *filename, char *passphrase);
static sign_key *openssh_read(const char *filename, const char *passphrase);
static int openssh_write(const char *filename, sign_key *key,
char *passphrase);
const char *passphrase);
 
static int dropbear_write(const char*filename, sign_key * key);
static sign_key *dropbear_read(const char* filename);
Loading
Loading
@@ -83,7 +83,7 @@ int import_encrypted(const char* filename, int filetype) {
return 0;
}
 
sign_key *import_read(const char *filename, char *passphrase, int filetype) {
sign_key *import_read(const char *filename, const char *passphrase, int filetype) {
 
if (filetype == KEYFILE_OPENSSH) {
return openssh_read(filename, passphrase);
Loading
Loading
@@ -97,7 +97,7 @@ sign_key *import_read(const char *filename, char *passphrase, int filetype) {
return NULL;
}
 
int import_write(const char *filename, sign_key *key, char *passphrase,
int import_write(const char *filename, sign_key *key, const char *passphrase,
int filetype) {
 
if (filetype == KEYFILE_OPENSSH) {
Loading
Loading
@@ -194,7 +194,7 @@ out:
)
 
/* cpl has to be less than 100 */
static void base64_encode_fp(FILE * fp, unsigned char *data,
static void base64_encode_fp(FILE * fp, const unsigned char *data,
int datalen, int cpl)
{
unsigned char out[100];
Loading
Loading
@@ -509,7 +509,7 @@ static int openssh_encrypted(const char *filename)
return ret;
}
 
static sign_key *openssh_read(const char *filename, char * UNUSED(passphrase))
static sign_key *openssh_read(const char *filename, const char * UNUSED(passphrase))
{
struct openssh_key *key;
unsigned char *p;
Loading
Loading
@@ -828,7 +828,7 @@ static sign_key *openssh_read(const char *filename, char * UNUSED(passphrase))
}
 
static int openssh_write(const char *filename, sign_key *key,
char *passphrase)
const char *passphrase)
{
buffer * keyblob = NULL;
buffer * extrablob = NULL; /* used for calculated values to write */
Loading
Loading
Loading
Loading
@@ -34,9 +34,9 @@ enum {
KEYFILE_SSHCOM
};
 
int import_write(const char *filename, sign_key *key, char *passphrase,
int import_write(const char *filename, sign_key *key, const char *passphrase,
int filetype);
sign_key *import_read(const char *filename, char *passphrase, int filetype);
sign_key *import_read(const char *filename, const char *passphrase, int filetype);
int import_encrypted(const char* filename, int filetype);
 
#endif /* DROPBEAR_KEYIMPORT_H_ */
Loading
Loading
@@ -53,7 +53,7 @@ void set_listener_fds(fd_set * readfds) {
}
 
 
void handle_listeners(fd_set * readfds) {
void handle_listeners(const fd_set * readfds) {
 
unsigned int i, j;
struct Listener *listener;
Loading
Loading
@@ -76,10 +76,10 @@ void handle_listeners(fd_set * readfds) {
 
/* acceptor(int fd, void* typedata) is a function to accept connections,
* cleanup(void* typedata) happens when cleaning up */
struct Listener* new_listener(int socks[], unsigned int nsocks,
struct Listener* new_listener(const int socks[], unsigned int nsocks,
int type, void* typedata,
void (*acceptor)(struct Listener* listener, int sock),
void (*cleanup)(struct Listener*)) {
void (*acceptor)(const struct Listener* listener, int sock),
void (*cleanup)(const struct Listener*)) {
 
unsigned int i, j;
struct Listener *newlisten = NULL;
Loading
Loading
@@ -132,8 +132,8 @@ struct Listener* new_listener(int socks[], unsigned int nsocks,
 
/* Return the first listener which matches the type-specific comparison
* function. Particularly needed for global requests, like tcp */
struct Listener * get_listener(int type, void* typedata,
int (*match)(void*, void*)) {
struct Listener * get_listener(int type, const void* typedata,
int (*match)(const void*, const void*)) {
 
unsigned int i;
struct Listener* listener;
Loading
Loading
Loading
Loading
@@ -35,8 +35,8 @@ struct Listener {
 
int index; /* index in the array of listeners */
 
void (*acceptor)(struct Listener*, int sock);
void (*cleanup)(struct Listener*);
void (*acceptor)(const struct Listener*, int sock);
void (*cleanup)(const struct Listener*);
 
int type; /* CHANNEL_ID_X11, CHANNEL_ID_AGENT,
CHANNEL_ID_TCPDIRECT (for clients),
Loading
Loading
@@ -47,16 +47,16 @@ struct Listener {
};
 
void listeners_initialise(void);
void handle_listeners(fd_set * readfds);
void handle_listeners(const fd_set * readfds);
void set_listener_fds(fd_set * readfds);
 
struct Listener* new_listener(int socks[], unsigned int nsocks,
struct Listener* new_listener(const int socks[], unsigned int nsocks,
int type, void* typedata,
void (*acceptor)(struct Listener* listener, int sock),
void (*cleanup)(struct Listener*));
void (*acceptor)(const struct Listener* listener, int sock),
void (*cleanup)(const struct Listener*));
 
struct Listener * get_listener(int type, void* typedata,
int (*match)(void*, void*));
struct Listener * get_listener(int type, const void* typedata,
int (*match)(const void*, const void*));
 
void remove_listener(struct Listener* listener);
 
Loading
Loading
Loading
Loading
@@ -197,7 +197,7 @@ void set_connect_fds(fd_set *writefd) {
}
}
 
void handle_connect_fds(fd_set *writefd) {
void handle_connect_fds(const fd_set *writefd) {
m_list_elem *iter;
TRACE(("enter handle_connect_fds"))
for (iter = ses.conn_pending.first; iter; iter = iter->next) {
Loading
Loading
@@ -240,7 +240,7 @@ void connect_set_writequeue(struct dropbear_progress_connection *c, struct Queue
c->writequeue = writequeue;
}
 
void packet_queue_to_iovec(struct Queue *queue, struct iovec *iov, unsigned int *iov_count) {
void packet_queue_to_iovec(const struct Queue *queue, struct iovec *iov, unsigned int *iov_count) {
struct Link *l;
unsigned int i;
int len;
Loading
Loading
Loading
Loading
@@ -34,7 +34,7 @@ struct dropbear_progress_connection * connect_remote (const char* remotehost, co
/* Sets up for select() */
void set_connect_fds(fd_set *writefd);
/* Handles ready sockets after select() */
void handle_connect_fds(fd_set *writefd);
void handle_connect_fds(const fd_set *writefd);
/* Cleanup */
void remove_connect_pending(void);
 
Loading
Loading
@@ -45,7 +45,7 @@ void connect_set_writequeue(struct dropbear_progress_connection *c, struct Queue
 
/* TODO: writev #ifdef guard */
/* Fills out iov which contains iov_count slots, returning the number filled in iov_count */
void packet_queue_to_iovec(struct Queue *queue, struct iovec *iov, unsigned int *iov_count);
void packet_queue_to_iovec(const struct Queue *queue, struct iovec *iov, unsigned int *iov_count);
void packet_queue_consume(struct Queue *queue, ssize_t written);
 
#if DROPBEAR_SERVER_TCP_FAST_OPEN
Loading
Loading
Loading
Loading
@@ -49,7 +49,7 @@ static int checkmac(void);
#define ZLIB_COMPRESS_EXPANSION (((RECV_MAX_PAYLOAD_LEN/16384)+1)*5 + 6)
#define ZLIB_DECOMPRESS_INCR 1024
#ifndef DISABLE_ZLIB
static buffer* buf_decompress(buffer* buf, unsigned int len);
static buffer* buf_decompress(const buffer* buf, unsigned int len);
static void buf_compress(buffer * dest, buffer * src, unsigned int len);
#endif
 
Loading
Loading
@@ -367,7 +367,7 @@ static int checkmac() {
 
#ifndef DISABLE_ZLIB
/* returns a pointer to a newly created buffer */
static buffer* buf_decompress(buffer* buf, unsigned int len) {
static buffer* buf_decompress(const buffer* buf, unsigned int len) {
 
int result;
buffer * ret;
Loading
Loading
Loading
Loading
@@ -33,7 +33,7 @@ void initqueue(struct Queue* queue) {
queue->count = 0;
}
 
int isempty(struct Queue* queue) {
int isempty(const struct Queue* queue) {
 
return (queue->head == NULL);
}
Loading
Loading
@@ -60,7 +60,7 @@ void* dequeue(struct Queue* queue) {
return ret;
}
 
void *examine(struct Queue* queue) {
void *examine(const struct Queue* queue) {
 
dropbear_assert(!isempty(queue));
return queue->head->item;
Loading
Loading
Loading
Loading
@@ -41,9 +41,9 @@ struct Queue {
};
 
void initqueue(struct Queue* queue);
int isempty(struct Queue* queue);
int isempty(const struct Queue* queue);
void* dequeue(struct Queue* queue);
void *examine(struct Queue* queue);
void *examine(const struct Queue* queue);
void enqueue(struct Queue* queue, void* item);
 
#endif
Loading
Loading
@@ -38,8 +38,8 @@
 
#if DROPBEAR_RSA
 
static void rsa_pad_em(dropbear_rsa_key * key,
buffer *data_buf, mp_int * rsa_em);
static void rsa_pad_em(const dropbear_rsa_key * key,
const buffer *data_buf, mp_int * rsa_em);
 
/* Load a public rsa key from a buffer, initialising the values.
* The key will have the same format as buf_put_rsa_key.
Loading
Loading
@@ -147,7 +147,7 @@ void rsa_key_free(dropbear_rsa_key *key) {
* mp_int e
* mp_int n
*/
void buf_put_rsa_pub_key(buffer* buf, dropbear_rsa_key *key) {
void buf_put_rsa_pub_key(buffer* buf, const dropbear_rsa_key *key) {
 
TRACE(("enter buf_put_rsa_pub_key"))
dropbear_assert(key != NULL);
Loading
Loading
@@ -161,7 +161,7 @@ void buf_put_rsa_pub_key(buffer* buf, dropbear_rsa_key *key) {
}
 
/* Same as buf_put_rsa_pub_key, but with the private "x" key appended */
void buf_put_rsa_priv_key(buffer* buf, dropbear_rsa_key *key) {
void buf_put_rsa_priv_key(buffer* buf, const dropbear_rsa_key *key) {
 
TRACE(("enter buf_put_rsa_priv_key"))
 
Loading
Loading
@@ -185,7 +185,7 @@ void buf_put_rsa_priv_key(buffer* buf, dropbear_rsa_key *key) {
#if DROPBEAR_SIGNKEY_VERIFY
/* Verify a signature in buf, made on data by the key given.
* Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
int buf_rsa_verify(buffer * buf, dropbear_rsa_key *key, buffer *data_buf) {
int buf_rsa_verify(buffer * buf, const dropbear_rsa_key *key, const buffer *data_buf) {
unsigned int slen;
DEF_MP_INT(rsa_s);
DEF_MP_INT(rsa_mdash);
Loading
Loading
@@ -240,7 +240,7 @@ out:
 
/* Sign the data presented with key, writing the signature contents
* to the buffer */
void buf_put_rsa_sign(buffer* buf, dropbear_rsa_key *key, buffer *data_buf) {
void buf_put_rsa_sign(buffer* buf, const dropbear_rsa_key *key, const buffer *data_buf) {
unsigned int nsize, ssize;
unsigned int i;
DEF_MP_INT(rsa_s);
Loading
Loading
@@ -346,8 +346,8 @@ void buf_put_rsa_sign(buffer* buf, dropbear_rsa_key *key, buffer *data_buf) {
*
* rsa_em must be a pointer to an initialised mp_int.
*/
static void rsa_pad_em(dropbear_rsa_key * key,
buffer *data_buf, mp_int * rsa_em) {
static void rsa_pad_em(const dropbear_rsa_key * key,
const buffer *data_buf, mp_int * rsa_em) {
 
/* ASN1 designator (including the 0x00 preceding) */
const unsigned char rsa_asn1_magic[] =
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment