Commit graph

23002 commits

Author SHA1 Message Date
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
2840884c35
Typo
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-12-20 17:30:19 +01:00
Gabor Mezei
6a31b7252d
Fix documentation
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
Gabor Mezei
9db81e9cca
Add mod_mul function
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-12-20 17:30:13 +01:00
Dave Rodgman
3e0418fe50
Merge pull request #6825 from minosgalanakis/bignum/adjust_pylint
pylint: Set a minimum duplicate match to 10 lines.
2022-12-20 16:26:57 +00:00
Dave Rodgman
2038da9266
Merge pull request #6826 from daverodgman/fix_gettimeofday
Fix gettimeofday overflow
2022-12-20 16:01:53 +00:00
Dave Rodgman
327b69c8a2 Add Changelog entry
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-12-20 13:16:34 +00:00
Dave Rodgman
7796cc4f24 Fix overflow in mbedtls_timing_hardclock
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-12-20 13:12:23 +00:00
Minos Galanakis
e080cc31f2 pylint: Set a minimum duplicate match to 10 lines.
This patch adjusts pylint to disregard duplicate matches
for up to 10 lines.

The number is chosen to permit overriding with up to
3 identical lines for `def arguments(self)` and
`def result(self)` while two more lines for `arity`
and `input_style` in the bignum test suite.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-12-20 11:59:08 +00:00
Glenn Strauss
efde9d58de remove duplicated consecutive preproc directives
Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
2022-12-20 04:20:12 -05:00
Manuel Pégourié-Gonnard
8b6d14be8b Extract common code for computing X^3 + AX + B
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-12-20 04:17:03 -05:00
Glenn Strauss
452416121d move mbedtls_ecp_sw_derive_y after MPI_ECP_ macros
Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
2022-12-19 21:25:27 -05:00
Glenn Strauss
fcabc28cfc use MPI_ECP_* macros in mbedtls_ecp_sw_derive_y()
Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
2022-12-19 21:24:50 -05:00
Manuel Pégourié-Gonnard
82dad10746
Merge pull request #6820 from gilles-peskine-arm/code-style-skip-generated-files
Don't touch the style of generated files
2022-12-19 13:06:25 +01:00
Manuel Pégourié-Gonnard
bb12621746
Merge pull request #6808 from gilles-peskine-arm/basic-build-test-lcov-format-robustness-3.3
Fix code_coverage broken by extra echo in make lcov
2022-12-19 13:03:37 +01:00
Manuel Pégourié-Gonnard
c572246fa5 Use OPENSSL everywhere, not OPENSSL_CMD
These variables were both uses to select the default version of OpenSSL
to use for tests:
- when running compat.sh or ssl-opt.sh directly, OPENSSL_CMD was used;
- when running all.sh, OPENSSL was used.

This caused surprising situations if you had one but not the other set
in your environment. For example I used to have OPENSSL_CMD set but not
OPENSSL, so ssl-opt.sh was failing in some all.sh components but passing
when I ran it manually in the same configuration and build, a rather
unpleasant experience.

The natural name would be OPENSSL, and that's what set in the Docker
images used by the CI. However back in the 1.3.x days, that name was
already used in library/Makefile, so it was preferable to pick a
different one, hence OPENSSL_CMD. However the build system has not been
using this name since at least Mbed TLS 2.0.0, so it's now free for use
again (as demonstrated by the fact that it's been set in the CI without
causing any trouble).

So, unify things and use OPENSSL everywhere. Just leave an error message
for the benefit of developers which might have OPENSSL_CMD, not OPENSSL,
set in their environment from the old days.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-12-19 11:42:12 +01:00
Gilles Peskine
3b56d29147 List all the places with instructions to generate those files
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-19 00:56:44 +01:00
Gilles Peskine
9a3771e1b3 Don't touch the style of generated files
Ideally the result of the generator would conform to the code style, but
this would be difficult, especially with respect to the placement of line
breaks in long logical lines. So, to avoid surprises when checking the style
of generated files (which happens in releases and in long-time support
branches), systematically skip generated files.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-19 00:52:39 +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
Gilles Peskine
cf86d70162
Merge pull request #6742 from gabor-mezei-arm/6022_bignum_mod_raw_mul
Bignum: Implement fixed width raw modular multiplication
2022-12-17 13:25:43 +01:00
Gilles Peskine
546493bee9
Merge pull request #6789 from mpg/doc-docker-from-ci
Point to docker images used in the CI
2022-12-17 01:54:24 +01:00
Gilles Peskine
77f9984cc3
Merge pull request #6810 from davidhorstmann-arm/fix-check-names-enum-regex
Fix an incorrect regex in check_names.py
2022-12-17 01:52:35 +01:00
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