|LIBMP(3)||FreeBSD Library Functions Manual||LIBMP(3)|
NAMElibmp — traditional BSD multiple precision integer arithmetic library
SYNOPSIS#include < mp.h>
Function prototypes are given in the main body of the text.
Applications using this interface must be linked with -lmp (this library) and -lcrypto ( crypto(3)).
libmp is the traditional BSD multiple precision integer arithmetic library. It has a number of problems, and is unsuitable for use in any programs where reliability is a concern. It is provided here for compatibility only.
These routines perform arithmetic on integers of arbitrary precision stored using the defined type MINT. Pointers to MINT are initialized using mp_itom() or mp_xtom(), and must be recycled with mp_mfree() when they are no longer needed. Routines which store a result in one of their arguments expect that the latter has also been initialized prior to being passed to it. The following routines are defined and implemented:
MINT *mp_itom( short n);
MINT *mp_xtom( const char *s);
char *mp_mtox( const MINT *mp);
void mp_mfree( MINT *mp);
void mp_madd( const MINT *mp1, const MINT *mp2, MINT *rmp);
void mp_msub( const MINT *mp1, const MINT *mp2, MINT *rmp);
void mp_mult( const MINT *mp1, const MINT *mp2, MINT *rmp);
void mp_mdiv( const MINT *nmp, const MINT *dmp, MINT *qmp, MINT *rmp);
void mp_sdiv( const MINT *nmp, short d, MINT *qmp, short *ro);
void mp_pow( const MINT *bmp, const MINT *emp, const MINT *mmp, MINT *rmp);
void mp_rpow( const MINT *bmp, short e, MINT *rmp);
void mp_min( MINT *mp);
void mp_mout( const MINT *mp);
void mp_gcd( const MINT *mp1, const MINT *mp2, MINT *rmp);
int mp_mcmp( const MINT *mp1, const MINT *mp2);
void mp_move( const MINT *smp, MINT *tmp);
void mp_msqrt( const MINT *nmp, MINT *xmp, MINT *rmp);
IMPLEMENTATION NOTESThis version of libmp is implemented in terms of the crypto(3) BIGNUM library.
DIAGNOSTICSRunning out of memory or illegal operations result in error messages on standard error and a call to abort(3).
HISTORYA libmp library appeared in 4.3BSD. FreeBSD 2.2 shipped with a libmp implemented in terms of libgmp. This implementation appeared in FreeBSD 5.0.
BUGSErrors are reported via output to standard error and abnormal program termination instead of via return values. The application cannot control this behavior.
It is not clear whether the string returned by mp_mtox() may be written to by the caller. This implementation allows it, but others may not. Ideally, mp_mtox() would take a pointer to a buffer to fill in.
It is not clear whether using the same variable as both source and destination in a single invocation is permitted. Some of the calls in this implementation allow this, while others do not.
|September 7, 1989||FreeBSD|