Nikos Mavrogiannopoulos <[email protected]> writes:

> What about the attached patch?

Looks good! Some minor comments:

--- /dev/null
+++ b/bignum-internal.h

> +inline static void* _tmp_gmp_alloc(unsigned* out_n, size_t n)

> +inline static void _tmp_gmp_free(void* p, size_t n)

I don't think the _tmp prefix is needed, since these are declared
static.

Do you think it's important that these are inline functions? The
alternative is to put them in gmp-glue.c together with with
gmp_{alloc,free}_limbs, and then the TMP_GMP_*-macros could go in
nettle-internal.h.

> +#define TMP_GMP_DECL(name, type) type *name; \
> +     unsigned name##_gmp_size

Here, on the other hand, it might make sense with a prefix on the size
variable. Maybe __tmp_gmp_size##name or so (I tend to use __{NAME OF
MACRO}_ as prefix).

> diff --git a/pkcs1-decrypt.c b/pkcs1-decrypt.c
> index 02d3728..96016e0 100644
> --- a/pkcs1-decrypt.c
> +++ b/pkcs1-decrypt.c

>    if (*length < message_length)
> -    return 0;
> +    {
> +      ret = 0;
> +      goto err;
> +    }
>    
>    memcpy(message, terminator + 1, message_length);
>    *length = message_length;
>  
> -  return 1;
> +  ret = 1;
> +err:
> +  TMP_GMP_FREE(em);
> +  return ret;
>  }

"err" is maybe not the right name for the label, since the code is also
for successful termination. "done" or "cleanup" would be better.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.
_______________________________________________
nettle-bugs mailing list
[email protected]
http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs

Reply via email to