Skip to content

Modify MCUboot to use PSA key_id_t for key type in AES encryption context#565

Open
de-nordic wants to merge 2 commits into
nrfconnect:mainfrom
de-nordic:psa_use_key_id
Open

Modify MCUboot to use PSA key_id_t for key type in AES encryption context#565
de-nordic wants to merge 2 commits into
nrfconnect:mainfrom
de-nordic:psa_use_key_id

Conversation

@de-nordic
Copy link
Copy Markdown
Contributor

Two commits from upstream:

  • split of encryption headers
  • change in encryption context, where there is no longer raw key stored in encryption context, instead context setup function has been setup to import key into PSA and obtain psa_key_id_t key id for it that is then stored in context; all encryption functions will now operate on that key_id, when using the context.

Replacement of raw key array in encryption context, with psa_key_id_t, has reduced MCUboot binary size by ~224 bytes, for non-KMU and non-log-dbg build; small amount of RAM is saved also.

return mbedtls_aes_setkey_enc(ctx, k, BOOT_ENC_KEY_SIZE * 8);
}

static inline int bootutil_aes_ctr_encrypt(bootutil_aes_ctr_context *ctx, uint8_t *counter, const uint8_t *m, uint32_t mlen, size_t blk_off, uint8_t *c)
Copy link
Copy Markdown
Contributor

@tomchy tomchy Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, I'd prefer to have docstrings inside the interface header, but since this is a [fromtree] commit, I'm not going to require them at this stage.

@de-nordic de-nordic requested a review from nordicjm November 13, 2025 11:22
@de-nordic de-nordic force-pushed the psa_use_key_id branch 3 times, most recently from 1b79117 to 208edf4 Compare November 18, 2025 16:29
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Collaborator

@nvlsianpu nvlsianpu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed upstream

@JL-Bee
Copy link
Copy Markdown

JL-Bee commented Jan 9, 2026

Good work on getting this implemented, however when is this getting merged?

de-nordic added 2 commits May 13, 2026 15:23
Split definitions to crypto backend specific headers.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
(cherry picked from commit 5a161e4)
Store psa_key_id_t key in AES context instead of RAW key.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
(cherry picked from commit e925518)
@de-nordic de-nordic requested a review from a team as a code owner May 13, 2026 15:24
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants