Commit graph

15 commits

Author SHA1 Message Date
Tom Cosgrove
62b20488f1 Implement mbedtls_mpi_mod_sub()
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-12-01 14:27:37 +00:00
Janos Follath
339b439906 Bignum Mod: remove unused parameter in io_neg test
The value was overwritten and the length wasn't used either. This latter
could have lead to a buffer overflow as well.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-26 12:24:34 +00:00
Janos Follath
566c91db27 Bignum Mod: io_neg test pass data directly
Pass buffer directly instead of constructing it in the function.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-26 12:24:34 +00:00
Minos Galanakis
96070a53a8 bignum_tests: Refactored mpi_mod_io_neg()
This patch refactores the negative testing suite
to utilised non-hardcoded input data.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-11-26 12:24:34 +00:00
Janos Follath
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
Janos Follath
50cd4b842b Bignum Mod: Restrict residue setup
In theory we could allow residues to have more allocated limbs than the
modulus, but we might or might not need it in the end.

Go for the simpler option for now and we can extend it later if we
really need it.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-25 17:55:00 +00:00
Janos Follath
b62bad442e Bidnum Mod: fix check in setup
We want to make sure that the value has at least as many limbs allocated
as the modulus as we need this to be able to do any operations in
constant time.

An invariant of the API is that the residue values are canonical, make
sure that the residue is compared to the entire modulus.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-25 17:55:00 +00:00
Minos Galanakis
aed832ac16 bignum_mod: Adjusted input checking for mbedtls_mpi_mod_residue_setup()
This patch adjusts the logic of the size checking of the method,
and refactors the tests. Documentation has also been updated.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-11-25 17:55:00 +00:00
Minos Galanakis
a17ad48e2d bignum_mod: Fixed an issue with input checking in mpi_mod_residue_setup
This patch is inverting the input type checking logic in the method,
in order to ensure that residue < modulus.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-11-25 17:55:00 +00:00
Minos Galanakis
8f24270630 test_suite_bignum_mod: Added tests for hight level IO
This patch adds the following tests for the high levet IO api:
* mpi_mod_io_neg
* mpi_mod_io

Manually generated test data has also been included.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-11-25 17:55:00 +00:00
Janos Follath
c1a81bc998 Remove trailing new lines
Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-02 17:33:11 +00:00
Janos Follath
be13652296 Use comments for merge separators in .data files
We do have a comment syntax for .data files, there is no need for dummy
test cases.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-02 17:28:37 +00:00
Janos Follath
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
Werner Lewis
6baf12b18d Move legacy mod functions back to test_suite_mpi
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-10-19 15:20:01 +01:00
Werner Lewis
0c6ea12145 Move bignum_mod tests into separate files
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-10-19 15:20:01 +01:00