GMP API

Torbjorn Granlund tg at gmplib.org
Tue Jun 22 18:59:13 CEST 2010


The first thing to understand is that it is not sufficient to ensure
that destination variables space needs can be met; internal scratch
space needs might also trigger out-of-memory conditions.  These needs
are far from easy to compute beforehand, even if we tried to supply such
an interface.  (And if one computed them beforehand, one would have a
race condition for VM.)

It would slow down and complicate GMP if we tried to flag ourselves out
of error situations like memory allocation problems.  Many internal
calls would need to be checked, which would require redesign of many
internal function, to add an error return mechanism.

For crypto usages, it should not be very hard to use documented mpn
routines which do not allocate space.  Unfortunately, we don't currently
document O(n^2) multiplication or division functions, only more
primitive and more general functions.  For cryptographic applications,
O(n^2) mul and div/mod should be what one needs.

-- 
Torbjörn


More information about the gmp-devel mailing list