Commit graph

18331 commits

Author SHA1 Message Date
Hanno Becker
bae3023576 Make more use of helper function for init/free of MPI array
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2022-01-11 05:06:54 +00:00
Hanno Becker
466df6e713 Introduce helper function for init/free of MPI array
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2022-01-10 11:24:42 +00:00
Hanno Becker
ac4d4bc97c Improve documentation of ECP module
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2022-01-09 06:34:04 +00:00
Hanno Becker
ee95f6c4c9 Don't allow Z coordinate being unset in ecp_add_mixed()
Previously, ecp_add_mixed(), commputing say P+Q, would allow for the
Q parameter to have an unset Z coordinate as a shortcut for Z == 1.
This was leveraged during computation and usage of the T-table
(storing low multiples of the to-be-multiplied point on the curve).
It is a potentially error-prone corner case, though, since an MPIs
with unset data pointer coordinate and limb size 0 is also a valid
representation of the number 0.

As a first step towards removing ECP points with unset Z coordinate,
the constant time T-array getter ecp_select_comb() has previously
been modified to return 'full' mbedtls_ecp_point structures,
including a 1-initialized Z-coordinate.

Similarly, this commit ...

- Modifies ecp_normalize_jac_many() to set the Z coordinates
  of the points it operates on to 1 instead of freeing them.

- Frees the Z-coordinates of the T[]-array explicitly
  once the computation and normalization of the T-table has finished.

  As a minimal functional difference between old and new code,
  the new code also frees the Z-coordinate of T[0]=P, which the
  old code did not.

- Modifies ecp_add_mixed() to no longer allow unset Z coordinates.

Except for the post-precomputation storage form of the T[] array,
the code does therefore no longer use EC points with unset Z coordinate.

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2022-01-09 05:52:40 +00:00
Hanno Becker
c27a0e0093 Add more wrappers for ECP MPI operations
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2022-01-06 09:21:50 +00:00
Hanno Becker
595616e5cd Add more wrappers for internal ECP coordinate operations
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2022-01-06 05:12:02 +00:00
Hanno Becker
6a28870b1e Make ecp_select_comb() create valid EC point with Z coordinate set
ecp_select_comb() did previously not set the Z coordinate of the target point.
Instead, callers would either set it explicitly or leave it uninitialized,
relying on the (only partly upheld) convention that sometimes an uninitialized
Z value represents 1.

This commit modifies ecp_select_comb() to always set the Z coordinate to 1.
This comes at the cost of memory for a single coordinate, which seems worth
it for the increased robustness.

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2022-01-06 04:46:45 +00:00
Hanno Becker
30838868ac Keep temporaries across iterations of ecp_double_add_mxz()
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2022-01-05 06:09:42 +00:00
Hanno Becker
3b29f2194b Keep temporaries across iterations of ecp_add_mixed()
This saves heap operations

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2022-01-04 07:34:14 +00:00
Hanno Becker
a7f8edd709 Keep temporaries across iterated invocations of ecp_double_jac()
This reduces the number of heap operations.

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2022-01-04 07:29:46 +00:00
Hanno Becker
28ccb1cc90 Reduce number of local MPIs from 9 to 4 in ecp_double_add_mxz()
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2022-01-04 07:15:14 +00:00
Hanno Becker
376dc89519 Reorder ops in ecp_double_add_mxz() to indicate redundant local MPIs
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2022-01-04 07:14:07 +00:00
Hanno Becker
0d629791e9 Remove local MPI from ecp_randomize_jac()
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2022-01-04 06:45:49 +00:00
Hanno Becker
885ed403c9 Introduce wrapper for modular squaring
This paves the way for dedicated squaring implementations.

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2022-01-04 06:43:50 +00:00
Hanno Becker
b8442cd9c6 Remove another local MPI from ecp_normalize_jac_many()
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2022-01-04 06:32:42 +00:00
Hanno Becker
02a999b91a Remove local MPI from ecp_normalize_jac_many()
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2022-01-04 06:32:42 +00:00
Hanno Becker
838b715fcc Add comment on input/output aliasing in ecp_add_mixed()
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2022-01-04 06:32:42 +00:00
Hanno Becker
ce29ae84dd Introduce macro wrappers for ECC modular arithmetic
This improves readibility and prepares for further changes
like the introduction of a single double-width temporary for
ECP arithmetic.

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2022-01-04 06:32:39 +00:00
Hanno Becker
76f897d699 Reduce number of temporary MPIs in ECP normalization
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2022-01-02 12:47:34 +00:00
Hanno Becker
02b35bd00a Introduce wrapper for modular multiplication with single-width const
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2022-01-01 06:54:25 +00:00
Hanno Becker
5c8ea307b8 Reduce number of local MPIs in ECP mixed point addition
`ecp_add_mixed()` and `ecp_double_jac()` are the core subroutines
for elliptic curve arithmetic, and as such crucial for the performance
of ECP primitives like ECDHE and ECDSA.

This commit provides a very slight simplification and performance and
memory usage improvement to `ecp_add_mixed()` by removing the use of
three temporary MPIs used for coordinate calculations.

Where those variables were used, the code now writes directly to the
coordinate MPIs of the target elliptic curve point.

This is a valid change even if there is aliasing between input and
output, since at the time any of the coordinate MPIs in question is
written, the corresponding coordinates of both inputs are no longer
read.

(The analogous change in `ecp_double_jac()` can not be made since
this property does not hold for `ecp_double_jac()`.)

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2022-01-01 06:16:16 +00:00
Gilles Peskine
acc74b8413
Merge pull request #5348 from davidhorstmann-arm/fix-ssl-debug-header-typo
Fix typo in python script method name
2021-12-20 22:07:08 +01:00
Dave Rodgman
bff88ab086
Merge pull request #874 from ARMmbed/mbedtls-3.1.0_merge_into_release
Mbedtls 3.1.0 merge into release
2021-12-17 11:22:31 +00:00
Dave Rodgman
77d778eee2
Merge branch 'development' into mbedtls-3.1.0_merge_into_release 2021-12-17 10:01:53 +00:00
Dave Rodgman
b8c3301b80 Revert "Add generated files"
This reverts commit 4e62cbc322.
2021-12-17 09:44:04 +00:00
David Horstmann
3be1271e35 Fix typo in python script method name
Change 'tranlation' -> 'translation' in the name of a
method in `scripts/generate_ssl_debug_headers.py`.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2021-12-16 11:01:43 +00:00
Gilles Peskine
ba57427bbf
Merge pull request #5283 from adeaarm/development
Make CMakeLists.txt discover if mbed TLS is being built as subproject
2021-12-16 11:58:24 +01:00
Gilles Peskine
cb4dc37a2a
Merge pull request #5340 from gilles-peskine-arm/ssl_debug_helpers_generated.h-commit-header
Commit ssl_debug_helpers.h
2021-12-16 11:57:07 +01:00
Gilles Peskine
863b96a21b Add copyright notice to ssl_debug_helpers*
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-12-16 10:04:58 +01:00
Dave Rodgman
d65aeb3734
Merge pull request #871 from ronald-cron-arm/mbedtls-3.1.0rc0-pr
Mbedtls 3.1.0rc0 pr
2021-12-15 13:48:01 +00:00
Gilles Peskine
1a1e78fa55 Remove comments indicating that the file was automatically generated
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-12-15 12:58:22 +01:00
Gilles Peskine
923d5c9e3c Rename ssl_debug_helpers.h
It's no longer generated, so rename it accordingly.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-12-15 12:56:54 +01:00
Gilles Peskine
ccbc318fc5 Remove generation of ssl_debug_helpers_generated.h
It's now under version control and meant to be updated manually.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-12-15 12:55:37 +01:00
Gilles Peskine
09f1ee68b6 Commit header file
Having an automatically generated header file makes it harder to have
working build scripts. The content of ssl_debug_helpers_generated.h isn't
likely to change often, so we can update it manually.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-12-15 12:55:33 +01:00
Ronald Cron
4e62cbc322 Add generated files
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2021-12-15 09:02:53 +01:00
Ronald Cron
17b1e2f6c3 Bump version to 3.1.0
Executed ./scripts/bump_version.sh --version 3.1.0 --so-crypto 11 --so-tls 17
+ fix of build_info.h

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2021-12-15 09:02:53 +01:00
Ronald Cron
1ffa6a538a Changelog updates & fixes
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2021-12-15 09:02:53 +01:00
Ronald Cron
831cf48abf Assemble change log
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2021-12-15 09:02:38 +01:00
Ronald Cron
acf0df81f2 Add change log for #4842
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2021-12-15 09:02:02 +01:00
Ronald Cron
be252a0da9 Add change log for #4859
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2021-12-15 08:43:53 +01:00
Ronald Cron
7e1cb129e8 Add change log for #4514
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2021-12-15 08:41:32 +01:00
Ronald Cron
2a4344d1fa Add change log for #4883
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2021-12-14 18:11:45 +01:00
Dave Rodgman
a53779dba4 Add missing changelog for ARIA (#4959)
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2021-12-14 18:11:45 +01:00
Manuel Pégourié-Gonnard
28e3bcf6e1 Fix misleading ChangeLog entry formatting.
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-12-14 18:11:45 +01:00
Manuel Pégourié-Gonnard
4e511ede90 Double-free goes under security, not bugfix.
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-12-14 18:11:45 +01:00
Ronald Cron
9ed3873905 psa: driver wrapper: cipher: Fix unused variable warning
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2021-12-14 18:11:06 +01:00
Ronald Cron
8188d19b0e Merge branch 'development-restricted' into mbedtls-3.1.0rc-pr 2021-12-14 10:58:18 +01:00
Manuel Pégourié-Gonnard
9fa5bf8e88
Merge pull request #5329 from gilles-peskine-arm/ssl_debug_helpers_generated.h-dependencies
List ssl_debug_helpers_generated.h in generated files
2021-12-14 09:57:38 +01:00
Gilles Peskine
12e27d4c5b List ssl_debug_helpers_generated.h in generated files
Running `generate_ssl_debug_helpers.py` generates both
`ssl_debug_helpers_generated.c` and `ssl_debug_helpers_generated.h`.

List the `.h` file as well as the `.c` file in `check-generated-files.sh` so
that `check-generated-files.sh -u` will complain if it isn't up to date.

List it in `Makefile` and `CMakeLists.txt` so that parallel builds know when
to wait until the `.h` file is present. In `Makefile`, declare the `.c` file
as depending on the `.h` file for order. This way, a dependency for either
will wait until the `.h` file is present, and since the `.h` file is
generated after the `.c` file, this guarantees that the `.c` file is
present.

This fixes random failures of `make -j` from a fresh checkout.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-12-14 00:19:47 +01:00
Gilles Peskine
32d2a58cc2
Merge pull request #5325 from gilles-peskine-arm/zeroize-tag-3.1
Zeroize expected MAC/tag intermediate variables
2021-12-13 19:09:30 +01:00