Mercurial > dropbear
diff signkey.c @ 1295:750ec4ec4cbe
Convert #ifdef to #if, other build changes
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 04 May 2016 15:33:40 +0200 |
parents | 0c47d97aa9d5 |
children | 74a22c562cdf c721e8c42d2a |
line wrap: on
line diff
--- a/signkey.c Mon May 02 23:48:16 2016 +0200 +++ b/signkey.c Wed May 04 15:33:40 2016 +0200 @@ -30,13 +30,13 @@ #include "ecdsa.h" static const char * const signkey_names[DROPBEAR_SIGNKEY_NUM_NAMED] = { -#ifdef DROPBEAR_RSA +#if DROPBEAR_RSA "ssh-rsa", #endif -#ifdef DROPBEAR_DSS +#if DROPBEAR_DSS "ssh-dss", #endif -#ifdef DROPBEAR_ECDSA +#if DROPBEAR_ECDSA "ecdsa-sha2-nistp256", "ecdsa-sha2-nistp384", "ecdsa-sha2-nistp521" @@ -75,7 +75,7 @@ if (namelen == strlen(fixed_name) && memcmp(fixed_name, name, namelen) == 0) { -#ifdef DROPBEAR_ECDSA +#if DROPBEAR_ECDSA /* Some of the ECDSA key sizes are defined even if they're not compiled in */ if (0 #ifndef DROPBEAR_ECC_256 @@ -106,25 +106,25 @@ void ** signkey_key_ptr(sign_key *key, enum signkey_type type) { switch (type) { -#ifdef DROPBEAR_ECDSA -#ifdef DROPBEAR_ECC_256 +#if DROPBEAR_ECDSA +#if DROPBEAR_ECC_256 case DROPBEAR_SIGNKEY_ECDSA_NISTP256: return (void**)&key->ecckey256; #endif -#ifdef DROPBEAR_ECC_384 +#if DROPBEAR_ECC_384 case DROPBEAR_SIGNKEY_ECDSA_NISTP384: return (void**)&key->ecckey384; #endif -#ifdef DROPBEAR_ECC_521 +#if DROPBEAR_ECC_521 case DROPBEAR_SIGNKEY_ECDSA_NISTP521: return (void**)&key->ecckey521; #endif #endif /* DROPBEAR_ECDSA */ -#ifdef DROPBEAR_RSA +#if DROPBEAR_RSA case DROPBEAR_SIGNKEY_RSA: return (void**)&key->rsakey; #endif -#ifdef DROPBEAR_DSS +#if DROPBEAR_DSS case DROPBEAR_SIGNKEY_DSS: return (void**)&key->dsskey; #endif @@ -161,7 +161,7 @@ /* Rewind the buffer back before "ssh-rsa" etc */ buf_incrpos(buf, -len - 4); -#ifdef DROPBEAR_DSS +#if DROPBEAR_DSS if (keytype == DROPBEAR_SIGNKEY_DSS) { dss_key_free(key->dsskey); key->dsskey = m_malloc(sizeof(*key->dsskey)); @@ -171,7 +171,7 @@ } } #endif -#ifdef DROPBEAR_RSA +#if DROPBEAR_RSA if (keytype == DROPBEAR_SIGNKEY_RSA) { rsa_key_free(key->rsakey); key->rsakey = m_malloc(sizeof(*key->rsakey)); @@ -181,7 +181,7 @@ } } #endif -#ifdef DROPBEAR_ECDSA +#if DROPBEAR_ECDSA if (signkey_is_ecdsa(keytype)) { ecc_key **eck = (ecc_key**)signkey_key_ptr(key, keytype); if (eck) { @@ -230,7 +230,7 @@ /* Rewind the buffer back before "ssh-rsa" etc */ buf_incrpos(buf, -len - 4); -#ifdef DROPBEAR_DSS +#if DROPBEAR_DSS if (keytype == DROPBEAR_SIGNKEY_DSS) { dss_key_free(key->dsskey); key->dsskey = m_malloc(sizeof(*key->dsskey)); @@ -240,7 +240,7 @@ } } #endif -#ifdef DROPBEAR_RSA +#if DROPBEAR_RSA if (keytype == DROPBEAR_SIGNKEY_RSA) { rsa_key_free(key->rsakey); key->rsakey = m_malloc(sizeof(*key->rsakey)); @@ -250,7 +250,7 @@ } } #endif -#ifdef DROPBEAR_ECDSA +#if DROPBEAR_ECDSA if (signkey_is_ecdsa(keytype)) { ecc_key **eck = (ecc_key**)signkey_key_ptr(key, keytype); if (eck) { @@ -281,17 +281,17 @@ TRACE2(("enter buf_put_pub_key")) pubkeys = buf_new(MAX_PUBKEY_SIZE); -#ifdef DROPBEAR_DSS +#if DROPBEAR_DSS if (type == DROPBEAR_SIGNKEY_DSS) { buf_put_dss_pub_key(pubkeys, key->dsskey); } #endif -#ifdef DROPBEAR_RSA +#if DROPBEAR_RSA if (type == DROPBEAR_SIGNKEY_RSA) { buf_put_rsa_pub_key(pubkeys, key->rsakey); } #endif -#ifdef DROPBEAR_ECDSA +#if DROPBEAR_ECDSA if (signkey_is_ecdsa(type)) { ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); if (eck) { @@ -314,21 +314,21 @@ TRACE(("enter buf_put_priv_key")) TRACE(("type is %d", type)) -#ifdef DROPBEAR_DSS +#if DROPBEAR_DSS if (type == DROPBEAR_SIGNKEY_DSS) { buf_put_dss_priv_key(buf, key->dsskey); TRACE(("leave buf_put_priv_key: dss done")) return; } #endif -#ifdef DROPBEAR_RSA +#if DROPBEAR_RSA if (type == DROPBEAR_SIGNKEY_RSA) { buf_put_rsa_priv_key(buf, key->rsakey); TRACE(("leave buf_put_priv_key: rsa done")) return; } #endif -#ifdef DROPBEAR_ECDSA +#if DROPBEAR_ECDSA if (signkey_is_ecdsa(type)) { ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); if (eck) { @@ -345,30 +345,30 @@ TRACE2(("enter sign_key_free")) -#ifdef DROPBEAR_DSS +#if DROPBEAR_DSS dss_key_free(key->dsskey); key->dsskey = NULL; #endif -#ifdef DROPBEAR_RSA +#if DROPBEAR_RSA rsa_key_free(key->rsakey); key->rsakey = NULL; #endif -#ifdef DROPBEAR_ECDSA -#ifdef DROPBEAR_ECC_256 +#if DROPBEAR_ECDSA +#if DROPBEAR_ECC_256 if (key->ecckey256) { ecc_free(key->ecckey256); m_free(key->ecckey256); key->ecckey256 = NULL; } #endif -#ifdef DROPBEAR_ECC_384 +#if DROPBEAR_ECC_384 if (key->ecckey384) { ecc_free(key->ecckey384); m_free(key->ecckey384); key->ecckey384 = NULL; } #endif -#ifdef DROPBEAR_ECC_521 +#if DROPBEAR_ECC_521 if (key->ecckey521) { ecc_free(key->ecckey521); m_free(key->ecckey521); @@ -395,7 +395,7 @@ /* Since we're not sure if we'll have md5 or sha1, we present both. * MD5 is used in preference, but sha1 could still be useful */ -#ifdef DROPBEAR_MD5_HMAC +#if DROPBEAR_MD5_HMAC static char * sign_key_md5_fingerprint(unsigned char* keyblob, unsigned int keybloblen) { @@ -470,7 +470,7 @@ * in either sha1 or md5 */ char * sign_key_fingerprint(unsigned char* keyblob, unsigned int keybloblen) { -#ifdef DROPBEAR_MD5_HMAC +#if DROPBEAR_MD5_HMAC return sign_key_md5_fingerprint(keyblob, keybloblen); #else return sign_key_sha1_fingerprint(keyblob, keybloblen); @@ -482,17 +482,17 @@ buffer *sigblob; sigblob = buf_new(MAX_PUBKEY_SIZE); -#ifdef DROPBEAR_DSS +#if DROPBEAR_DSS if (type == DROPBEAR_SIGNKEY_DSS) { buf_put_dss_sign(sigblob, key->dsskey, data_buf); } #endif -#ifdef DROPBEAR_RSA +#if DROPBEAR_RSA if (type == DROPBEAR_SIGNKEY_RSA) { buf_put_rsa_sign(sigblob, key->rsakey, data_buf); } #endif -#ifdef DROPBEAR_ECDSA +#if DROPBEAR_ECDSA if (signkey_is_ecdsa(type)) { ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); if (eck) { @@ -508,7 +508,7 @@ } -#ifdef DROPBEAR_SIGNKEY_VERIFY +#if DROPBEAR_SIGNKEY_VERIFY /* Return DROPBEAR_SUCCESS or DROPBEAR_FAILURE. * If FAILURE is returned, the position of * buf is undefined. If SUCCESS is returned, buf will be positioned after the @@ -526,7 +526,7 @@ type = signkey_type_from_name(type_name, type_name_len); m_free(type_name); -#ifdef DROPBEAR_DSS +#if DROPBEAR_DSS if (type == DROPBEAR_SIGNKEY_DSS) { if (key->dsskey == NULL) { dropbear_exit("No DSS key to verify signature"); @@ -535,7 +535,7 @@ } #endif -#ifdef DROPBEAR_RSA +#if DROPBEAR_RSA if (type == DROPBEAR_SIGNKEY_RSA) { if (key->rsakey == NULL) { dropbear_exit("No RSA key to verify signature"); @@ -543,7 +543,7 @@ return buf_rsa_verify(buf, key->rsakey, data_buf); } #endif -#ifdef DROPBEAR_ECDSA +#if DROPBEAR_ECDSA if (signkey_is_ecdsa(type)) { ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); if (eck) { @@ -557,7 +557,7 @@ } #endif /* DROPBEAR_SIGNKEY_VERIFY */ -#ifdef DROPBEAR_KEY_LINES /* ie we're using authorized_keys or known_hosts */ +#if DROPBEAR_KEY_LINES /* ie we're using authorized_keys or known_hosts */ /* Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE when given a buffer containing * a key, a key, and a type. The buffer is positioned at the start of the