mirror of
https://github.com/clearml/dropbear
synced 2025-03-09 13:30:45 +00:00
- Add hmac-sha2-256 and hmac-sha2-512. Needs debugging, seems to be
getting keyed incorrectly --HG-- branch : sha2
This commit is contained in:
parent
10d7a35841
commit
c62e53807f
@ -106,6 +106,14 @@ static const struct dropbear_hash dropbear_sha1 =
|
||||
static const struct dropbear_hash dropbear_sha1_96 =
|
||||
{&sha1_desc, 20, 12};
|
||||
#endif
|
||||
#ifdef DROPBEAR_SHA2_256_HMAC
|
||||
static const struct dropbear_hash dropbear_sha2_256 =
|
||||
{&sha256_desc, 32, 32};
|
||||
#endif
|
||||
#ifdef DROPBEAR_SHA2_512_HMAC
|
||||
static const struct dropbear_hash dropbear_sha2_512 =
|
||||
{&sha512_desc, 64, 64};
|
||||
#endif
|
||||
#ifdef DROPBEAR_MD5_HMAC
|
||||
static const struct dropbear_hash dropbear_md5 =
|
||||
{&md5_desc, 16, 16};
|
||||
@ -156,6 +164,12 @@ algo_type sshciphers[] = {
|
||||
};
|
||||
|
||||
algo_type sshhashes[] = {
|
||||
#ifdef DROPBEAR_SHA2_256_HMAC
|
||||
// {"hmac-sha2-256", 0, &dropbear_sha2_256, 1, NULL},
|
||||
#endif
|
||||
#ifdef DROPBEAR_SHA2_512_HMAC
|
||||
// {"hmac-sha2-512", 0, &dropbear_sha2_512, 1, NULL},
|
||||
#endif
|
||||
#ifdef DROPBEAR_SHA1_96_HMAC
|
||||
{"hmac-sha1-96", 0, &dropbear_sha1_96, 1, NULL},
|
||||
#endif
|
||||
|
14
common-kex.c
14
common-kex.c
@ -248,26 +248,28 @@ static void kexinitialise() {
|
||||
* already initialised hash_state hs, which should already have processed
|
||||
* the dh_K and hash, since these are common. X is the letter 'A', 'B' etc.
|
||||
* out must have at least min(SHA1_HASH_SIZE, outlen) bytes allocated.
|
||||
* The output will only be expanded once, as we are assured that
|
||||
* outlen <= 2*SHA1_HASH_SIZE for all known hashes.
|
||||
*
|
||||
* See Section 7.2 of rfc4253 (ssh transport) for details */
|
||||
static void hashkeys(unsigned char *out, int outlen,
|
||||
const hash_state * hs, const unsigned char X) {
|
||||
|
||||
hash_state hs2;
|
||||
unsigned char k2[SHA1_HASH_SIZE]; /* used to extending */
|
||||
int offset;
|
||||
|
||||
memcpy(&hs2, hs, sizeof(hash_state));
|
||||
sha1_process(&hs2, &X, 1);
|
||||
sha1_process(&hs2, ses.session_id, SHA1_HASH_SIZE);
|
||||
sha1_done(&hs2, out);
|
||||
if (SHA1_HASH_SIZE < outlen) {
|
||||
for (offset = SHA1_HASH_SIZE;
|
||||
offset < outlen;
|
||||
offset += SHA1_HASH_SIZE)
|
||||
{
|
||||
/* need to extend */
|
||||
unsigned char k2[SHA1_HASH_SIZE];
|
||||
memcpy(&hs2, hs, sizeof(hash_state));
|
||||
sha1_process(&hs2, out, SHA1_HASH_SIZE);
|
||||
sha1_process(&hs2, out, offset);
|
||||
sha1_done(&hs2, k2);
|
||||
memcpy(&out[SHA1_HASH_SIZE], k2, outlen - SHA1_HASH_SIZE);
|
||||
memcpy(&out[offset], k2, MIN(outlen - offset, SHA1_HASH_SIZE));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,16 +118,20 @@
|
||||
#define LTC_CTR_MODE
|
||||
#endif
|
||||
|
||||
#if defined(DROPBEAR_DSS) && defined(DSS_PROTOK)
|
||||
#define SHA512
|
||||
#endif
|
||||
|
||||
#define SHA1
|
||||
|
||||
#ifdef DROPBEAR_MD5_HMAC
|
||||
#ifdef DROPBEAR_MD5
|
||||
#define MD5
|
||||
#endif
|
||||
|
||||
#ifdef DROPBEAR_SHA256
|
||||
#define SHA256
|
||||
#endif
|
||||
|
||||
#ifdef DROPBEAR_SHA512
|
||||
#define SHA512
|
||||
#endif
|
||||
|
||||
#define LTC_HMAC
|
||||
|
||||
/* Various tidbits of modern neatoness */
|
||||
|
@ -112,6 +112,8 @@ much traffic. */
|
||||
|
||||
#define DROPBEAR_SHA1_HMAC
|
||||
#define DROPBEAR_SHA1_96_HMAC
|
||||
#define DROPBEAR_SHA2_256_HMAC
|
||||
#define DROPBEAR_SHA2_512_HMAC
|
||||
#define DROPBEAR_MD5_HMAC
|
||||
|
||||
/* Hostkey/public key algorithms - at least one required, these are used
|
||||
|
19
sysoptions.h
19
sysoptions.h
@ -90,7 +90,13 @@
|
||||
#define MAX_KEY_LEN 32 /* 256 bits for aes256 etc */
|
||||
#define MAX_IV_LEN 20 /* must be same as max blocksize,
|
||||
and >= SHA1_HASH_SIZE */
|
||||
#if defined(DROPBEAR_SHA2_512_HMAC)
|
||||
#define MAX_MAC_KEY 64
|
||||
#elif defined(DROPBEAR_SHA2_256_HMAC)
|
||||
#define MAX_MAC_KEY 32
|
||||
#else
|
||||
#define MAX_MAC_KEY 20
|
||||
#endif
|
||||
|
||||
#define MAX_NAME_LEN 64 /* maximum length of a protocol name, isn't
|
||||
explicitly specified for all protocols (just
|
||||
@ -144,6 +150,19 @@
|
||||
#define DROPBEAR_TWOFISH
|
||||
#endif
|
||||
|
||||
#ifdef DROPBEAR_MD5_HMAC
|
||||
#define DROPBEAR_MD5
|
||||
#endif
|
||||
|
||||
#ifdef DROPBEAR_SHA2_256_HMAC
|
||||
#define DROPBEAR_SHA256
|
||||
#endif
|
||||
|
||||
#if (defined(DROPBEAR_DSS) && defined(DSS_PROTOK)) \
|
||||
|| defined(DROPBEAR_SHA2_512_HMAC)
|
||||
#define DROPBEAR_SHA512
|
||||
#endif
|
||||
|
||||
#ifndef ENABLE_X11FWD
|
||||
#define DISABLE_X11FWD
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user