Commit graph

9 commits

Author SHA1 Message Date
Yann Gautier
3007c72844 feat(st): do not directly call BSEC functions in common code
When STM32MP2 boots on Cortex-M33, the Cortex-A35 do no more have access
to BSEC peripheral. New static inline stm32_otp_* wrappers are added,
which just redirect to BSEC functions.

While at it remove a useless bsec.h include.

Change-Id: Ie0f917c02e48acf456634f455dae41805bf6adbf
Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
2024-01-18 11:30:42 +01:00
Yann Gautier
9cd784db55 refactor(st): update test for closed chip
The function stm32mp_is_closed_device() is replaced with
stm32mp_check_closed_device(), which return an uint32_t, either
STM32MP_CHIP_SEC_OPEN or STM32MP_CHIP_SEC_CLOSED.

Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
Change-Id: Ie0790cdc36c4b6522083bc1f0e7c38e8061e6adf
2024-01-18 11:30:42 +01:00
Yann Gautier
5c506c7375 fix(st): update comment on encryption key
On STM32MP2, the encryption key is 32 bytes, the key duplication
(done for 16 bytes OTP) is not done. Update the comment to precise that.

Change-Id: I6fc4d652fdd462808918e85f6e5bd0d68d10d436
Yann Gautier <yann.gautier@foss.st.com>
2023-09-27 18:41:46 +02:00
Yann Gautier
76e4fab000 fix(st): allow crypto lib compilation in aarch64
Cast len with size_t, as it is unsigned long on Aarch64, and no more
unsigned int. Changing functions prototypes will not help as
.verify_signature awaits an unsigned int for its last parameter.

Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
Change-Id: I9332fd46301a9653af917802788fd97fe7c8a162
2023-09-27 16:21:58 +02:00
Yann Gautier
dee99f10b1 refactor(auth)!: unify REGISTER_CRYPTO_LIB
Have only one definition for REGISTER_CRYPTO_LIB macro, with all the
possible fields. Worst case adds 4 u64 to crypto_lib_desc.
While at it, correct some MISRA violations:
MC3R1.R12.1: (advisory) The precedence of operators within expressions
should be made explicit.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I1342a20e6eef2354753182c2a81ff959e03e5c81
2023-04-21 09:46:01 +01:00
Yann Gautier
4ac5b3949d refactor(auth): replace plat_convert_pk
Following discussions in the reviews of the patch that introduced
plat_convert_pk() function [1], it was decided to deprecate it to
avoid weak function declaration.
A new optional function pointer convert_pk is added to crypto_lib_desc_t.
A new function crypto_mod_convert_pk() will either call
crypto_lib_desc.convert_pk() if it is defined, or do the same
as what was done by the weak function otherwise.

[1] https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/17174

Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
Change-Id: I9358867f8bfd5e96b5ee238c066877da368e43c6
2023-04-21 09:46:01 +01:00
Yann Gautier
70a422ba83 fix(st-crypto): set get_plain_pk_from_asn1() static
The issue is triggered when enabling -Wmissing-prototypes warning:
plat/st/common/stm32mp_crypto_lib.c:81:5: warning:
 no previous prototype for 'get_plain_pk_from_asn1'
 [-Wmissing-prototypes]
   81 | int get_plain_pk_from_asn1(void *pk_ptr, unsigned int pk_len,
      |     ^~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: Ia36bbaba6e187ab47c203ddf0d7d017b210545cf
2022-12-13 10:54:07 +01:00
Yann Gautier
377846b65e fix(st): include utils.h to solve compilation error
If compiling with STM32MP13 with DECRYPTION_SUPPORT != none, there is
a compilation error:
plat/st/common/stm32mp_crypto_lib.c:
 In function 'plat_get_enc_key_info':
plat/st/common/stm32mp_crypto_lib.c:532:25:
 error: implicit declaration of function 'zeromem'
 [-Werror=implicit-function-declaration]
  532 |                         zeromem(key, *key_len);
      |                         ^~~~~~~

Adding #include <lib/utils.h> solves the error.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I0a20c5632f0379612149333e69875369d4cfca15
2022-12-12 15:15:38 +01:00
Lionel Debieve
ad3e46a35c feat(stm32mp1): add a stm32mp crypto library
Add the crypto library for STM32MP1 to use STM32 hardware
accelerators.

Change-Id: I0bbb941001242a6fdc47514ab3efe07b12249285
Signed-off-by: Nicolas Toromanoff <nicolas.toromanoff@st.com>
Signed-off-by: Lionel Debieve <lionel.debieve@foss.st.com>
2022-11-14 10:55:17 +01:00