f2334b7b39
Remove new bignum when not needed
...
New bignum modules are only needed when the new ecp_curves module is
present. Remove them when they are not needed to save code size.
Signed-off-by: Janos Follath <janos.follath@arm.com >
2023-08-17 14:36:59 +01:00
0540fe74e3
Fix code style
...
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com >
2023-07-27 14:17:27 +01:00
e4e9e7da58
For tests, rename TEST_BUFFERS_EQUAL() to TEST_MEMORY_COMPARE()
...
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com >
2023-07-21 11:45:25 +01:00
05b2a87ea0
For tests, rename TEST_CALLOC_OR_FAIL() to just TEST_CALLOC()
...
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com >
2023-07-21 11:32:25 +01:00
f9ffd11e7a
For tests, rename ASSERT_ALLOC() to TEST_CALLOC_OR_FAIL()
...
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com >
2023-07-20 16:51:21 +01:00
65cd8519f7
For tests, rename ASSERT_COMPARE() to TEST_BUFFERS_EQUAL()
...
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com >
2023-07-20 16:51:15 +01:00
88e16dfa2a
bignum_mod: Refactored mbedtls_mpi_mod_modulus_setup()
...
This patch removes the `int_rep` input parameter for modular
setup, aiming to align it with the optred variant.
Test and test-suite helper functions have been updated
accordingly.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2023-06-16 13:48:47 +01:00
00bd8925a7
bignum: Removed merge scaffolding.
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2023-04-05 16:13:11 +01:00
86c90fca3e
Rename variables to follow the naming convention
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com >
2023-01-24 14:21:10 +01:00
ee2aff2093
Add check for test input
...
The input for fix_quasi_reduction must be in range 0 <= X < 2N.
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com >
2023-01-24 14:21:05 +01:00
9073f7dd3b
Remove unneeded check
...
The fix_quasi_reduction function changed to static so checking the
invalid arguments are not needed anymore.
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com >
2023-01-23 19:05:37 +01:00
e81a2b85c9
Change the fix_quasi_reduction function to static
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com >
2023-01-23 18:58:20 +01:00
aaa1d2a276
Move the quasi reduction fixing function to bignum_mod_raw
...
Rename the function to 'fix_quasi_reduction' to better suite its functionality.
Also changed the name prefix to suite for the new module.
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com >
2023-01-23 18:55:57 +01:00
449bd8303e
Switch to the new code style
...
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com >
2023-01-11 14:50:10 +01:00
2fcb4c1d06
Merge pull request #6747 from gilles-peskine-arm/bignum-mod-random
...
Bignum mod random
2022-12-23 10:36:22 +01:00
4c950d5ff1
Cosmetic fix
...
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com >
2022-12-20 22:02:55 +01:00
1e2a4d4089
Functions to convert raw residues to/from the modulus representation
...
Test cases will be generated automatically by a subsequent commit.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com >
2022-12-20 19:55:51 +01:00
e162b4725c
Merge pull request #6777 from tom-cosgrove-arm/issue-6292-mod_inv
...
Bignum: Implement high level fixed width modular inversion
2022-12-17 13:26:02 +01:00
b31b2e62ec
Generate operands in Mongomery representation for the test function
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com >
2022-12-16 14:27:48 +01:00
786848b5c5
Add low-level Montgomery conversion functions to bignum_core
...
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com >
2022-12-15 16:56:36 +00:00
28ff92cc3a
Add an explicit mbedtls_mpi_core_montmul_working_limbs() function
...
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com >
2022-12-15 16:56:36 +00:00
80a334ada3
Add generated tests for mod_raw_mul
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com >
2022-12-15 15:04:20 +01:00
48232ed2c1
Merge pull request #6743 from minosgalanakis/bignum/implement_modular_negation
...
Bignum: Implement fixed width modular negation
2022-12-13 09:54:38 +01:00
9a60b2373b
bignum_mod_raw testsuite: Refactored mpi_mod_raw_neg()
.
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2022-12-12 11:13:56 +00:00
6118a3e5aa
test_suite_bignumg_mod_raw: Added test for mpi_mod_raw_neg
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2022-12-12 11:13:56 +00:00
6129268fee
Bignum: Implement mbedtls_mpi_mod_raw_inv_prime() and tests
...
Fixes #6023 .
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com >
2022-12-08 09:44:10 +00:00
f55505d38b
Bignum Mod Raw: fix tests after rebase
...
Signed-off-by: Janos Follath <janos.follath@arm.com >
2022-11-25 17:58:40 +00:00
91295d2b8f
Bignum Mod: remove endianness from modulus
...
The external representation before included more than just endianness
(like reading in Mongtomery curve scalars or converting hashes to
numbers in a standard compliant way).
These are higher level concepts and are out of scope for Bignum and for
the modulus structure.
Signed-off-by: Janos Follath <janos.follath@arm.com >
2022-11-25 17:55:00 +00:00
d3eed33709
Bignum Mod Raw: pass endianness as a parameter
...
The external representation before included more than just endianness
(like reading in Mongtomery curve scalars or converting hashes to
numbers in a standard compliant way).
These are higher level concepts and are out of scope for Bignum and for
the modulus structure.
Passing endianness as a parameter is a step towards removing it from the
modulus structure.
Signed-off-by: Janos Follath <janos.follath@arm.com >
2022-11-25 17:55:00 +00:00
590ae5363d
Merge pull request #6656 from tom-cosgrove-arm/bignum_pr_6225-updated
...
Bignum: add mod_raw_add
2022-11-25 17:53:31 +00:00
ddad40b1de
Free the modulus before the data in it in mod_raw_add tests
...
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com >
2022-11-25 14:18:52 +00:00
50fc127a4e
Change order of test arguments for bignum_mod_raw to simplify Python script
...
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com >
2022-11-24 21:29:23 +00:00
54d87bf5c2
Take limb count from the modulus in mod_raw_add tests
...
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com >
2022-11-24 16:22:38 +00:00
f907576245
Pass correct arguments in test
...
Signed-off-by: Werner Lewis <werner.lewis@arm.com >
2022-11-24 16:18:06 +00:00
baa34b6248
Add test function for mpi_mod_raw_add
...
Signed-off-by: Werner Lewis <werner.lewis@arm.com >
2022-11-24 16:18:06 +00:00
b3b3466657
Test subtraction if the parameters are aliased to each other
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com >
2022-11-23 14:44:14 +01:00
4d3f3c5430
Fix the checking of the used limbs
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com >
2022-11-23 14:44:14 +01:00
68a45e0aaf
Fix potential not initialized warning
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com >
2022-11-23 14:44:14 +01:00
cefe03a10c
Add tests for low level subtraction with modulus
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com >
2022-11-23 14:44:13 +01:00
8c0eb9744c
Must call mbedtls_mpi_mod_modulus_init() before anything else in tests
...
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com >
2022-11-17 08:48:12 +00:00
f90111b2b5
Must call mbedtls_mpi_mod_modulus_init() before anything else in tests
...
Fixes (new) Coverity issues 381893 and 381894
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com >
2022-11-15 06:15:15 +00:00
47691fb756
bignum_tests: Refactored mpi_mod_raw_to/fromt_mont_rep
...
This patch migrates the tests to use the `mbedtls_test_read_mpi_core()`.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2022-11-11 10:55:08 +00:00
df070d660d
bignum_tests: Added test for mbedtls_mpi_mod_raw_from_mont_rep()
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2022-11-11 10:55:08 +00:00
631b491cbf
bignum_tests: Added test for mbedtls_mpi_mod_raw_to_mont_rep()
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2022-11-11 10:55:08 +00:00
a8cf998bc9
Let the allocated memory visible for the memory sanitizer
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com >
2022-11-07 15:14:49 +01:00
7ba7b3aded
Update tests to use mbedtls_test_read_mpi_core
...
In conditional assign and swap tests use the mbedtls_test_read_mpi_core
function for reading MPIs.
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com >
2022-11-07 15:14:49 +01:00
6642cafae3
Fix merge separator position
...
Signed-off-by: Janos Follath <janos.follath@arm.com >
2022-11-02 17:28:39 +00:00
5933f691a2
Add merge slots to Bignum files
...
Legacy Bignum is excluded as it doesn't get regular extensions like new
ones.
Each slot uses comments of their respective filetype. Since .data files
don't have a syntax for comments, dummy test cases are used. (These test
cases will never be executed and no noise will be added to tests.)
Signed-off-by: Janos Follath <janos.follath@arm.com >
2022-11-02 17:27:25 +00:00
0c61a749b7
test_suite_bignum_mod_raw: Removed parameter for mbedtls_mpi_mod_modulus_setup()
...
This patch updates the tests `mpi_mod_raw_cond_swap()` &
`mpi_mod_raw_cond_assign()` to use a non-zero modulus
when invoking `mbedtls_mpi_mod_modulus_setup()`
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2022-10-28 00:11:19 +01:00
be17655b57
mbedtls_mpi_mod_modulus_init() must be called before any 'goto exit' in tests
...
Fixes Coverity issues 381527 and 381526.
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com >
2022-10-20 16:57:10 +01:00