I'm working on some RSA code that uses Toms Fast Math (TFM for short), and I'm trying to understand why the functions fp_exptmod
(for modular exponentiation operations) and fp_invmod
(for modular inverse operations) both require an odd modulus and the former also requires an odd exponent. I've written code to allow the use of evens, but TFM is built with crypto in mind, so I'm thinking maybe allowing evens isn't necessary or even desired? Still, even though my math-fu isn't as strong as it could be, I would think limiting the choices of exponent and modulus to only half (i.e. only odds) of all natural numbers would give bad actors a head start that we don't want.
Asked more generically, in the context of generating strong RSA keys, is the use of odd exponent and modulus for modular exponentiation operations and the use of an odd modulus for modular inverse operations required? If not, is there a benefit to including evens?