Commit graph

284 commits

Author SHA1 Message Date
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