mirror of
https://github.com/cuberite/polarssl.git
synced 2025-10-04 02:52:38 -04:00

This patch adds the test for the method calculating the RR. The input/expected data are generated manually using the following Python3 snippet: ~~~~~ import math title="mpi_get_montgomery_constant_unsafe" tt = title + " #{}" in_data = [ "0f", ... ] def limb_no(number, bil=64): return int(math.ceil(int.bit_length(number)/(bil * 1.0))) def calc_rr(number, bil=64 ): return '{:x}'.format(pow(pow(2, limb_no(number, bil) * bil), 2, number)) def calc_rr_str(number, prefix=""): rr64 = calc_rr(number) rr32 = calc_rr(number, bil=32) return '{}:"{:x}":"{}":"{}"'.format(prefix,number, rr32, rr64) print("\n\n".join(["{}\n{}".format(tt.format(in_data.index(v)+1), calc_rr_str(int(v,base=16), title)) for v in in_data])) ~~~~~ Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>