Commit graph

36 commits

Author SHA1 Message Date
Andrzej Kurek
8a045ce5e6 Unify PSA to Mbed TLS error translation
Move all error translation utilities to psa_util.c.
Introduce macros and functions to avoid having
a local copy of the error translating function in
each place.
Identify overlapping errors and introduce a
generic function.
Provide a single macro for all error translations
(unless one file needs a couple of different ones).
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-03-03 05:23:44 -05:00
Gilles Peskine
449bd8303e Switch to the new code style
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-11 14:50:10 +01:00
Raef Coles
142e577c34
Add extra zeroization to LMS and LMOTS
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:30:03 +01:00
Raef Coles
9fc303a99a
Add extra LMOTS import negative tests
And fix failures that are related to the new tests

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:30:01 +01:00
Raef Coles
4829459c90
Validate LMOTS sig length before parsing type
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:47 +01:00
Raef Coles
faf59babe8
Make LMS verification return VERIFY_FAILED more
To align with PSA error code rules on when VERIFY_FAILED is returned vs
INVALID_ARGUMENT

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:42 +01:00
Raef Coles
fbd60ec775
Change LMS and LMOTS init functions to use memset
Instead of zeroize

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:40 +01:00
Raef Coles
f6cb5a4826
Fix LMS return statements having incorrect style
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:35 +01:00
Raef Coles
d48f7e90bb
Allocate LMS C_RANDOM_VALUE as hash size
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:32 +01:00
Raef Coles
370cc43630
Make LMS public key export part of public key api
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:28 +01:00
Raef Coles
e89488debf
Fix bug in LMS public key loading
To avoid using the type before it is parsed from the signature

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:27 +01:00
Raef Coles
be3bdd8240
Rename LMS and LMOTS init/free functions
To match convention

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:18 +01:00
Raef Coles
29117d2e4e
Update LMS PSA error conversion
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:17 +01:00
Raef Coles
be0c2f9183
Update LMS local variable allocation
To use a default failure value, and to avoid a call to
psa_hash_operation_init()

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:15 +01:00
Raef Coles
2ac352a322
Make LMS functions args const where required
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:14 +01:00
Raef Coles
5127e859d7
Update LMS and LMOTS dependency macros
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:11 +01:00
Raef Coles
57d5328ad5
Remove MBEDTLS_LM(OT)S prefix from internal macros
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:00 +01:00
Raef Coles
ad05425ab7
Update naming of internal LMS functions
To comply with the mbedtls_ requirement

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:59 +01:00
Raef Coles
98d6e22050
Remove doxygen markup from internal LMS functions
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:54 +01:00
Raef Coles
9c9027b1a4
Add extra LMS and LMOTS tests
NULL-message and LMOTS signature leak tests

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:50 +01:00
Raef Coles
fa24f9d6ea
Minor fixes to LMS and LMOTS macros
Update some names, use the correct macro in certain places.

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:48 +01:00
Raef Coles
0a967ccf9a
Document LMS and LMOTS internal functions
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:47 +01:00
Raef Coles
8738a49d0c
Fix iterator types in LMOTS
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:45 +01:00
Raef Coles
e0a17610d1
Fix LMS/LMOTS if-statement style
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:41 +01:00
Raef Coles
9b88ee5d5d
Fix LMS and LMOTS coding style violations
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:40 +01:00
Raef Coles
366d67d9af
Shorted LMS and LMOTS line-lengths
To attempt to comply with the 80-char suggestion

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:38 +01:00
Raef Coles
e9479a0264
Update LMS API to support multiple parameter sets
Parameterise macros to allow variation of sizes

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:36 +01:00
Raef Coles
ab4f87413a
Add MBEDTLS_LMS_PRIVATE define
To enable private key operations

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:35 +01:00
Raef Coles
ebd35b5b80
Rename LMS internal tree-manipulation functions
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:31 +01:00
Raef Coles
891c613f31
Update LMOTS signature use of temporary variables
Document them properly, and move random value to a temporary variable

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:29 +01:00
Raef Coles
0c88d4e447
Remove superfluous casts in LMS and LMOTS
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:28 +01:00
Raef Coles
f5632d3efc
Remove MBEDTLS_PRIVATE usage from LMS and LMOTS
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:27 +01:00
Raef Coles
01c71a17b3
Update LMS and LMOTS api
Fix function names and parameters. Move macros to be more private.
Update implementation.

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:25 +01:00
Raef Coles
c8f9604d7b
Use PSA hashing for LMS and LMOTS
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:23 +01:00
Raef Coles
7dce69a27a
Make LMOTS a private api
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:22 +01:00
Raef Coles
8ff6df538c
Add LMS implementation
Also an LM-OTS implementation as one is required for LMS.

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:15 +01:00