Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for the new functions in bignum_new.c
That is, mbedtls_mpi_core_add_if(), mbedtls_mpi_core_sub(), mbedtls_mpi_core_mla() and mbedtls_mpi_core_montmul(). Also add unit tests for mpi_montg_init() (and rename it with mbedtls_ prefix). The tests for mbedtls_mpi_core_montmul() are also used to test the existing mpi_montmul() function (which too is renamed with mbedtls_ prefix). Some of these are replays of captured invocations during unit test runs. Others are generated. They use a mixture of primes and odd numbers for N, with four randomly-generated cases for each N. The test cases for mbedtls_mpi_core_add_if() and mbedtls_mpi_core_sub() use the following MPI values. For mbedtls_mpi_core_add_if() the .data file only includes those (a, b) values where a <= b, and gives the sum unconditionally; the test code exercises a >= b and cond == 0 using these values. The .data file gives two values for the carry out, which are for when sizeof(mbedtls_mpi_uint) == 4 or 8. For mbedtls_mpi_core_sub() the .data file includes two results, for the cases when sizeof(mbedtls_mpi_uint) == 4 or 8. 0 1 3 f fe ff 100 ff00 fffe ffff 10000 fffffffe ffffffff 100000000 1f7f7f7f7f7f7f 8000000000000000 fefefefefefefefe fffffffffffffffe ffffffffffffffff 10000000000000000 1234567890abcdef0 fffffffffffffffffefefefefefefefe fffffffffffffffffffffffffffffffe ffffffffffffffffffffffffffffffff 100000000000000000000000000000000 1234567890abcdef01234567890abcdef0 fffffffffffffffffffffffffffffffffffffffffffffffffefefefefefefefe fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 10000000000000000000000000000000000000000000000000000000000000000 1234567890abcdef01234567890abcdef01234567890abcdef01234567890abcdef0 4df72d07b4b71c8dacb6cffa954f8d88254b6277099308baf003fab73227f34029643b5a263f66e0d3c3fa297ef71755efd53b8fb6cb812c6bbf7bcf179298bd9947c4c8b14324140a2c0f5fad7958a69050a987a6096e9f055fb38edf0c5889eca4a0cfa99b45fbdeee4c696b328ddceae4723945901ec025076b12b The test cases for mbedtls_mpi_core_mla() use the following MPIs: 0 1 fffe ffffffff 100000000 20000000000000 ffffffffffffffff 10000000000000000 1234567890abcdef0 fffffffffffffffffefefefefefefefe 100000000000000000000000000000000 1234567890abcdef01234567890abcdef0 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 1234567890abcdef01234567890abcdef01234567890abcdef01234567890abcdef0 4df72d07b4b71c8dacb6cffa954f8d88254b6277099308baf003fab73227f34029643b5a263f66e0d3c3fa297ef71755efd53b8fb6cb812c6bbf7bcf179298bd9947c4c8b14324140a2c0f5fad7958a69050a987a6096e9f055fb38edf0c5889eca4a0cfa99b45fbdeee4c696b328ddceae4723945901ec025076b12b and the following scalars. The .data files include two sets of results (final accumulator and carry) for the cases sizeof(mbedtls_mpi_uint) == 4 or 8. 0 3 fe ff ffff 10000 ffffffff 100000000 7f7f7f7f7f7f7f7f 8000000000000000 fffffffffffffffe Signed-off-by: Tom Cosgrove <[email protected]>
- Loading branch information