projects
/
u
/
mdw
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update link to s2putty.
[u/mdw/putty]
/
sshdh.c
diff --git
a/sshdh.c
b/sshdh.c
index
2e16bbe
..
af7eaf8
100644
(file)
--- a/
sshdh.c
+++ b/
sshdh.c
@@
-52,7
+52,7
@@
static void dh_init(struct dh_ctx *ctx)
*/
void *dh_setup_group1(void)
{
*/
void *dh_setup_group1(void)
{
- struct dh_ctx *ctx = s
malloc(sizeof(struct dh_ctx)
);
+ struct dh_ctx *ctx = s
new(struct dh_ctx
);
ctx->p = bignum_from_bytes(P, sizeof(P));
ctx->g = bignum_from_bytes(G, sizeof(G));
dh_init(ctx);
ctx->p = bignum_from_bytes(P, sizeof(P));
ctx->g = bignum_from_bytes(G, sizeof(G));
dh_init(ctx);
@@
-64,7
+64,7
@@
void *dh_setup_group1(void)
*/
void *dh_setup_group(Bignum pval, Bignum gval)
{
*/
void *dh_setup_group(Bignum pval, Bignum gval)
{
- struct dh_ctx *ctx = s
malloc(sizeof(struct dh_ctx)
);
+ struct dh_ctx *ctx = s
new(struct dh_ctx
);
ctx->p = copybn(pval);
ctx->g = copybn(gval);
dh_init(ctx);
ctx->p = copybn(pval);
ctx->g = copybn(gval);
dh_init(ctx);
@@
-110,7
+110,7
@@
Bignum dh_create_e(void *handle, int nbits)
unsigned char *buf;
nbytes = ssh1_bignum_length(ctx->qmask);
unsigned char *buf;
nbytes = ssh1_bignum_length(ctx->qmask);
- buf = s
malloc(nbytes
);
+ buf = s
newn(nbytes, unsigned char
);
do {
/*
do {
/*
@@
-123,7
+123,7
@@
Bignum dh_create_e(void *handle, int nbits)
ssh1_write_bignum(buf, ctx->qmask);
for (i = 2; i < nbytes; i++)
buf[i] &= random_byte();
ssh1_write_bignum(buf, ctx->qmask);
for (i = 2; i < nbytes; i++)
buf[i] &= random_byte();
- ssh1_read_bignum(buf,
&ctx->x);
+ ssh1_read_bignum(buf,
nbytes, &ctx->x); /* can't fail */
} else {
int b, nb;
ctx->x = bn_power_2(nbits);
} else {
int b, nb;
ctx->x = bn_power_2(nbits);
@@
-140,6
+140,8
@@
Bignum dh_create_e(void *handle, int nbits)
}
} while (bignum_cmp(ctx->x, One) <= 0 || bignum_cmp(ctx->x, ctx->q) >= 0);
}
} while (bignum_cmp(ctx->x, One) <= 0 || bignum_cmp(ctx->x, ctx->q) >= 0);
+ sfree(buf);
+
/*
* Done. Now compute e = g^x mod p.
*/
/*
* Done. Now compute e = g^x mod p.
*/