/*************************************************************************** * Copyright (C) 2010 by Michael Fischer * * fischer-michael@cs.yale.edu * * * * For use in Yale course CPSC 467b, Spring 2010 * ***************************************************************************/ Sample files for using the gmp and the openssl/bn big number libraries. These programs take three command line arguments a b c, compute a^b (mod c), and print out the result, along with the elapsed time. Both simply invoke the modular exponentiation function in their respective packages -- mpz_powm() for gmp and BN_mod_exp() for openssl/bn. They illustrate how to set up big number variables, how to convert from long decimal integers to the internal bignum format, how to print bignums in decimal, and how to free memory so as to avoid memory leaks. The stopwatch module is used to obtain the elapsed times. You can try both modexp packages to see which runs faster on your machine with the size numbers you are interested in. On my machine, with moderate sized numbers, gmp seems to take only about 2/3 the time of openssl/bn. However, the elapsed times vary considerably from run to run because of caching and other activity going on in my machine.