use oldstyle comments

This commit is contained in:
Matt Johnston 2013-11-14 22:03:30 +08:00
parent e00a97944a
commit de1deaf0bd
28 changed files with 72 additions and 73 deletions

4
algo.h
View File

@ -76,8 +76,8 @@ struct dropbear_cipher_mode {
struct dropbear_hash {
const struct ltc_hash_descriptor *hash_desc;
const unsigned long keysize;
// hashsize may be truncated from the size returned by hash_desc,
// eg sha1-96
/* hashsize may be truncated from the size returned by hash_desc,
eg sha1-96 */
const unsigned char hashsize;
};

View File

@ -73,8 +73,8 @@ static int connect_agent() {
return fd;
}
// handle a request for a connection to the locally running ssh-agent
// or forward.
/* handle a request for a connection to the locally running ssh-agent
or forward. */
static int new_agent_chan(struct Channel * channel) {
int fd = -1;
@ -94,7 +94,6 @@ static int new_agent_chan(struct Channel * channel) {
channel->readfd = fd;
channel->writefd = fd;
// success
return 0;
}

View File

@ -433,7 +433,7 @@ void cli_send_chansess_request() {
}
// returns 1 if the character should be consumed, 0 to pass through
/* returns 1 if the character should be consumed, 0 to pass through */
static int
do_escape(unsigned char c) {
switch (c) {
@ -442,10 +442,10 @@ do_escape(unsigned char c) {
return 1;
break;
case 0x1a:
// ctrl-z
/* ctrl-z */
cli_tty_cleanup();
kill(getpid(), SIGTSTP);
// after continuation
/* after continuation */
cli_tty_setup();
cli_ses.winchange = 1;
return 1;
@ -459,8 +459,8 @@ void cli_escape_handler(struct Channel* UNUSED(channel), unsigned char* buf, int
char c;
int skip_char = 0;
// only handle escape characters if they are read one at a time. simplifies
// the code and avoids nasty people putting ~. at the start of a line to paste
/* only handle escape characters if they are read one at a time. simplifies
the code and avoids nasty people putting ~. at the start of a line to paste */
if (*len != 1) {
cli_ses.last_char = 0x0;
return;

View File

@ -143,4 +143,4 @@ static void cli_proxy_cmd(int *sock_in, int *sock_out) {
*sock_in = *sock_out = -1;
}
}
#endif // ENABLE_CLI_PROXYCMD
#endif /* ENABLE_CLI_PROXYCMD */

View File

@ -216,7 +216,7 @@ void cli_getopts(int argc, char ** argv) {
switch (argv[i][1]) {
case 'y': /* always accept the remote hostkey */
if (cli_opts.always_accept_key) {
// twice means no checking at all
/* twice means no checking at all */
cli_opts.no_hostkey_check = 1;
}
cli_opts.always_accept_key = 1;
@ -481,7 +481,7 @@ multihop_passthrough_args() {
sign_key * key = (sign_key*)iter->item;
len += 3 + strlen(key->filename);
}
len += 30; // space for -W <size>, terminator.
len += 30; /* space for -W <size>, terminator. */
ret = m_malloc(len);
total = 0;
@ -619,7 +619,7 @@ static void parse_hostname(const char* orighostarg) {
port = strchr(cli_opts.remotehost, '%');
if (!port) {
// legacy separator
/* legacy separator */
port = strchr(cli_opts.remotehost, '/');
}
if (port) {

View File

@ -175,7 +175,7 @@ static void send_msg_service_request(char* servicename) {
}
static void recv_msg_service_accept(void) {
// do nothing, if it failed then the server MUST have disconnected
/* do nothing, if it failed then the server MUST have disconnected */
}
/* This function drives the progress of the session - it initiates KEX,

View File

@ -193,8 +193,8 @@ void setup_remotetcp() {
struct TCPFwdEntry *fwd = (struct TCPFwdEntry*)iter->item;
if (!fwd->listenaddr)
{
// we store the addresses so that we can compare them
// when the server sends them back
/* we store the addresses so that we can compare them
when the server sends them back */
if (opts.listen_fwd_all) {
fwd->listenaddr = m_strdup("");
} else {

View File

@ -395,7 +395,7 @@ algo_type * buf_match_algo(buffer* buf, algo_type localalgos[],
for (i = 0; i < clicount; i++) {
for (j = 0; j < servcount; j++) {
if (!(servnames[j] && clinames[i])) {
// unusable algos are NULL
/* unusable algos are NULL */
continue;
}
if (strcmp(servnames[j], clinames[i]) == 0) {
@ -458,7 +458,7 @@ get_algo_usable(algo_type algos[], const char * algo_name)
return 0;
}
#endif // DROPBEAR_NONE_CIPHER
#endif /* DROPBEAR_NONE_CIPHER */
#ifdef ENABLE_USER_ALGO_LIST
@ -539,4 +539,4 @@ check_user_algos(const char* user_algo_list, algo_type * algos,
memcpy(algos, new_algos, sizeof(*new_algos) * (num_ret+1));
return num_ret;
}
#endif // ENABLE_USER_ALGO_LIST
#endif /* ENABLE_USER_ALGO_LIST */

View File

@ -685,7 +685,7 @@ void free_kexecdh_param(struct kex_ecdh_param *param) {
void kexecdh_comb_key(struct kex_ecdh_param *param, buffer *pub_them,
sign_key *hostkey) {
const struct dropbear_kex *algo_kex = ses.newkeys->algo_kex;
// public keys from client and server
/* public keys from client and server */
ecc_key *Q_C, *Q_S, *Q_them;
Q_them = buf_get_ecc_raw_pubkey(pub_them, algo_kex->ecc_curve);

View File

@ -266,7 +266,7 @@ void session_cleanup() {
void send_session_identification() {
buffer *writebuf = buf_new(strlen(LOCAL_IDENT "\r\n") + 1);
buf_putbytes(writebuf, LOCAL_IDENT "\r\n", strlen(LOCAL_IDENT "\r\n"));
buf_putbyte(writebuf, 0x0); // packet type
buf_putbyte(writebuf, 0x0); /* packet type */
buf_setpos(writebuf, 0);
enqueue(&ses.writequeue, writebuf);
}

View File

@ -5,5 +5,5 @@ void crypto_init();
extern int dropbear_ltc_prng;
#endif // _CRYPTO_DESC_H
#endif /* _CRYPTO_DESC_H */

10
ecc.c
View File

@ -80,8 +80,8 @@ ecc_key * new_ecc_key(void) {
return key;
}
// Copied from libtomcrypt ecc_import.c (version there is static), modified
// for different mp_int pointer without LTC_SOURCE
/* 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)
{
mp_int *prime, *b, *t1, *t2;
@ -191,7 +191,7 @@ ecc_key * buf_get_ecc_raw_pubkey(buffer *buf, const struct dropbear_ecc_curve *c
goto out;
}
// SEC1 3.2.3.1 Check that Q != 0
/* SEC1 3.2.3.1 Check that Q != 0 */
if (mp_cmp_d(key->pubkey.x, 0) == LTC_MP_EQ) {
TRACE(("failed, x == 0"))
goto out;
@ -216,8 +216,8 @@ 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.
/* 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)
{
ecc_point *result = NULL;

10
ecc.h
View File

@ -9,8 +9,8 @@
#ifdef DROPBEAR_ECC
struct dropbear_ecc_curve {
int ltc_size; // to match the byte sizes in ltc_ecc_sets[]
const ltc_ecc_set_type *dp; // curve domain parameters
int ltc_size; /* to match the byte sizes in ltc_ecc_sets[] */
const ltc_ecc_set_type *dp; /* curve domain parameters */
const struct ltc_hash_descriptor *hash_desc;
const unsigned char *name;
};
@ -23,8 +23,8 @@ extern struct dropbear_ecc_curve *dropbear_ecc_curves[];
void dropbear_ecc_fill_dp();
struct dropbear_ecc_curve* curve_for_dp(const ltc_ecc_set_type *dp);
// "pubkey" refers to a point, but LTC uses ecc_key structure for both public
// and private keys
/* "pubkey" refers to a point, but LTC uses ecc_key structure for both public
and private keys */
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);
@ -33,4 +33,4 @@ mp_int * dropbear_ecc_shared_secret(ecc_key *pub_key, ecc_key *priv_key);
#endif
#endif // _DROPBEAR_ECC_H
#endif /* _DROPBEAR_ECC_H */

20
ecdsa.c
View File

@ -35,7 +35,7 @@ enum signkey_type ecdsa_signkey_type(ecc_key * key) {
}
ecc_key *gen_ecdsa_priv_key(unsigned int bit_size) {
const ltc_ecc_set_type *dp = NULL; // curve domain parameters
const ltc_ecc_set_type *dp = NULL; /* curve domain parameters */
ecc_key *new_key = NULL;
switch (bit_size) {
#ifdef DROPBEAR_ECC_256
@ -82,9 +82,9 @@ ecc_key *buf_get_ecdsa_pub_key(buffer* buf) {
struct dropbear_ecc_curve **curve;
ecc_key *new_key = NULL;
// string "ecdsa-sha2-[identifier]"
/* string "ecdsa-sha2-[identifier]" */
key_ident = buf_getstring(buf, &key_ident_len);
// string "[identifier]"
/* string "[identifier]" */
identifier = buf_getstring(buf, &identifier_len);
if (key_ident_len != identifier_len + strlen("ecdsa-sha2-")) {
@ -106,7 +106,7 @@ ecc_key *buf_get_ecdsa_pub_key(buffer* buf) {
goto out;
}
// string Q
/* string Q */
q_buf = buf_getstringbuf(buf);
new_key = buf_get_ecc_raw_pubkey(q_buf, *curve);
@ -183,7 +183,7 @@ void buf_put_ecdsa_sign(buffer *buf, ecc_key *key, buffer *data_buf) {
}
for (;;) {
ecc_key R_key; // ephemeral key
ecc_key R_key; /* ephemeral key */
if (ecc_make_key_ex(NULL, dropbear_ltc_prng, &R_key, key->dp) != CRYPT_OK) {
goto out;
}
@ -191,7 +191,7 @@ void buf_put_ecdsa_sign(buffer *buf, ecc_key *key, buffer *data_buf) {
goto out;
}
if (ltc_mp.compare_d(r, 0) == LTC_MP_EQ) {
// try again
/* try again */
ecc_free(&R_key);
continue;
}
@ -223,7 +223,7 @@ void buf_put_ecdsa_sign(buffer *buf, ecc_key *key, buffer *data_buf) {
snprintf((char*)key_ident, sizeof(key_ident), "ecdsa-sha2-%s", curve->name);
buf_putstring(buf, key_ident, strlen(key_ident));
// enough for nistp521
/* enough for nistp521 */
sigbuf = buf_new(200);
buf_putmpint(sigbuf, (mp_int*)r);
buf_putmpint(sigbuf, (mp_int*)s);
@ -245,8 +245,8 @@ out:
}
}
// returns values in s and r
// returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE
/* returns values in s and r
returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
static int buf_get_ecdsa_verify_params(buffer *buf,
void *r, void* s) {
int ret = DROPBEAR_FAILURE;
@ -417,4 +417,4 @@ out:
#endif // DROPBEAR_ECDSA
#endif /* DROPBEAR_ECDSA */

View File

@ -32,4 +32,4 @@ int signkey_is_ecdsa(enum signkey_type type);
#endif
#endif // _ECDSA_H_
#endif /* _ECDSA_H_ */

View File

@ -10,7 +10,7 @@
#define RSA_DEFAULT_SIZE 2048
#define DSS_DEFAULT_SIZE 1024
// Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE
/* Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
static int buf_writefile(buffer * buf, const char * filename) {
int ret = DROPBEAR_FAILURE;
int fd = -1;

View File

@ -672,14 +672,14 @@ static sign_key *openssh_read(const char *filename, char * UNUSED(passphrase))
ecc_key *ecc = NULL;
const struct dropbear_ecc_curve *curve = NULL;
// See SEC1 v2, Appendix C.4
// OpenSSL (so OpenSSH) seems to include the optional parts.
/* See SEC1 v2, Appendix C.4 */
/* OpenSSL (so OpenSSH) seems to include the optional parts. */
// privateKey OCTET STRING,
/* privateKey OCTET STRING, */
ret = ber_read_id_len(p, key->keyblob+key->keyblob_len-p,
&id, &len, &flags);
p += ret;
// id==4 for octet string
/* id==4 for octet string */
if (ret < 0 || id != 4 ||
key->keyblob+key->keyblob_len-p < len) {
errmsg = "ASN.1 decoding failure";
@ -689,11 +689,11 @@ static sign_key *openssh_read(const char *filename, char * UNUSED(passphrase))
private_key_len = len;
p += len;
// parameters [0] ECDomainParameters {{ SECGCurveNames }} OPTIONAL,
/* parameters [0] ECDomainParameters {{ SECGCurveNames }} OPTIONAL, */
ret = ber_read_id_len(p, key->keyblob+key->keyblob_len-p,
&id, &len, &flags);
p += ret;
// id==0
/* id==0 */
if (ret < 0 || id != 0) {
errmsg = "ASN.1 decoding failure";
goto error;
@ -702,7 +702,7 @@ static sign_key *openssh_read(const char *filename, char * UNUSED(passphrase))
ret = ber_read_id_len(p, key->keyblob+key->keyblob_len-p,
&id, &len, &flags);
p += ret;
// id==6 for object
/* id==6 for object */
if (ret < 0 || id != 6 ||
key->keyblob+key->keyblob_len-p < len) {
errmsg = "ASN.1 decoding failure";
@ -737,11 +737,11 @@ static sign_key *openssh_read(const char *filename, char * UNUSED(passphrase))
}
p += len;
// publicKey [1] BIT STRING OPTIONAL
/* publicKey [1] BIT STRING OPTIONAL */
ret = ber_read_id_len(p, key->keyblob+key->keyblob_len-p,
&id, &len, &flags);
p += ret;
// id==1
/* id==1 */
if (ret < 0 || id != 1) {
errmsg = "ASN.1 decoding failure";
goto error;
@ -750,7 +750,7 @@ static sign_key *openssh_read(const char *filename, char * UNUSED(passphrase))
ret = ber_read_id_len(p, key->keyblob+key->keyblob_len-p,
&id, &len, &flags);
p += ret;
// id==3 for bit string
/* id==3 for bit string */
if (ret < 0 || id != 3 ||
key->keyblob+key->keyblob_len-p < len) {
errmsg = "ASN.1 decoding failure";
@ -775,7 +775,7 @@ static sign_key *openssh_read(const char *filename, char * UNUSED(passphrase))
*signkey_key_ptr(retkey, retkey->type) = ecc;
}
#endif // DROPBEAR_ECDSA
#endif /* DROPBEAR_ECDSA */
/*
* Now put together the actual key. Simplest way to do this is
@ -1012,7 +1012,7 @@ static int openssh_write(const char *filename, sign_key *key,
memcpy(outblob+pos, numbers[i].start, numbers[i].bytes);
pos += numbers[i].bytes;
}
} // end RSA and DSS handling
} /* end RSA and DSS handling */
#ifdef DROPBEAR_ECDSA
if (key->type == DROPBEAR_SIGNKEY_ECDSA_NISTP256
@ -1067,7 +1067,7 @@ static int openssh_write(const char *filename, sign_key *key,
buf_incrwritepos(seq_buf,
ber_write_id_len(buf_getwriteptr(seq_buf, 10), 0, 2+curve_oid_len, 0xa0));
// object == 6
/* object == 6 */
buf_incrwritepos(seq_buf,
ber_write_id_len(buf_getwriteptr(seq_buf, 10), 6, curve_oid_len, 0));
buf_putbytes(seq_buf, curve_oid, curve_oid_len);

View File

@ -134,4 +134,4 @@ const struct ltc_prng_descriptor dropbear_prng_desc =
};
#endif // DROPBEAR_LTC_PRNG
#endif /* DROPBEAR_LTC_PRNG */

View File

@ -8,6 +8,6 @@
extern const struct ltc_prng_descriptor dropbear_prng_desc;
#endif // DROPBEAR_LTC_PRNG
#endif /* DROPBEAR_LTC_PRNG */
#endif // _LTC_PRNG_H_DROPBEAR
#endif /* _LTC_PRNG_H_DROPBEAR */

View File

@ -171,7 +171,7 @@ much traffic. */
#endif
/* Whether to do reverse DNS lookups. */
//#define DO_HOST_LOOKUP
/*#define DO_HOST_LOOKUP */
/* Whether to print the message of the day (MOTD). This doesn't add much code
* size */

View File

@ -98,7 +98,7 @@ void write_packet() {
writebuf = (buffer*)examine(&ses.writequeue);
len = writebuf->len - 1 - writebuf->pos;
if (len > written) {
// partial buffer write
/* partial buffer write */
buf_incrpos(writebuf, written);
written = 0;
} else {

View File

@ -225,8 +225,8 @@ void seedrandom() {
pid = getpid();
sha1_process(&hs, (void*)&pid, sizeof(pid));
// gettimeofday() doesn't completely fill out struct timeval on
// OS X (10.8.3), avoid valgrind warnings by clearing it first
/* gettimeofday() doesn't completely fill out struct timeval on
OS X (10.8.3), avoid valgrind warnings by clearing it first */
memset(&tv, 0x0, sizeof(tv));
gettimeofday(&tv, NULL);
sha1_process(&hs, (void*)&tv, sizeof(tv));

4
scp.c
View File

@ -494,8 +494,8 @@ toremote(char *targ, int argc, char **argv)
if (verbose_mode)
addargs(&alist, "-v");
#if 0
// Disabled since dbclient won't understand them
// and scp works fine without them.
/* Disabled since dbclient won't understand them
and scp works fine without them. */
addargs(&alist, "-x");
addargs(&alist, "-oClearAllForwardings yes");
addargs(&alist, "-n");

View File

@ -241,7 +241,7 @@ typedef enum {
struct clientsession {
// XXX - move these to kexstate?
/* XXX - move these to kexstate? */
struct kex_dh_param *dh_param;
struct kex_ecdh_param *ecdh_param;
struct kex_curve25519_param *curve25519_param;

View File

@ -40,7 +40,7 @@ static const char *signkey_names[DROPBEAR_SIGNKEY_NUM_NAMED] = {
"ecdsa-sha2-nistp256",
"ecdsa-sha2-nistp384",
"ecdsa-sha2-nistp521"
#endif // DROPBEAR_ECDSA
#endif /* DROPBEAR_ECDSA */
};
/* malloc a new sign_key and set the dss and rsa keys to NULL */

View File

@ -40,9 +40,9 @@ enum signkey_type {
DROPBEAR_SIGNKEY_ECDSA_NISTP256,
DROPBEAR_SIGNKEY_ECDSA_NISTP384,
DROPBEAR_SIGNKEY_ECDSA_NISTP521,
DROPBEAR_SIGNKEY_ECDSA_KEYGEN, // just "ecdsa" for keygen
#endif // DROPBEAR_ECDSA
#endif /* DROPBEAR_ECDSA */
DROPBEAR_SIGNKEY_NUM_NAMED,
DROPBEAR_SIGNKEY_ECDSA_KEYGEN = 70, /* just "ecdsa" for keygen */
DROPBEAR_SIGNKEY_ANY = 80,
DROPBEAR_SIGNKEY_NONE = 90,
};

View File

@ -436,7 +436,7 @@ static void loadhostkey(const char *keyfile, int fatal_duplicate) {
loadhostkey_helper("ECDSA521", (void**)&read_key->ecckey521, (void**)&svr_opts.hostkey->ecckey521, fatal_duplicate);
}
#endif
#endif // DROPBEAR_ECDSA
#endif /* DROPBEAR_ECDSA */
sign_key_free(read_key);
TRACE(("leave loadhostkey"))
}

View File

@ -211,7 +211,7 @@ static int svr_remotetcpreq() {
tcpinfo->request_listenaddr = request_addr;
if (!opts.listen_fwd_all || (strcmp(request_addr, "localhost") == 0) ) {
// NULL means "localhost only"
/* NULL means "localhost only" */
tcpinfo->listenaddr = NULL;
}
else