GMP API
Nikos Mavrogiannopoulos
nmav at gnutls.org
Tue Jun 22 18:30:38 CEST 2010
Hello,
Currently there is a fork of the GMP at libgcrypt (crypto library)[0],
and the main if not only reason is that the API for GMP does not allow
detection of out of memory situations, except for a callback. For
example in libgcrypt if I want to do multiplication I do:
gcry_mpi_t w = gcry_mpi_new(gcry_mpi_get_nbits(a)+gcry_mpi_get_nbits(b));
if (w==NULL) return -ENOMEM;
gcry_mpi_mul (w, a, b); /* always succeeds */
whilst in gmp:
mpz_init (w);
mpz_mul (w, a, b);
In the first case the application can return an error on the
out-of-memory condition whilst in the gmp case, the application cannot
control out of memory errors, except crashing or transfering control to
a callback that is not always useful.
My question is. Do you plan in GMP to support a "safe" API such as
libgcrypt's?
Having something like this will really help applications that are build
on the assumption that recovery from out-of-memory situations is
possible, to benefit from using GMP.
regards,
Nikos
[0]. The API of libgcrypt's gmp are the gcry_mpi_* functions.
http://www.koders.com/c/fid8BDDCED564A2F4B450D29E02EFB8B14BC8471EC0.aspx
More information about the gmp-devel
mailing list