I am playing around in PHP with RSA and big numbers. I need to be able to take numbers to the power of an exponent that has ~256 to ~512 bytes using gmp_pow(). Does anyone have any suggestions?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You should use gmp_powm() which automatically reduces the intermediate values to be less than the modulus value. This exactly what you want for RSA.
gmp_pow() doesn't accept an exponent large than a long since the intermediate values will be larger than the addressable memory in your computer.