~mdw
/
sgt
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update the text format of the public key as the comment box is edited
[sgt/putty]
/
sshbn.c
diff --git
a/sshbn.c
b/sshbn.c
index
aea5a82
..
3a5ddc0
100644
(file)
--- a/
sshbn.c
+++ b/
sshbn.c
@@
-6,6
+6,14
@@
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
+#if 0 // use PuTTY main debugging for diagbn()
+#include <windows.h>
+#include "putty.h"
+#define debugprint debug
+#else
+#define debugprint(x) printf x
+#endif
+
#define BIGNUM_INTERNAL
typedef unsigned short *Bignum;
#define BIGNUM_INTERNAL
typedef unsigned short *Bignum;
@@
-289,7
+297,7
@@
Bignum modmul(Bignum p, Bignum q, Bignum mod)
{
unsigned short *a, *n, *m, *o;
int mshift;
{
unsigned short *a, *n, *m, *o;
int mshift;
- int pqlen, mlen, i, j;
+ int pqlen, mlen,
rlen,
i, j;
Bignum result;
/* Allocate m of size mlen, copy mod to m */
Bignum result;
/* Allocate m of size mlen, copy mod to m */
@@
-339,9
+347,10
@@
Bignum modmul(Bignum p, Bignum q, Bignum mod)
}
/* Copy result to buffer */
}
/* Copy result to buffer */
- result = newbn(mod[0]);
- for (i = 0; i < mlen; i++)
- result[result[0] - i] = a[i+2*pqlen-mlen];
+ rlen = (mlen < pqlen*2 ? mlen : pqlen*2);
+ result = newbn(rlen);
+ for (i = 0; i < rlen; i++)
+ result[result[0] - i] = a[i+2*pqlen-rlen];
while (result[0] > 1 && result[result[0]] == 0) result[0]--;
/* Free temporary arrays */
while (result[0] > 1 && result[result[0]] == 0) result[0]--;
/* Free temporary arrays */
@@
-713,15
+722,15
@@
void diagbn(char *prefix, Bignum md) {
int i, nibbles, morenibbles;
static const char hex[] = "0123456789ABCDEF";
int i, nibbles, morenibbles;
static const char hex[] = "0123456789ABCDEF";
-
printf("%s0x", prefix ? prefix : ""
);
+
debugprint(("%s0x", prefix ? prefix : "")
);
nibbles = (3 + ssh1_bignum_bitcount(md))/4; if (nibbles<1) nibbles=1;
morenibbles = 4*md[0] - nibbles;
nibbles = (3 + ssh1_bignum_bitcount(md))/4; if (nibbles<1) nibbles=1;
morenibbles = 4*md[0] - nibbles;
- for (i=0; i<morenibbles; i++)
putchar('-'
);
+ for (i=0; i<morenibbles; i++)
debugprint(("-")
);
for (i=nibbles; i-- ;)
for (i=nibbles; i-- ;)
-
putchar(hex[(bignum_byte(md, i/2) >> (4*(i%2))) & 0xF]
);
+
debugprint(("%c",hex[(bignum_byte(md, i/2) >> (4*(i%2))) & 0xF])
);
- if (prefix)
putchar('\n'
);
+ if (prefix)
debugprint(("\n")
);
}
/*
}
/*