Gabor Mezei
dacfe56370
Add _raw
function to P192K1
...
Modified the testing to use the generic fast reduction test function.
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-05-16 17:29:57 +02:00
Minos Galanakis
99453ad9f0
bignum_core.py: Simplified result calculation for BignumCoreShiftL
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-05-16 15:28:19 +01:00
Gabor Mezei
23b10109bb
Add test cases to test overflow in the Kobltz reduction
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-05-12 12:34:12 +02:00
Minos Galanakis
013167ed7f
bignum_common.py: Addressed minor typos
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-05-11 10:54:44 +01:00
Paul Elliott
481a6a8edb
Merge pull request #7482 from gabor-mezei-arm/6029_use_core_api_in_ecp_mod_koblitz
...
[Bignum] Use core API in ecp_mod_koblitz()
2023-05-10 17:24:46 +01:00
Gabor Mezei
9bf1aaf385
Fix input parameter alignment in P256K1 test cases
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-05-05 16:32:28 +02:00
Paul Elliott
b8bd47dd68
Remove unrequired limb size calculation
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2023-05-03 14:16:54 +01:00
Paul Elliott
b7fd1d6044
Correct max canonical multiplication result
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2023-05-03 14:16:48 +01:00
Paul Elliott
16648be171
Add Curve 448 tests
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2023-04-26 22:23:27 +01:00
Minos Galanakis
c787cf73b3
bignum_core.py: Add "BignumCoreShiftL()"
...
This patch introduces automatic test input generation for
`mpi_core_shift_l()` function.
It also adds two utility functions in bignum_common.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-04-26 17:04:20 +01:00
Minos Galanakis
d6751dcd8b
ecp_curves: Added unit-tests for secp256k1
...
This patch introduces basic unit-testing for the `ecp_mod_p256k1()`.
The method is exposed through the ecp_invasive interface, and
the standard testing data is being provided by the python framework.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-04-25 13:30:59 +01:00
Minos Galanakis
e5dab975c6
ecp_curves: Added unit-tests for secp224k1
...
This patch introduces basic unit-testing for the `ecp_mod_p224k1()`.
The method is exposed through the ecp_invasive interface, and
the standard testing data is being provided by the python framework.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-04-18 14:13:20 +01:00
Gabor Mezei
cec506083b
Fix test case dependency
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-04-17 14:56:03 +02:00
Gabor Mezei
bda7f87e2a
Add dependency for P192K1 tests
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-04-13 13:11:05 +02:00
Gabor Mezei
b86ead3cb2
Add generated tests for ecp_mod_p192k1
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-04-13 12:47:59 +02:00
Minos Galanakis
0a325b6767
ecp.py: Set test-dependencies as attributes.
...
This patch enables declaring dependencie as test-class
members. ECP curve functions have been updated
to use the new capability.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-04-06 16:33:10 +01:00
Minos Galanakis
1358648f77
test_suite_ecp: Introduced ecp_mod_p_generic_raw
...
This patch replaces similiarly structured test functions
for:
* MBEDTLS_ECP_DP_SECP192R1
* MBEDTLS_ECP_DP_SECP224R1
* MBEDTLS_ECP_DP_SECP256R1
* MBEDTLS_ECP_DP_SECP384R1
* MBEDTLS_ECP_DP_BP512R1R1
with a more generic version, which adjusts the parameters, based on the `curve_id` field,
provided by the testing data.
The python test framework has been updated to provide that extra field.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-04-06 16:27:12 +01:00
Janos Follath
44c6694be7
Merge pull request #7351 from gabor-mezei-arm/7109_ecp_fast_reduction_testing
...
Test unlikely cases of ECC modular reduction
2023-04-06 15:55:19 +01:00
Minos Galanakis
00bd8925a7
bignum: Removed merge scaffolding.
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-04-05 16:13:11 +01:00
Gabor Mezei
b0f013784f
Multplication is simmetric so only generate unique combinations
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-04-03 17:26:44 +02:00
Gabor Mezei
87223ab1ce
Add generated test for core_mul
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-03-31 16:17:06 +02:00
Gabor Mezei
5ded38e0e1
Fix 0 limb size for value 0
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-03-31 16:17:06 +02:00
Gabor Mezei
d8c0e1aa8d
Fix comments
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-03-28 15:34:49 +02:00
Gabor Mezei
c33a36b5df
Typo: reorder testing classes
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-03-28 15:32:47 +02:00
Gabor Mezei
a8d0da3880
Add test cases for P256 fast reduction testing
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-03-28 15:31:05 +02:00
Gabor Mezei
54ad647e8d
Add test cases for P384 fast reduction testing
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-03-28 15:30:32 +02:00
Gabor Mezei
fede276392
Typo: reformat numbers
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-03-28 15:29:40 +02:00
Gabor Mezei
a9a68728b3
Add test cases for P521 fast reduction testing
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-03-28 15:09:35 +02:00
Gabor Mezei
64a229f6ac
Add test cases for P224 fast reduction testing
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-03-28 15:09:35 +02:00
Gabor Mezei
62adc726d0
Add test cases for P192 fast reduction testing
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-03-28 15:09:35 +02:00
Minos Galanakis
4af90bbcda
EcpP384R1Raw: Added test case for 2nd round of carry reduction.
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-03-21 15:46:51 +00:00
Minos Galanakis
37f4cb6d0e
ecp_curves: Minor rework for p384
...
This patch adjusts formatting, documentation and testing.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-03-21 15:46:50 +00:00
Minos Galanakis
f359c91f9b
ecp test generator: Added EcpPp384R1Raw().
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-03-21 15:45:18 +00:00
Gabor Mezei
fffd6d9ded
Fix maximum cannonical value
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-03-09 13:43:15 +01:00
Gabor Mezei
e4710ae9ed
Add and fix comments
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-03-09 13:43:02 +01:00
Gabor Mezei
eb591ff94d
Add test generation for ecp_mod_p256_raw
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-03-08 14:12:20 +01:00
Gabor Mezei
a2ef6a8e38
The is_valid() function is needed to not filter out test cases
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-03-06 16:57:25 +01:00
Gabor Mezei
61ef3603eb
Correct the maximum canonical value in tests
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-03-06 16:32:16 +01:00
Gabor Mezei
d034b3d0d2
Code style: have two empty lines before and after class definitions
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-03-06 16:32:15 +01:00
Gabor Mezei
5e33e6f5d4
Remove unnecessary function override
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-03-06 16:32:12 +01:00
Gabor Mezei
931fd646ff
Use lower case hex number
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-03-01 16:50:00 +01:00
Gabor Mezei
98791e7781
Add more test cases for P224 testing
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-02-27 15:59:34 +01:00
Gabor Mezei
f65a059a64
Add test generation for ecp_mod_p224_raw
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-02-21 11:40:27 +01:00
Gabor Mezei
7c8d706f4e
Use a common function to calculate the number of hex digits
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-02-21 11:36:49 +01:00
Gabor Mezei
2c8e144ef6
Fix tests for 32bit
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-02-16 10:25:08 +01:00
Gabor Mezei
2b064ec332
Revert the addition of hex digit calculator function
...
This reverts commit 0f83e15e670565147daa32fd1fac510759520e26.
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-02-15 18:19:08 +01:00
Gabor Mezei
cf228706cd
Restrict input parameter size for ecp_mod_p521_raw
...
The imput mpi parameter must have twice as many limbs as the modulus.
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-02-15 18:19:08 +01:00
Janos Follath
755ff0e685
Add corner case to mod_p521 tests
...
Signed-off-by: Janos Follath <janos.follath@arm.com>
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-02-15 18:13:50 +01:00
Gabor Mezei
b50aeb8f05
Fix 32-bit issues
...
The 521 bit needs different limb alignment for different word sizes.
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-02-15 18:13:49 +01:00
Gabor Mezei
05c138e172
Fix pylint issues
...
Create a new function for calculating the number of hex digits needed
for a certain amount of limbs.
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-02-15 18:13:49 +01:00
Gabor Mezei
d8f67b975b
Add test generation for ecp_mod_p521_raw
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-02-15 18:13:48 +01:00
Gilles Peskine
e2a9f86755
Merge pull request #6971 from gabor-mezei-arm/6026_Secp192r1_fast_reduction
...
Extract Secp192r1 fast reduction from the prototype
2023-02-15 16:22:36 +01:00
Gabor Mezei
5c9f401e47
Add more test cases
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-02-13 14:15:08 +01:00
Gilles Peskine
4c77601832
Merge pull request #6975 from davidhorstmann-arm/c-build-helper-improvements
...
Minor improvements to `c_build_helper.py`
2023-02-07 10:25:59 +01:00
Gabor Mezei
b6875086e6
Fix pylint issues
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-01-31 14:40:05 +01:00
Gabor Mezei
bd23f3b2b8
Add test generation for ecp_mod_p192_raw
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-01-31 14:40:05 +01:00
Gabor Mezei
95ecaaf56d
Add test generation support for the ecp module
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-01-31 14:40:05 +01:00
Gilles Peskine
470f10cfc5
Merge pull request #6941 from gabor-mezei-arm/6375_quasi-reduction_function
...
Add function to fix quasi-reduction
2023-01-31 11:25:25 +01:00
David Horstmann
cf0b881803
Add docstring for new compile function.
...
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-30 09:50:59 +00:00
David Horstmann
ef504d96c1
Make c_build_helper module respect HOSTCC
...
If HOSTCC is set, use that to generate files, otherwise use CC. This
should make cross-compilation with generated files slightly easier.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-27 17:02:09 +00:00
David Horstmann
ac49ee5d4c
c_build_helper.py: Move compile to helper
...
Move compilation to a separate helper function in c_build_helper.py to
allow more generic use.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-27 17:02:09 +00:00
Gabor Mezei
b57c908855
Shorten the prefix of the test case belongs to the fix quasi-reduction function
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-01-27 14:37:42 +01:00
Gabor Mezei
26439bf692
Revert "Add dependency for generated test cases"
...
The 'MBEDTLS_TEST_HOOKS' belongs to a test function and
not to a test case.
This reverts commit 1e8c210b9d
.
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-01-27 14:33:50 +01:00
Manuel Pégourié-Gonnard
169d9e6eb4
Merge pull request #6802 from gilles-peskine-arm/test_suite_psa_crypto_metadata-20221215
...
Add metadata tests for CCM* and TLS1.2-ECJPAKE-to-PMS
2023-01-27 10:05:00 +01:00
Gabor Mezei
1e8c210b9d
Add dependency for generated test cases
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-01-26 12:30:01 +01:00
David Horstmann
79f14e3990
Give proper Dict type hints in crypto_knowledge.py
...
This prevents a return type error in a later function that uses the
dictionaries here properly typed.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-24 18:59:07 +00:00
Gabor Mezei
246d66bb5f
Use reproductable random numbers
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-01-24 18:02:52 +01:00
Gabor Mezei
6f96c89fc3
Fix pylint issues
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-01-24 17:38:26 +01:00
Gabor Mezei
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
Gilles Peskine
f6c6b64be2
A key agreement cannot be chained with PSA_ALG_TLS12_ECJPAKE_TO_PMS
...
Test accordingly.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-19 12:11:20 +01:00
Gilles Peskine
72f41562f2
Refactoring: new method Algorithm.is_valid_for_operation
...
No intended behavior change.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-19 12:11:18 +01:00
Gabor Mezei
7e14c66c4d
Fix lint issues
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-01-18 10:56:13 +01:00
Gabor Mezei
aec3eea064
Fix pylint issues
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-01-17 16:34:24 +01:00
Gabor Mezei
3c6f89b46a
Add generated test for ecp quasi-reduction
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-01-17 13:16:47 +01:00
Gabor Mezei
308132f641
Add test generation support for the ecp module
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-01-17 13:16:46 +01:00
Manuel Pégourié-Gonnard
676766ff77
Merge pull request #6776 from gabor-mezei-arm/6222_bignum_mod_mul
...
Bignum: Implement fixed width modular multiplication
2022-12-23 10:39:30 +01:00
Manuel Pégourié-Gonnard
2fcb4c1d06
Merge pull request #6747 from gilles-peskine-arm/bignum-mod-random
...
Bignum mod random
2022-12-23 10:36:22 +01:00
Gilles Peskine
5efe449a6a
More robust dependency filtering
...
Only remove the MBEDTLS_HAVE_INTnn dependency, not any other dependency that
might be present.
No behavior change, this is just robustness.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-21 20:33:30 +01:00
Gilles Peskine
f287366376
Simplify logic and document test_cases_for_values
...
Explain what's going on in BignumModRawConvertRep.test_case_for_values.
Simplify the logic and the interdependencies related to limb sizes:
* Montgomery is the special case, so base the decisions on it.
* As soon as we've encountered one limb size, no matter what it is,
give up.
No behavior change, other than changing the numbering of test cases (which
previously included more skipped test cases).
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-21 20:31:14 +01:00
Gilles Peskine
394da2d857
Pacify pylint
...
Except for missing documentation, which will come in a subsequent commit.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-21 20:22:38 +01:00
Gilles Peskine
6d40e54db0
Split the high nesting of BignumModRawConvertRep.generate_function_tests
...
Pylint complains about the nesting. It's not wrong.
No behavior change.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-21 20:22:38 +01:00
Gilles Peskine
636809f2b9
Fix type declaration
...
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-21 20:12:31 +01:00
Minos Galanakis
342b9a903d
bignum_mod_raw.py: Added a filtering logic to BignumModRawConvertRep.generate_function_tests()
...
This patch introduces a hybrid approach to input_styles, and will remove the
dependency requirements from test cases with `ModulusRepresentation.OPT_RED`
As a result it is reducing testing input duplication.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-12-21 18:00:01 +00:00
Minos Galanakis
afa7c04105
bignum_common.py: Refactored BignumModRawConvertRep.generate_function_tests()
...
This patch adjusts the test generating method to calculate all possible combinations for
(modulo, input, limb_sizes, representation).
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-12-21 18:00:01 +00:00
Minos Galanakis
ae4d2cf3e3
bignum_common.py: Introduce the set_representation setter.
...
This patch adds the default representation attribute through a
setter() method in `BignumModRawConvertRep()`
It also adds standard common template properties:
symbol = ""
input_style = "arch_split"
arity = 1
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-12-21 18:00:01 +00:00
Minos Galanakis
5689410083
bignum_mod_raw: Simplified BignumModRawCanonicalToFromModulusRep
output expressions.
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-12-21 17:31:56 +00:00
Minos Galanakis
3d2aab891b
bignum_common: Adjusted format_arg
to always size input according to modulo.
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-12-21 17:30:10 +00:00
Gilles Peskine
ad335b55ff
Fix representation conversion with 32-bit limbs
...
The Montgomery representation depends on the limb size. So the
representation conversion test cases need separate 64-bit and 32-bit cases
when the representation is Montgomery.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-20 22:39:15 +01:00
Gilles Peskine
be69c7d559
Generate test cases for mpi_mod_raw_modulus_to_canonical_rep as well
...
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-20 20:28:02 +01:00
Gilles Peskine
23636aca98
Generate test cases for mpi_mod_raw_canonical_to_modulus_rep
...
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-20 19:55:51 +01:00
Gilles Peskine
7a708fd49f
Helpers for generating representation-aware test cases
...
Add a class for modulus representations (mbedtls_mpi_mod_rep_selector).
Add a method to convert a number to any representation.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-20 19:52:49 +01:00
Gilles Peskine
5623ecc2d6
Mod operations: fill arguments to the width of the modulus
...
With the default input style (which is "variable"), fill all bignum test
case arguments to the same width as the modulus.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-20 19:52:49 +01:00
Gilles Peskine
f8a4463bd6
Add some missing type annotations
...
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-20 19:52:49 +01:00
Gabor Mezei
8a26164684
Supress pylint's duplicated code warning
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-12-20 17:30:19 +01:00
Gabor Mezei
77b877d5a7
Generate operands in Mongomery representation for the test function
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-12-20 17:30:19 +01:00
Gabor Mezei
eca74668c7
Add tests for mod_mul
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-12-20 17:30:19 +01:00
Gilles Peskine
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
Tom Cosgrove
f723754f6d
Fix typos
...
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-12-16 16:10:36 +00:00
Gabor Mezei
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
Tom Cosgrove
1133d2325b
Attempt to pacify pylint in bignum tests
...
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-12-16 03:53:17 +00:00