Commit graph

372 commits

Author SHA1 Message Date
Gilles Peskine
68b5182dad Add test data for secp192r1
Same generation methodology as 0cbaf056fa:

```
openssl genpkey -algorithm ec -pkeyopt ec_paramgen_curve:P-192 -text |perl -0777 -pe 's/.*\npriv:([\n 0-9a-f:]*)pub:([\n 0-9a-f:]*).*/"$1","$2"/s or die; y/\n ://d; s/,/,\n              /;'
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-01-03 20:57:52 +01:00
Gilles Peskine
478dd84b63 Fix mixup between secp224r1 and secp224k1 in test scripts
secp224k1 is the one with 225-bit private keys.

The consequences of this mistake were:

* We emitted positive test cases for hypothetical SECP_R1_225 and
  SECP_K1_224 curves, which were never executed.
* We emitted useless not-supported test cases for SECP_R1_225 and SECP_K1_224.
* We were missing positive test cases for SECP_R1_224 in automatically
  generated tests.
* We were missing not-supported test cases for SECP_R1_224 and SECP_K1_225.

Thus this didn't cause test failures, but it caused missing test coverage
and some never-executed test cases.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-01-03 20:50:56 +01:00
Gilles Peskine
b4362d2cc7
Merge pull request #8523 from tom-daubney-arm/modify_check_generated_files_script
Modify check generated files script to work with TF PSA Crypto too
2023-12-11 21:15:00 +00:00
Thomas Daubney
04c446cc21 Modify crypto_core_directory to also return a relative path
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-12-01 17:18:38 +00:00
Thomas Daubney
99030e2a50 Remove trailing whitespace
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-12-01 09:52:35 +00:00
Thomas Daubney
db80b2301c Introduce guess_tf_psa_crypto_root
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-11-30 17:33:54 +00:00
Thomas Daubney
d1f2934e78 Introduce guess_mbedtls_root
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-11-30 17:27:42 +00:00
Thomas Daubney
46588de8fc Improve documentation of crypto_core_directory
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-11-30 13:59:30 +00:00
Thomas Daubney
08c6dc4942 Rename project_crypto_name
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-11-30 13:56:09 +00:00
Thomas Daubney
cdbf2fd644 Add documentation for new public functions
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-11-24 10:54:56 +00:00
Thomas Daubney
beec452e3c Use os.path.join in crypto_core_directory
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-11-24 10:48:44 +00:00
Thomas Daubney
8932404c45 Introduce project_crypto_name in build_tree.py
Add new function to build_tree.py to return the crypto
name for the project; either tfpsacrypto or mbedcrypto.
Deploy this function where needed.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-11-23 10:14:12 +00:00
Yanray Wang
690ee81533 Merge remote-tracking branch 'origin/development' into support_cipher_encrypt_only 2023-11-23 10:31:26 +08:00
Thomas Daubney
755d32117b Rename guess_mbedtls_root to guess_project_root
Rename for consistency. Also, replace all calls to
this function with correct name.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-11-22 17:18:22 +00:00
Thomas Daubney
d35b94b662 Improve implementation of crypto_core_directory
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-11-22 17:04:02 +00:00
Thomas Daubney
13ecb691a3 Introduce function to return library/core directory
Add crypto_core_directory in build_tree.py so that
the libary/core directory can be returned based
on what repository we are in.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-11-16 18:34:58 +00:00
Yanray Wang
19583e44ed psa_information: improve code readability
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-11-13 17:43:37 +08:00
Yanray Wang
70743b02df psa_information: compile a regex instead of using string directly
Compiling a regex improves performance and avoids accidentally
combining it with a string. This commit makes this change.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-11-09 16:13:55 +08:00
Yanray Wang
6b190d4f27 psa_information.py: generate dep for AES/ARIA/CAMELLIA ECB test case
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-11-03 17:37:22 +08:00
Dave Rodgman
16799db69a update headers
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-11-02 19:47:20 +00:00
Ronald Cron
070e8652d5 Adapt to new PSA Crypto repo name
Patterns I looked for:
grep -i "psa-crypto"
grep -i "psa.*crypto.*repo"
grep -i "psa.*crypto.*root"

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2023-10-09 10:26:18 +02:00
David Horstmann
2fde99962d Improve directory coverage in PSA repo detection
Check for the 'drivers' and 'programs' directories additionally to the
ones that are already there.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-08-29 09:50:16 +01:00
David Horstmann
42f42f4394 Support psa-crypto repo in psa_storage.py
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-08-24 15:18:18 +01:00
David Horstmann
795d8b523d Modify build_tree.py for the PSA Crypto repo
When detecting the root dir, look both for PSA Crypto and Mbed TLS
directories.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-08-24 15:18:18 +01:00
Gilles Peskine
ad7725d95d Fix type annotation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-22 09:59:50 +02:00
Gilles Peskine
c9187c5866 New test suite for the low-level hash interface
Some basic test coverage for now:

* Nominal operation.
* Larger output buffer.
* Clone an operation and use it after the original operation stops.

Generate test data automatically. For the time being, only do that for
hashes that Python supports natively. Supporting all algorithms is future
work.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-22 09:59:42 +02:00
Gilles Peskine
fdb722384b Move PSA information and dependency automation into their own module
This will let us use these features from other modules (yet to be created).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-21 18:32:11 +02:00
Bence Szépkúti
505dffd5e3
Merge pull request #7937 from yanrayw/code_size_compare_improvement
code_size_compare.py: preparation work to show code size changes in PR comment
2023-08-17 20:59:11 +00:00
Yanray Wang
1998aac349 logging_util: support to tweak loglevel directed to stderr/stdout
Previously we set loglevel >= WARNING printed to stderr and
loglevel < WARNING printed to stdout. To be more flexible, we
replace this `WARNING` value with an argument: split_level and leave
`WARNING` as default split_level if not set.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-08-14 11:22:34 +08:00
Tom Cosgrove
2588f8d36d
Merge pull request #8018 from AgathiyanB/add-overflow-test-inputs-bignum
[Bignum] Add overflow test inputs for add and add if
2023-08-04 14:00:39 +00:00
Agathiyan Bragadeesh
3c963eefe2 Remove trailing whitespace
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-03 12:32:09 +01:00
Agathiyan Bragadeesh
ab329c0dfc Rename ADD_SUB_DEFAULT to ADD_SUB_DATA
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-01 17:18:31 +01:00
Agathiyan Bragadeesh
59003c70ae Use ADD_SUB_DEFAULT as test input for bignum tests
In BignumCoreAddAndAddIf and BignumCoreSub we use the new dedicated
test inputs.

Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-01 16:32:36 +01:00
Agathiyan Bragadeesh
7847eaef20 Add default test cases for add/subtract in bignum
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-01 16:30:51 +01:00
Manuel Pégourié-Gonnard
182eb1514e Fix KeyType.can_do() for DH+FFDH
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-07-26 09:34:30 +02:00
Manuel Pégourié-Gonnard
636d85724a Shorten DH_FAMILY just like ECC_FAMILY
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-07-26 09:32:42 +02:00
Manuel Pégourié-Gonnard
afe4b79114 Enable DH in generate_psa_tests.py
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-07-26 09:32:42 +02:00
Yanray Wang
15b1358f22 logging_util: rename argument
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-26 14:48:12 +08:00
Yanray Wang
21127f7095 code_size_compare: add logging module and tweak prompt message
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-24 18:07:12 +08:00
Minos Galanakis
dae4c038f8 ecp.py: Extended EcpP224K1Raw tests for 32/64 bit architectures.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-06-27 18:54:53 +01:00
Minos Galanakis
80c4ae893c bignum_common.py: Added bits_to_limbs method.
This patch introduces a rounding-error-resiliant method to
calculate bits_to_limbs, and is updating `SECP224R1` and
`SECP224K1` to use it.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-06-27 16:38:22 +01:00
Minos Galanakis
450abfd922 test_suite_ecp: Added MBEDTLS_ECP_NIST_OPTIM define guards.
This patch updates `ecp_mod_p_generic_raw` and corresponding
curve test methods, that depend on the NIST optimisation
parameter to not run when it is not included.

The following curves are affected:
* SECP192R1
* SECP224R1
* SECP256R1
* SECP384R1
* SECP521R1

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-06-16 13:48:47 +01:00
Paul Elliott
a2e48f751b Split out mbedtls_ecp_mod_p448_raw()
Switch testing over to using the generic raw functions.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2023-06-15 17:16:38 +01:00
Paul Elliott
b4df176610
Merge pull request #7637 from paul-elliott-arm/fixed_ecp_mod_p448
[Bignum] Fixed width for ecp mod p448
2023-06-15 17:12:02 +01:00
Paul Elliott
b727042501 Move corner test case into python framework
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2023-06-13 17:42:01 +01:00
Minos Galanakis
2daa374ea8 ecp_curves: Minor refactoring of mbedtls_ecp_mod_p255_raw()
* Fixed whitespace issues.
* Renamed variables to align with bignum conventions.
* Updated alignment on test input data.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-05-23 09:57:09 +01:00
Minos Galanakis
aada68f1be ecp.py: Fixed types for arguments() overrides.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-05-23 09:57:09 +01:00
Minos Galanakis
c2c967b1f0 ecp.py: Added tests for mbedtls_ecp_mod_p255_raw
This patch introduces the `EcpP255Raw` test class for testing
the curve using the preestablished `ecp_mod_p_generic_raw()`
test. The test's logic has been updated accordingly.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-05-23 09:57:09 +01:00
Paul Elliott
26070670d6
Merge pull request #7565 from gabor-mezei-arm/7263_split_out_Koblitz_raw_functions
[Bignum] Split out _raw Koblitz reduction functions
2023-05-22 16:03:17 +01:00
Paul Elliott
f0806bee66
Merge pull request #7489 from minosgalanakis/ecp/7246_xtrack_core_shift_l
[Bignum]: Introduce left shift from prototype
2023-05-16 17:13:19 +01:00