This is some old code for bignum modular arithmetic using gnu mp. It's supposed to work, so far as it goes, or at least so far as described in the little manual for it (read it online), but is not being actively worked. See redc1 for some similar single-word code.
The best feature is a sub-quadratic version of Peter L. Montgomery's REDC algorithm, though it only becomes sub-quadratic above about perhaps 3500 bits. Function pointers do a dispatch to code specific to the modulus, so special moduli like 2^N-1 can be handled with a generic set of functions, and some parts of algorithm selection can be done at initialization.
Download version 2 here:
(Back to the sitemap.)