I am trying to implement the SAFER+ algorithm. The algorithm requires finding the modulus of a power function as follows:
pow(45, x) mod 257
The variable x is a byte, and thus can range from 0 to 255. Accordingly, the result of the power function can be VERY big resulting in incorrect values if implemented using 32- or 64-bit integers.
How can I perform this calculation?