Commit graph

22979 commits

Author SHA1 Message Date
Tom Cosgrove
f723754f6d Fix typos
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-12-16 16:10:36 +00:00
Glenn Strauss
cbfd5e9db7 comment
Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
2022-12-16 11:03:41 -05:00
Glenn Strauss
369bfb94c5 comments and whitespace
Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
2022-12-16 10:49:04 -05:00
Gabor Mezei
210ea63d8b
Fix documentation
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-12-16 16:35:24 +01:00
Valerio Setti
e7221a21ad test: adjust depends.py to new SHA224/SHA384 changes
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2022-12-16 14:43:48 +01:00
David Horstmann
f91090e4a3 Fix an incorrect regex in check_names.py
Allow check_names.py to detect declarations of the form:

enum some_enum_name {

This pattern has only just appeared due to code style correction, which
explains why the issue was not previously noticed.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-12-16 13:39:04 +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
Gilles Peskine
98d3a67a5c Simplify the coverage statistics summary
The script was parsing the output from `make lcov` to extract numbers and
calculate percentages. But everything including the percentages is already
present in the output of `make lcov`, just with a slightly different
presentation. So replace all this by a simple extraction of the relevant
lines from the output of `make lcov`.

This is more robust than the previous code, which relied on `tail -n4` to
extract relevant lines, which broke when `make lcov` started to emit one
extra line at the end.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-16 12:09:17 +01:00
Tom Cosgrove
342d00bc22 Oops, use mbedtls_free() not plain free()
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-12-16 11:02:06 +00:00
Ronald Cron
fbc115f43c
Merge pull request #6794 from ronald-cron-arm/tls13-fix-some-test-dependencies
TLS 1.3: Fix some test dependencies
2022-12-16 11:07:00 +01:00
Gilles Peskine
071f47343b Document the test strategy
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-16 10:13:29 +01:00
Gilles Peskine
d878d1c638 Add validation tests for mbedtls_mpi_{mod,mod_raw}_random
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-16 10:13:29 +01:00
Gilles Peskine
b1eea02f74 Implement and test mbedtls_mpi_mod_random
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-16 10:13:29 +01:00
Gilles Peskine
d008abbc4f Fix leak of modulus structures in tests
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-16 10:13:29 +01:00
Gilles Peskine
a57cf9813a Implement and test mbedtls_mpi_mod_raw_random
In the basic/XXX=core test cases, use odd upper bounds, because the mod
version of random() only supports odd upper bounds (the upper bound is a
modulus and the mod modules only support odd moduli).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-16 10:13:29 +01:00
Gilles Peskine
8c32b24a35 Rename MPI-legacy test function for clarity
A mod version of the function will be added very soon.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-16 10:13:29 +01:00
Gilles Peskine
195f998107 New helper function to allocate and read a modulus
When including <test/bignum_helpers.h>, the library/ directory now needs to
be on the include path.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-16 10:13:28 +01:00
Gilles Peskine
881447d411 Move bignum helpers to their own module
Move bignum-related helper functions to their own files under tests/include
and tests/src. The primary motivation is that a subsequent commit will make
bignum_helpers.h include library/bignum*.h, but we want to be able to
include <test/helpers.h> without having the library directory on the include
path (we do this in some programs under programs/ intended for testing).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-16 10:13:28 +01:00
Manuel Pégourié-Gonnard
057b458583
Merge pull request #6766 from wernerlewis/bignum_mod_docs
Bignum: document conventions for bignum mod and mod_raw
2022-12-16 09:58:36 +01:00
Manuel Pégourié-Gonnard
5bf8629b2c
Merge pull request #6303 from gilles-peskine-arm/bignum-core-random
Bignum: Implement mbedtls_mpi_core_random
2022-12-16 09:58:07 +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
Gilles Peskine
d1dd41f3fc
Merge pull request #6723 from mpg/restartable-vs-use-psa
Document ECP_RESTARTABLE and make it compatible with USE_PSA
2022-12-15 19:47:44 +01:00
Gilles Peskine
6b21820bd3
Merge pull request #6687 from gilles-peskine-arm/fuzz-cflags
programs/fuzz: set sensible default CFLAGS
2022-12-15 19:47:22 +01:00
Gilles Peskine
c8d616364c
Merge pull request #6793 from tom-cosgrove-arm/update-mbedtls_mpi_mod_sub-tests-to-match-mod_add-tests
Update mbedtls_mpi_mod_sub() tests to incorporate mod_add test feedback
2022-12-15 19:47:01 +01:00
Werner Lewis
6bb49ba121 Document const parameter conventions
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-15 17:04:43 +00:00
Tom Cosgrove
dc19759327 Add tests for mbedtls_mpi_mod_inv()
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-12-15 16:59:40 +00:00
Tom Cosgrove
b38c2ed3d9 Fix double space between words
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-12-15 16:56:36 +00:00
Tom Cosgrove
d692ba4248 Note that (as usual) for mbedtls_mpi_mod_inv() residues must be associated with the modulus
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-12-15 16:56:36 +00:00
Tom Cosgrove
dbac60924b mbedtls_mpi_mod_raw_inv_prime() tests should be arch_split
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-12-15 16:56:36 +00:00
Tom Cosgrove
a9e0f95903 Split mbedtls_mpi_mod_inv() into separate functions for mont/non-mont form
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-12-15 16:56:36 +00:00
Tom Cosgrove
4302d02fa8 Add mbedtls_mpi_mod_inv()
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-12-15 16:56:36 +00:00
Tom Cosgrove
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
Tom Cosgrove
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
Tom Cosgrove
30f3b4d601 Add mbedtls_mpi_core_check_zero_ct() and tests
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-12-15 16:56:36 +00:00
Tom Cosgrove
e9ffb6c8e9 Fix mbedtls_platform_zeroize() call in mbedtls_mpi_mod_modulus_free()
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-12-15 16:56:36 +00:00
Werner Lewis
756a34aadc Use lower case for p and r
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-15 14:53:43 +00:00
Gilles Peskine
acdefdd51a Unify RNG initialization that must be unified
mpi_core_random_basic and mpi_random_values must generate the same random
sequences in order to get the expected test coverage (where we know we'll
hit certain numbers of retries). Facilitate this by defining the RNG seed
only once.

Fix the seed to explicitly list all 16 words of the key. This isn't strictly
required (missing initializer fields get the value zero), but it's clearer.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-15 15:15:47 +01:00
Werner Lewis
0f644f48e9 Add output initialization requirement
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-15 14:13:32 +00:00
Gilles Peskine
6b7ce968d2 Clarify some comments
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-15 15:04:33 +01:00
Gabor Mezei
95b754dfac
Fix documentation
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-12-15 15:04:20 +01:00
Gabor Mezei
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
Gabor Mezei
979d34ca7d
Add mod_raw_mul function
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-12-15 15:04:20 +01:00
Gilles Peskine
031114d6ec Hide check_test_cases warnings on the CI
We aren't paying attention to the warnings. So hide them and save log size.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-15 14:46:31 +01:00
Werner Lewis
214ae64349 Replace \p with \c for non-parameter code typeset
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-15 13:36:07 +00:00
Werner Lewis
1d89ebf548 Clarify all functions operate modulo N
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-15 13:35:41 +00:00
Werner Lewis
a306886b3a Add modulus to parameter ordering
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-15 13:35:41 +00:00
Werner Lewis
2e70b9afef Reword bignum sizes section
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-15 13:35:41 +00:00
Werner Lewis
2bd263da1e Fix grammar and spelling
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-15 13:35:40 +00:00
Werner Lewis
945a165a3c Clarify output requirements
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-15 13:22:27 +00:00
Werner Lewis
eac8be76d6 Remove unnecessary type comment
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-15 13:22:17 +00:00