X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=secnet.git;a=blobdiff_plain;f=dh.c;h=54d3102e00163bebf9b45d581dbcbfee2e32766f;hp=2383192fdc4ea2e807fc353e30b67e9a1a9130cd;hb=b7886fd46ab05c97b8a072e497903622bd1d5290;hpb=1caa23ff879cec7f8f36b32a987f0610291ef177 diff --git a/dh.c b/dh.c index 2383192..54d3102 100644 --- a/dh.c +++ b/dh.c @@ -63,7 +63,7 @@ static list_t *dh_apply(closure_t *self, struct cloc loc, dict_t *context, string_t p,g; item_t *i; - st=safe_malloc(sizeof(*st),"dh_apply"); + NEW(st); st->cl.description="dh"; st->cl.type=CL_DH; st->cl.apply=NULL; @@ -125,6 +125,10 @@ static list_t *dh_apply(closure_t *self, struct cloc loc, dict_t *context, st->ops.len=sz; + st->ops.ceil_len=(mpz_sizeinbase(&st->p,2)+7)/8; + /* According to the docs, mpz_sizeinbase(,256) is allowed to return + * an answer which is 1 too large. But mpz_sizeinbase(,2) isn't. */ + return new_closure(&st->cl); }