Skip to content

Commit

Permalink
Crypto: Adjust CRYPTO_ENGINE_BUF_SIZE in profiles with RSA encryption
Browse files Browse the repository at this point in the history
If a profile supports RSA encryption/decryption, increase the
default size of the CRYPTO_ENGINE_BUF_SIZE to 0x3000 to avoid
PSA_ERROR_INSUFFICIENT_MEMORY when calling into Mbed TLS using
RSA-2048 keys. Existing value is calibrated for RSA-1024 which
is less relevant nowadays from security perspective.

Signed-off-by: Antonio de Angelis <[email protected]>
Change-Id: I3dc3e1fd26da9d9e69bce5b0b480228e896aa025
(cherry picked from commit c271e4a)
  • Loading branch information
adeaarm authored and tomi-font committed Nov 28, 2024
1 parent 83c8b2a commit fa020a8
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
7 changes: 4 additions & 3 deletions config/config_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@
/* Crypto Partition Configs */

/*
* Heap size for the crypto backend
* CRYPTO_ENGINE_BUF_SIZE needs to be >8KB for EC signing by attest module.
* Heap size for the crypto backend. This is statically allocated
* inside the Crypto service and used as heap through the default
* Mbed TLS allocator
*/
#ifndef CRYPTO_ENGINE_BUF_SIZE
#define CRYPTO_ENGINE_BUF_SIZE 0x2080
#define CRYPTO_ENGINE_BUF_SIZE 0x3000
#endif

/* The max number of concurrent operations that can be active (allocated) at any time in Crypto */
Expand Down
7 changes: 4 additions & 3 deletions config/profile/config_profile_large.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@
#endif

/*
* Heap size for the crypto backend
* CRYPTO_ENGINE_BUF_SIZE needs to be >8KB for EC signing by attest module.
* Heap size for the crypto backend. This is statically allocated
* inside the Crypto service and used as heap through the default
* Mbed TLS allocator
*/
#ifndef CRYPTO_ENGINE_BUF_SIZE
#define CRYPTO_ENGINE_BUF_SIZE 0x2380
#define CRYPTO_ENGINE_BUF_SIZE 0x3000
#endif

/* The max number of concurrent operations that can be active (allocated) at any time in Crypto */
Expand Down
5 changes: 3 additions & 2 deletions config/profile/config_profile_medium.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
/* Crypto Partition Configs */

/*
* Heap size for the crypto backend
* CRYPTO_ENGINE_BUF_SIZE needs to be >8KB for EC signing by attest module.
* Heap size for the crypto backend. This is statically allocated
* inside the Crypto service and used as heap through the default
* Mbed TLS allocator
*/
#ifndef CRYPTO_ENGINE_BUF_SIZE
#define CRYPTO_ENGINE_BUF_SIZE 0x2080
Expand Down
5 changes: 3 additions & 2 deletions config/profile/config_profile_medium_arotless.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
/* Crypto Partition Configs */

/*
* Heap size for the crypto backend
* CRYPTO_ENGINE_BUF_SIZE needs to be >8KB for EC signing by attest module.
* Heap size for the crypto backend. This is statically allocated
* inside the Crypto service and used as heap through the default
* Mbed TLS allocator
*/
#ifndef CRYPTO_ENGINE_BUF_SIZE
#define CRYPTO_ENGINE_BUF_SIZE 0x2080
Expand Down
6 changes: 5 additions & 1 deletion config/profile/config_profile_small.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@

/* Crypto Partition Configs */

/* Heap size for the crypto backend */
/*
* Heap size for the crypto backend. This is statically allocated
* inside the Crypto service and used as heap through the default
* Mbed TLS allocator
*/
#ifndef CRYPTO_ENGINE_BUF_SIZE
#define CRYPTO_ENGINE_BUF_SIZE 0x400
#endif
Expand Down

0 comments on commit fa020a8

Please sign in to comment.