32
32
/* Mappings for ciphers, parameters are
33
33
{&cipher_desc, keysize, blocksize} */
35
#ifdef DROPBEAR_AES256_CBC
36
static const struct dropbear_cipher dropbear_aes256 =
35
39
#ifdef DROPBEAR_AES128_CBC
36
const struct dropbear_cipher dropbear_aes128 =
40
static const struct dropbear_cipher dropbear_aes128 =
37
41
{&aes_desc, 16, 16};
39
43
#ifdef DROPBEAR_BLOWFISH_CBC
40
const struct dropbear_cipher dropbear_blowfish =
44
static const struct dropbear_cipher dropbear_blowfish =
41
45
{&blowfish_desc, 16, 8};
47
#ifdef DROPBEAR_TWOFISH256_CBC
48
static const struct dropbear_cipher dropbear_twofish256 =
49
{&twofish_desc, 32, 16};
43
51
#ifdef DROPBEAR_TWOFISH128_CBC
44
const struct dropbear_cipher dropbear_twofish128 =
52
static const struct dropbear_cipher dropbear_twofish128 =
45
53
{&twofish_desc, 16, 16};
47
55
#ifdef DROPBEAR_3DES_CBC
48
const struct dropbear_cipher dropbear_3des =
56
static const struct dropbear_cipher dropbear_3des =
49
57
{&des3_desc, 24, 8};
57
65
{&hash_desc, keysize, hashsize} */
59
67
#ifdef DROPBEAR_SHA1_HMAC
60
const struct dropbear_hash dropbear_sha1 =
68
static const struct dropbear_hash dropbear_sha1 =
61
69
{&sha1_desc, 20, 20};
71
#ifdef DROPBEAR_SHA1_96_HMAC
72
static const struct dropbear_hash dropbear_sha1_96 =
63
75
#ifdef DROPBEAR_MD5_HMAC
64
const struct dropbear_hash dropbear_md5 =
76
static const struct dropbear_hash dropbear_md5 =
65
77
{&md5_desc, 16, 16};
75
87
#ifdef DROPBEAR_AES128_CBC
76
88
{"aes128-cbc", 0, (void*)&dropbear_aes128, 1},
90
#ifdef DROPBEAR_3DES_CBC
91
{"3des-cbc", 0, (void*)&dropbear_3des, 1},
93
#ifdef DROPBEAR_AES256_CBC
94
{"aes256-cbc", 0, (void*)&dropbear_aes256, 1},
96
#ifdef DROPBEAR_TWOFISH256_CBC
97
{"twofish256-cbc", 0, (void*)&dropbear_twofish256, 1},
98
{"twofish-cbc", 0, (void*)&dropbear_twofish256, 1},
100
#ifdef DROPBEAR_TWOFISH128_CBC
101
{"twofish128-cbc", 0, (void*)&dropbear_twofish128, 1},
78
103
#ifdef DROPBEAR_BLOWFISH_CBC
79
104
{"blowfish-cbc", 0, (void*)&dropbear_blowfish, 1},
81
#ifdef DROPBEAR_TWOFISH128_CBC
82
{"twofish-cbc", 0, (void*)&dropbear_twofish128, 1},
84
#ifdef DROPBEAR_3DES_CBC
85
{"3des-cbc", 0, (void*)&dropbear_3des, 1},
87
106
{NULL, 0, NULL, 0}
90
109
algo_type sshhashes[] = {
110
#ifdef DROPBEAR_SHA1_96_HMAC
111
{"hmac-sha1-96", 0, (void*)&dropbear_sha1_96, 1},
91
113
#ifdef DROPBEAR_SHA1_HMAC
92
114
{"hmac-sha1", 0, (void*)&dropbear_sha1, 1},
100
122
algo_type sshcompress[] = {
101
{"none", DROPBEAR_COMP_NONE, NULL, 1},
102
123
#ifndef DISABLE_ZLIB
103
124
{"zlib", DROPBEAR_COMP_ZLIB, NULL, 1},
126
{"none", DROPBEAR_COMP_NONE, NULL, 1},
105
127
{NULL, 0, NULL, 0}
125
147
* This should be run before using any of the ciphers/hashes */
126
148
void crypto_init() {
128
const struct _cipher_descriptor *regciphers[] = {
129
#ifdef DROPBEAR_AES128_CBC
150
const struct ltc_cipher_descriptor *regciphers[] = {
151
#ifdef DROPBEAR_AES_CBC
132
154
#ifdef DROPBEAR_BLOWFISH_CBC
135
#ifdef DROPBEAR_TWOFISH128_CBC
157
#ifdef DROPBEAR_TWOFISH_CBC
138
160
#ifdef DROPBEAR_3DES_CBC
187
209
/* Output a comma separated list of algorithms to a buffer */
188
210
void buf_put_algolist(buffer * buf, algo_type localalgos[]) {
190
unsigned int pos = 0, i, len;
191
char str[50]; /* enough for local algo storage */
213
unsigned int donefirst = 0;
214
buffer *algolist = NULL;
216
algolist = buf_new(100);
193
217
for (i = 0; localalgos[i].name != NULL; i++) {
194
218
if (localalgos[i].usable) {
195
/* Avoid generating a trailing comma */
220
buf_putbyte(algolist, ',');
198
222
len = strlen(localalgos[i].name);
199
memcpy(&str[pos], localalgos[i].name, len);
223
buf_putbytes(algolist, localalgos[i].name, len);
205
TRACE(("buf_put_algolist: %s", str))
206
buf_putstring(buf, str, pos);
226
buf_putstring(buf, algolist->data, algolist->len);