From: simon Date: Mon, 23 Oct 2000 15:18:37 +0000 (+0000) Subject: Fix a bug which was causing occasional failed-host-key-check X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/commitdiff_plain/9c6214334f866ab91173df992180e168c17f904d Fix a bug which was causing occasional failed-host-key-check messages. Also left some diagnostics in, under #if 0, so that next time this happens it'll be easier to debug. git-svn-id: svn://svn.tartarus.org/sgt/putty@749 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/sshdss.c b/sshdss.c index 01c452b9..1bdaed5d 100644 --- a/sshdss.c +++ b/sshdss.c @@ -15,6 +15,29 @@ (cp)[2] = (unsigned char)((value) >> 8); \ (cp)[3] = (unsigned char)(value); } +#if 0 +#define DEBUG_DSS +/* + * Condition this section in for debugging of DSS. + */ +static void diagbn(char *prefix, Bignum md) { + int i, nibbles, morenibbles; + static const char hex[] = "0123456789ABCDEF"; + + printf("%s0x", prefix ? prefix : ""); + + nibbles = (3 + ssh1_bignum_bitcount(md))/4; if (nibbles<1) nibbles=1; + morenibbles = 4*md[0] - nibbles; + for (i=0; i> (4*(i%2))) & 0xF]); + + if (prefix) putchar('\n'); +} +#else +#define diagbn(x,y) +#endif + static void getstring(char **data, int *datalen, char **p, int *length) { *p = NULL; if (*datalen < 4) @@ -44,6 +67,7 @@ static Bignum getmp(char **data, int *datalen) { else b[j/2+1] |= ((unsigned char)p[i]); } + while (b[0] > 1 && b[b[0]] == 0) b[0]--; return b; } @@ -75,6 +99,17 @@ static void dss_setkey(char *data, int len) { char *p; int slen; getstring(&data, &len, &p, &slen); + +#ifdef DEBUG_DSS + { + int i; + printf("key:"); + for (i=0;i