SPRUJ17H March 2022 – October 2024 AM2631 , AM2631-Q1 , AM2632 , AM2632-Q1 , AM2634 , AM2634-Q1
The MODINVp operation requires the modulus to be odd. At first, this appears to make the operation useless in the case of RSA key generation where the private key exponent d is derived from a chosen public exponent 'e' as follows:
d = ModInvp(e, φ), where φ = (p-1)·(q-1) and p and q both prime
Note that φ is even. However, since 'e' must be odd (otherwise no inverse exists), d can be calculated as:
d = (1 + (φ · (e – MODINVp(φ, e))) / e
So with four additional basic PKCP operations, MODINVp can also be used to find inverse values in case the modulus is even.