Add support for Blake2 MAC #898

Open
valeriosetti wants to merge 25 commits from valeriosetti/blake2-hmac into development
valeriosetti commented 2026-09-07 09:28:40 -05:00 (Migrated from github.com)

Description

That's the follow-up of https://github.com/Mbed-TLS/TF-PSA-Crypto/pull/867 and it completes the support for Blake2 in tf-psa-crypto.

This PR depends on https://github.com/Mbed-TLS/TF-PSA-Crypto/pull/867 and therefore most of the initial commits come from that PR.

Current limitations

Only positive testing has been added so far. Negative testing is TODO.

PR checklist

  • changelog provided: TODO
  • framework PR not required
  • TF-PSA-Crypto development PR provided: this one
  • TF-PSA-Crypto 1.1 PR not required because: new feature
  • mbedtls development PR not required because: hopefully not, but we'll see what the CI thinks
  • mbedtls 4.1 PR not required because: new feature
  • mbedtls 3.6 PR not required because: new feature
  • tests provided
## Description That's the follow-up of https://github.com/Mbed-TLS/TF-PSA-Crypto/pull/867 and it completes the support for Blake2 in tf-psa-crypto. This PR depends on https://github.com/Mbed-TLS/TF-PSA-Crypto/pull/867 and therefore most of the initial commits come from that PR. ## Current limitations Only positive testing has been added so far. Negative testing is TODO. ## PR checklist - [ ] **changelog** provided: TODO - [ ] **framework PR** not required - [ ] **TF-PSA-Crypto development PR** provided: this one - [ ] **TF-PSA-Crypto 1.1 PR** not required because: new feature - [ ] **mbedtls development PR** not required because: hopefully not, but we'll see what the CI thinks - [ ] **mbedtls 4.1 PR** not required because: new feature - [ ] **mbedtls 3.6 PR** not required because: new feature - **tests** provided
bjwtaylor (Migrated from github.com) reviewed 2026-09-18 03:39:54 -05:00
bjwtaylor (Migrated from github.com) left a comment

Still need to do a full review, but some initial comments?

Still need to do a full review, but some initial comments?
@ -0,0 +1,6 @@
Features
* Support for Blake2 hash algorithms Blake2s and Blake2b has been added.
They are enabled via PSA_WANT_ALG_BLAKE2S_HASH256 and
PSA_WANT_ALG_BLAKE2B_HASH512 respectively.
bjwtaylor (Migrated from github.com) commented 2026-09-18 03:39:26 -05:00

Should PSA_WANT_ALG_BLAKE2_MAC be added here, or is it deliberately ommited?

Should PSA_WANT_ALG_BLAKE2_MAC be added here, or is it deliberately ommited?
@ -156,0 +229,4 @@
tf_psa_crypto_blake2b_finish(&op->ctx.b, mac, mac_size);
} else
#endif /* MBEDTLS_PSA_BUILTIN_ALG_BLAKE2B_HASH512 */
{
bjwtaylor (Migrated from github.com) commented 2026-09-18 03:16:16 -05:00

This call and the call below do not capture the return value. This function can return TF_PSA_CRYPTO_ERR_BUFFER_TOO_SMALL. This is in itself not good and will need fixing, however I think it will mean that you can manipulate the tag to perform a authentication bypass of the PSA MAC boundary by passing multiple forged tags. It may also be possible and advisable to initialise the keyed blake2 context with the requested tag length to mitigate this further. What do you think?

This call and the call below do not capture the return value. This function can return TF_PSA_CRYPTO_ERR_BUFFER_TOO_SMALL. This is in itself not good and will need fixing, however I think it will mean that you can manipulate the tag to perform a authentication bypass of the PSA MAC boundary by passing multiple forged tags. It may also be possible and advisable to initialise the keyed blake2 context with the requested tag length to mitigate this further. What do you think?
@ -132,2 +132,4 @@
MBEDTLS_THREADING_PTHREAD
PSA_CRYPTO_CONFIG_H
PSA_WANT_ALG_BLAKE2B_HASH512
PSA_WANT_ALG_BLAKE2S_HASH256
bjwtaylor (Migrated from github.com) commented 2026-09-18 03:38:23 -05:00

Do we also need PSA_WANT_ALG_BLAKE2_MAC here, or is it expected to be added later?

Do we also need PSA_WANT_ALG_BLAKE2_MAC here, or is it expected to be added later?
valeriosetti commented 2026-09-21 06:21:49 -05:00 (Migrated from github.com)

Rebased to align to recent changes done in https://github.com/Mbed-TLS/TF-PSA-Crypto/pull/867 (which is the base PR for this one)

Rebased to align to recent changes done in https://github.com/Mbed-TLS/TF-PSA-Crypto/pull/867 (which is the base PR for this one)
valeriosetti (Migrated from github.com) reviewed 2026-09-21 06:28:14 -05:00
valeriosetti (Migrated from github.com) reviewed 2026-09-21 06:32:51 -05:00
gilles-peskine-arm (Migrated from github.com) reviewed 2026-09-21 13:19:12 -05:00
valeriosetti (Migrated from github.com) reviewed 2026-09-22 02:12:30 -05:00
This pull request is broken due to missing fork information.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'valeriosetti/blake2-hmac:valeriosetti/blake2-hmac'
git switch 'valeriosetti/blake2-hmac'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'development'
git merge --no-ff 'valeriosetti/blake2-hmac'
git switch 'valeriosetti/blake2-hmac'
git rebase 'development'
git switch 'development'
git merge --ff-only 'valeriosetti/blake2-hmac'
git switch 'valeriosetti/blake2-hmac'
git rebase 'development'
git switch 'development'
git merge --no-ff 'valeriosetti/blake2-hmac'
git switch 'development'
git merge --squash 'valeriosetti/blake2-hmac'
git switch 'development'
git merge --ff-only 'valeriosetti/blake2-hmac'
git switch 'development'
git merge 'valeriosetti/blake2-hmac'
git push origin 'development'
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-Mbed-TLS/TF-PSA-Crypto!898
No description provided.