1
0
mirror of http://galexander.org/git/simplesshd.git synced 2024-10-31 20:40:22 +00:00
simplesshd/dropbear/crypto_desc.c

76 lines
1.3 KiB
C
Raw Normal View History

2014-12-10 21:56:49 +00:00
#include "includes.h"
#include "dbutil.h"
#include "crypto_desc.h"
#include "ltc_prng.h"
#include "ecc.h"
2019-06-09 20:44:26 +00:00
#if DROPBEAR_LTC_PRNG
2014-12-10 21:56:49 +00:00
int dropbear_ltc_prng = -1;
#endif
/* Register the compiled in ciphers.
* This should be run before using any of the ciphers/hashes */
void crypto_init() {
const struct ltc_cipher_descriptor *regciphers[] = {
2019-06-09 20:44:26 +00:00
#if DROPBEAR_AES
2014-12-10 21:56:49 +00:00
&aes_desc,
#endif
2019-06-09 20:44:26 +00:00
#if DROPBEAR_BLOWFISH
2014-12-10 21:56:49 +00:00
&blowfish_desc,
#endif
2019-06-09 20:44:26 +00:00
#if DROPBEAR_TWOFISH
2014-12-10 21:56:49 +00:00
&twofish_desc,
#endif
2019-06-09 20:44:26 +00:00
#if DROPBEAR_3DES
2014-12-10 21:56:49 +00:00
&des3_desc,
#endif
NULL
};
const struct ltc_hash_descriptor *reghashes[] = {
/* we need sha1 for hostkey stuff regardless */
&sha1_desc,
2019-06-09 20:44:26 +00:00
#if DROPBEAR_MD5_HMAC
2014-12-10 21:56:49 +00:00
&md5_desc,
#endif
2019-06-09 20:44:26 +00:00
#if DROPBEAR_SHA256
2014-12-10 21:56:49 +00:00
&sha256_desc,
#endif
2019-06-09 20:44:26 +00:00
#if DROPBEAR_SHA384
2014-12-10 21:56:49 +00:00
&sha384_desc,
#endif
2019-06-09 20:44:26 +00:00
#if DROPBEAR_SHA512
2014-12-10 21:56:49 +00:00
&sha512_desc,
#endif
NULL
};
int i;
for (i = 0; regciphers[i] != NULL; i++) {
if (register_cipher(regciphers[i]) == -1) {
dropbear_exit("Error registering crypto");
}
}
for (i = 0; reghashes[i] != NULL; i++) {
if (register_hash(reghashes[i]) == -1) {
dropbear_exit("Error registering crypto");
}
}
2019-06-09 20:44:26 +00:00
#if DROPBEAR_LTC_PRNG
2014-12-10 21:56:49 +00:00
dropbear_ltc_prng = register_prng(&dropbear_prng_desc);
if (dropbear_ltc_prng == -1) {
dropbear_exit("Error registering crypto");
}
#endif
2019-06-09 20:44:26 +00:00
#if DROPBEAR_ECC
2014-12-10 21:56:49 +00:00
ltc_mp = ltm_desc;
dropbear_ecc_fill_dp();
#endif
}