From 8f70d3f4e23eb1033f4e25433881044124276eac Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 15 Jun 2021 22:01:23 +0200 Subject: [PATCH] Improve coverage of mbedtls_mpi_cmp_mpi Test with and without leading zeros on each side. Signed-off-by: Gilles Peskine --- tests/suites/test_suite_mpi.data | 68 ++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/tests/suites/test_suite_mpi.data b/tests/suites/test_suite_mpi.data index 6397cd61f..17eed9108 100644 --- a/tests/suites/test_suite_mpi.data +++ b/tests/suites/test_suite_mpi.data @@ -214,18 +214,78 @@ mbedtls_mpi_cmp_mpi:10:"0":10:"":0 Test mbedtls_mpi_cmp_mpi: 0 (1 limb) = 0 (1 limb) mbedtls_mpi_cmp_mpi:10:"0":10:"0":0 -Test mbedtls_mpi_cmp_mpi: 0 < positive +Test mbedtls_mpi_cmp_mpi: 0 (null) < positive +mbedtls_mpi_cmp_mpi:10:"":10:"123":-1 + +Test mbedtls_mpi_cmp_mpi: 0 (1 limb) < positive mbedtls_mpi_cmp_mpi:10:"0":10:"123":-1 -Test mbedtls_mpi_cmp_mpi: 0 > negative +Test mbedtls_mpi_cmp_mpi: 0 (null) > negative +mbedtls_mpi_cmp_mpi:10:"":10:"-123":1 + +Test mbedtls_mpi_cmp_mpi: 0 (1 limb) > negative mbedtls_mpi_cmp_mpi:10:"0":10:"-123":1 -Test mbedtls_mpi_cmp_mpi: positive > 0 +Test mbedtls_mpi_cmp_mpi: positive > 0 (null) mbedtls_mpi_cmp_mpi:10:"123":10:"":1 -Test mbedtls_mpi_cmp_mpi: negative < 0 +Test mbedtls_mpi_cmp_mpi: positive > 0 (1 limb) +mbedtls_mpi_cmp_mpi:10:"123":10:"0":1 + +Test mbedtls_mpi_cmp_mpi: negative < 0 (null) mbedtls_mpi_cmp_mpi:10:"-123":10:"":-1 +Test mbedtls_mpi_cmp_mpi: negative < 0 (1 limb) +mbedtls_mpi_cmp_mpi:10:"-123":10:"0":-1 + +Test mbedtls_mpi_cmp_mpi: 0 (null) < positive with leading zero limb +mbedtls_mpi_cmp_mpi:16:"":16:"0000000000000000123":-1 + +Test mbedtls_mpi_cmp_mpi: 0 (1 limb) < positive with leading zero limb +mbedtls_mpi_cmp_mpi:16:"0":16:"0000000000000000123":-1 + +Test mbedtls_mpi_cmp_mpi: 0 (null) > negative with leading zero limb +mbedtls_mpi_cmp_mpi:16:"":16:"-0000000000000000123":1 + +Test mbedtls_mpi_cmp_mpi: 0 (1 limb) > negative with leading zero limb +mbedtls_mpi_cmp_mpi:16:"0":16:"-0000000000000000123":1 + +Test mbedtls_mpi_cmp_mpi: positive with leading zero limb > 0 (null) +mbedtls_mpi_cmp_mpi:16:"0000000000000000123":16:"":1 + +Test mbedtls_mpi_cmp_mpi: positive with leading zero limb > 0 (1 limb) +mbedtls_mpi_cmp_mpi:16:"0000000000000000123":16:"0":1 + +Test mbedtls_mpi_cmp_mpi: negative with leading zero limb < 0 (null) +mbedtls_mpi_cmp_mpi:16:"-0000000000000000123":16:"":-1 + +Test mbedtls_mpi_cmp_mpi: negative with leading zero limb < 0 (1 limb) +mbedtls_mpi_cmp_mpi:16:"-0000000000000000123":16:"0":-1 + +Test mbedtls_mpi_cmp_mpi: 0 (null) < large positive +mbedtls_mpi_cmp_mpi:16:"":16:"1230000000000000000":-1 + +Test mbedtls_mpi_cmp_mpi: 0 (1 limb) < large positive +mbedtls_mpi_cmp_mpi:16:"0":16:"1230000000000000000":-1 + +Test mbedtls_mpi_cmp_mpi: 0 (null) > large negative +mbedtls_mpi_cmp_mpi:16:"":16:"-1230000000000000000":1 + +Test mbedtls_mpi_cmp_mpi: 0 (1 limb) > large negative +mbedtls_mpi_cmp_mpi:16:"0":16:"-1230000000000000000":1 + +Test mbedtls_mpi_cmp_mpi: large positive > 0 (null) +mbedtls_mpi_cmp_mpi:16:"1230000000000000000":16:"":1 + +Test mbedtls_mpi_cmp_mpi: large positive > 0 (1 limb) +mbedtls_mpi_cmp_mpi:16:"1230000000000000000":16:"0":1 + +Test mbedtls_mpi_cmp_mpi: large negative < 0 (null) +mbedtls_mpi_cmp_mpi:16:"-1230000000000000000":16:"":-1 + +Test mbedtls_mpi_cmp_mpi: large negative < 0 (1 limb) +mbedtls_mpi_cmp_mpi:16:"-1230000000000000000":16:"0":-1 + Base test mbedtls_mpi_lt_mpi_ct #1 mbedtls_mpi_lt_mpi_ct:1:"2B5":1:"2B5":0:0