GMP API

Werner Koch wk at gnupg.org
Tue Jun 22 23:15:24 CEST 2010


On Tue, 22 Jun 2010 18:30, nmav at gnutls.org said:

> gcry_mpi_t w = gcry_mpi_new(gcry_mpi_get_nbits(a)+gcry_mpi_get_nbits(b));
> if (w==NULL) return -ENOMEM;

I better should have checked the code first.  Here is the basic
allocation function:

  gcry_mpi_t
  _gcry_mpi_alloc( unsigned nlimbs )
  {
      gcry_mpi_t a;
  
      a = gcry_xmalloc( sizeof *a );
      a->d = nlimbs? mpi_alloc_limb_space( nlimbs, 0 ) : NULL;
  
as you can see there is no error checking at all.  I recall that we once
discussed how we can implement this but it has not been implemented. 

If such a feature is really required we may be able to do this with not
too much effort.  Every one else uses libcgrypt's out of core handler to
release some memory if libgcrypt runs on empty.


Salam-Shalom,

   Werner


-- 
Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.



More information about the gmp-devel mailing list