comparison common-algo.c @ 992:731f624af902

Add config option to disable cbc. Disable twofish by default
author Matt Johnston <matt@ucc.asn.au>
date Fri, 23 Jan 2015 22:37:14 +0800
parents c19acba28590
children 5c5ade336926
comparison
equal deleted inserted replaced
991:4f65c867fc99 992:731f624af902
82 const struct dropbear_cipher dropbear_nocipher = 82 const struct dropbear_cipher dropbear_nocipher =
83 {NULL, 16, 8}; 83 {NULL, 16, 8};
84 84
85 /* A few void* s are required to silence warnings 85 /* A few void* s are required to silence warnings
86 * about the symmetric_CBC vs symmetric_CTR cipher_state pointer */ 86 * about the symmetric_CBC vs symmetric_CTR cipher_state pointer */
87 #ifdef DROPBEAR_ENABLE_CBC_MODE
87 const struct dropbear_cipher_mode dropbear_mode_cbc = 88 const struct dropbear_cipher_mode dropbear_mode_cbc =
88 {(void*)cbc_start, (void*)cbc_encrypt, (void*)cbc_decrypt}; 89 {(void*)cbc_start, (void*)cbc_encrypt, (void*)cbc_decrypt};
90 #endif // DROPBEAR_ENABLE_CBC_MODE
91
89 const struct dropbear_cipher_mode dropbear_mode_none = 92 const struct dropbear_cipher_mode dropbear_mode_none =
90 {void_start, void_cipher, void_cipher}; 93 {void_start, void_cipher, void_cipher};
94
91 #ifdef DROPBEAR_ENABLE_CTR_MODE 95 #ifdef DROPBEAR_ENABLE_CTR_MODE
92 /* a wrapper to make ctr_start and cbc_start look the same */ 96 /* a wrapper to make ctr_start and cbc_start look the same */
93 static int dropbear_big_endian_ctr_start(int cipher, 97 static int dropbear_big_endian_ctr_start(int cipher,
94 const unsigned char *IV, 98 const unsigned char *IV,
95 const unsigned char *key, int keylen, 99 const unsigned char *key, int keylen,
96 int num_rounds, symmetric_CTR *ctr) { 100 int num_rounds, symmetric_CTR *ctr) {
97 return ctr_start(cipher, IV, key, keylen, num_rounds, CTR_COUNTER_BIG_ENDIAN, ctr); 101 return ctr_start(cipher, IV, key, keylen, num_rounds, CTR_COUNTER_BIG_ENDIAN, ctr);
98 } 102 }
99 const struct dropbear_cipher_mode dropbear_mode_ctr = 103 const struct dropbear_cipher_mode dropbear_mode_ctr =
100 {(void*)dropbear_big_endian_ctr_start, (void*)ctr_encrypt, (void*)ctr_decrypt}; 104 {(void*)dropbear_big_endian_ctr_start, (void*)ctr_encrypt, (void*)ctr_decrypt};
101 #endif 105 #endif // DROPBEAR_ENABLE_CTR_MODE
102 106
103 /* Mapping of ssh hashes to libtomcrypt hashes, including keysize etc. 107 /* Mapping of ssh hashes to libtomcrypt hashes, including keysize etc.
104 {&hash_desc, keysize, hashsize} */ 108 {&hash_desc, keysize, hashsize} */
105 109
106 #ifdef DROPBEAR_SHA1_HMAC 110 #ifdef DROPBEAR_SHA1_HMAC
143 #ifdef DROPBEAR_AES256 147 #ifdef DROPBEAR_AES256
144 {"aes256-ctr", 0, &dropbear_aes256, 1, &dropbear_mode_ctr}, 148 {"aes256-ctr", 0, &dropbear_aes256, 1, &dropbear_mode_ctr},
145 #endif 149 #endif
146 #endif /* DROPBEAR_ENABLE_CTR_MODE */ 150 #endif /* DROPBEAR_ENABLE_CTR_MODE */
147 151
148 /* CBC modes are always enabled */ 152 #ifdef DROPBEAR_ENABLE_CBC_MODE
149 #ifdef DROPBEAR_AES128 153 #ifdef DROPBEAR_AES128
150 {"aes128-cbc", 0, &dropbear_aes128, 1, &dropbear_mode_cbc}, 154 {"aes128-cbc", 0, &dropbear_aes128, 1, &dropbear_mode_cbc},
151 #endif 155 #endif
152 #ifdef DROPBEAR_3DES 156 #ifdef DROPBEAR_3DES
153 {"3des-cbc", 0, &dropbear_3des, 1, &dropbear_mode_cbc}, 157 {"3des-cbc", 0, &dropbear_3des, 1, &dropbear_mode_cbc},
163 {"twofish128-cbc", 0, &dropbear_twofish128, 1, &dropbear_mode_cbc}, 167 {"twofish128-cbc", 0, &dropbear_twofish128, 1, &dropbear_mode_cbc},
164 #endif 168 #endif
165 #ifdef DROPBEAR_BLOWFISH 169 #ifdef DROPBEAR_BLOWFISH
166 {"blowfish-cbc", 0, &dropbear_blowfish, 1, &dropbear_mode_cbc}, 170 {"blowfish-cbc", 0, &dropbear_blowfish, 1, &dropbear_mode_cbc},
167 #endif 171 #endif
172 #endif /* DROPBEAR_ENABLE_CBC_MODE */
168 #ifdef DROPBEAR_NONE_CIPHER 173 #ifdef DROPBEAR_NONE_CIPHER
169 {"none", 0, (void*)&dropbear_nocipher, 1, &dropbear_mode_none}, 174 {"none", 0, (void*)&dropbear_nocipher, 1, &dropbear_mode_none},
170 #endif 175 #endif
171 {NULL, 0, NULL, 0, NULL} 176 {NULL, 0, NULL, 0, NULL}
172 }; 177 };