# HG changeset patch # User Matt Johnston # Date 1225977415 0 # Node ID 582cb38e4eb507792759de64901a53bc51649557 # Parent 461c4b1fb35ffb0482e304cf927ed0cb05a4af3a# Parent b85507ade01056c28e31d602815779f366606b51 propagate from branch 'au.asn.ucc.matt.dropbear' (head cdcc3c729e29544e8b98a408e2dc60e4483dfd2a) to branch 'au.asn.ucc.matt.dropbear.insecure-nocrypto' (head 0ca38a1cf349f7426ac9de34ebe4c3e3735effab) diff -r b85507ade010 -r 582cb38e4eb5 cli-auth.c --- a/cli-auth.c Wed Nov 05 14:14:40 2008 +0000 +++ b/cli-auth.c Thu Nov 06 13:16:55 2008 +0000 @@ -253,7 +253,10 @@ #endif #ifdef ENABLE_CLI_INTERACT_AUTH - if (!finished && ses.authstate.authtypes & AUTH_TYPE_INTERACT) { + if (ses.keys->trans_algo_crypt->cipherdesc == NULL) { + fprintf(stderr, "Sorry, I won't let you use interactive auth unencrypted.\n"); + } + else if (!finished && ses.authstate.authtypes & AUTH_TYPE_INTERACT) { if (cli_ses.auth_interact_failed) { finished = 0; } else { @@ -265,7 +268,10 @@ #endif #ifdef ENABLE_CLI_PASSWORD_AUTH - if (!finished && ses.authstate.authtypes & AUTH_TYPE_PASSWORD) { + if (ses.keys->trans_algo_crypt->cipherdesc == NULL) { + fprintf(stderr, "Sorry, I won't let you use password auth unencrypted.\n"); + } + else if (!finished && ses.authstate.authtypes & AUTH_TYPE_PASSWORD) { cli_auth_password(); finished = 1; cli_ses.lastauthtype = AUTH_TYPE_PASSWORD; diff -r b85507ade010 -r 582cb38e4eb5 common-algo.c --- a/common-algo.c Wed Nov 05 14:14:40 2008 +0000 +++ b/common-algo.c Thu Nov 06 13:16:55 2008 +0000 @@ -150,7 +150,10 @@ #ifdef DROPBEAR_BLOWFISH {"blowfish-cbc", 0, &dropbear_blowfish, 1, &dropbear_mode_cbc}, #endif - {NULL, 0, NULL, 0, NULL} +#ifdef DROPBEAR_NONE_CIPHER + {"none", 0, (void*)&dropbear_nocipher, 1}, +#endif + {NULL, 0, NULL, 0} }; algo_type sshhashes[] = { @@ -161,9 +164,12 @@ {"hmac-sha1", 0, &dropbear_sha1, 1, NULL}, #endif #ifdef DROPBEAR_MD5_HMAC - {"hmac-md5", 0, &dropbear_md5, 1, NULL}, + {"hmac-md5", 0, (void*)&dropbear_md5, 1}, #endif - {NULL, 0, NULL, 0, NULL} +#ifdef DROPBEAR_NONE_INTEGRITY + {"none", 0, (void*)&dropbear_nohash, 1}, +#endif + {NULL, 0, NULL, 0} }; algo_type sshcompress[] = { diff -r b85507ade010 -r 582cb38e4eb5 common-kex.c --- a/common-kex.c Wed Nov 05 14:14:40 2008 +0000 +++ b/common-kex.c Thu Nov 06 13:16:55 2008 +0000 @@ -310,13 +310,35 @@ ses.newkeys->trans_algo_crypt->keysize, 0, &ses.newkeys->trans_cipher_state) != CRYPT_OK) { dropbear_exit("crypto error"); + if (ses.newkeys->recv_algo_crypt->cipherdesc != NULL) { + if (cbc_start( + find_cipher(ses.newkeys->recv_algo_crypt->cipherdesc->name), + recv_IV, recv_key, + ses.newkeys->recv_algo_crypt->keysize, 0, + &ses.newkeys->recv_symmetric_struct) != CRYPT_OK) { + dropbear_exit("crypto error"); + } + } + + if (ses.newkeys->trans_algo_crypt->cipherdesc != NULL) { + if (cbc_start( + find_cipher(ses.newkeys->trans_algo_crypt->cipherdesc->name), + trans_IV, trans_key, + ses.newkeys->trans_algo_crypt->keysize, 0, + &ses.newkeys->trans_symmetric_struct) != CRYPT_OK) { + dropbear_exit("crypto error"); + } } /* MAC keys */ - hashkeys(ses.newkeys->transmackey, - ses.newkeys->trans_algo_mac->keysize, &hs, mactransletter); - hashkeys(ses.newkeys->recvmackey, - ses.newkeys->recv_algo_mac->keysize, &hs, macrecvletter); + if (ses.newkeys->trans_algo_mac->hashdesc != NULL) { + hashkeys(ses.newkeys->transmackey, + ses.newkeys->trans_algo_mac->keysize, &hs, mactransletter); + } + if (ses.newkeys->recv_algo_mac->hashdesc != NULL) { + hashkeys(ses.newkeys->recvmackey, + ses.newkeys->recv_algo_mac->keysize, &hs, macrecvletter); + } #ifndef DISABLE_ZLIB gen_new_zstreams(); diff -r b85507ade010 -r 582cb38e4eb5 options.h --- a/options.h Wed Nov 05 14:14:40 2008 +0000 +++ b/options.h Thu Nov 06 13:16:55 2008 +0000 @@ -93,6 +93,17 @@ * CBC mode against certain attacks. This adds around 1kB to binary * size and is recommended for most cases */ #define DROPBEAR_ENABLE_CTR_MODE +/* You can compile with no encryption if you want. In some circumstances + * this could be safe securitywise, though make sure you know what + * you're doing. Anyone can see everything that goes over the wire, so + * the only safe auth method is public key. You'll have to disable all other + * ciphers above in the client if you want to use this, or implement cipher + * prioritisation in cli-runopts. + * + * The best way to do things is probably make normal compile of dropbear with + * all ciphers including "none" as the server, then recompile a special + * "dbclient-insecure" client. */ +#define DROPBEAR_NONE_CIPHER /* Message Integrity - at least one required. * Protocol RFC requires sha1 and recommends sha1-96. @@ -110,6 +121,12 @@ #define DROPBEAR_SHA1_96_HMAC #define DROPBEAR_MD5_HMAC +/* You can also disable integrity. Don't bother disabling this if you're + * still using a cipher, it's relatively cheap. Don't disable this if you're + * using 'none' cipher, since it's dead simple to run arbitrary commands + * on the remote host. Beware. */ +/*#define DROPBEAR_NONE_INTEGRITY*/ + /* Hostkey/public key algorithms - at least one required, these are used * for hostkey as well as for verifying signatures with pubkey auth. * Removing either of these won't save very much space.