Skip to content

Add AES-256-ECB to the PolarFire SoC Athena port for AES-XTS and carry its CTR counter past the engine's 32-bit wrap - #12055

Open
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:mpfs_athena_aesxts
Open

dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:mpfs_athena_aesxts

Conversation

@dgarske

@dgarske dgarske commented Nov 6, 2026

Copy link
Copy Markdown
Member

Description

AES-XTS is AES-ECB over tweak-masked data, and _AesXtsHelper() already issues one bulk ECB call per XTS call through the crypto callback, so the Athena F5200 port needs an ECB case and no XTS code. Validating it on the MPFS250TS Video Kit also turned up two bugs that this fixes.

  • mpfs_athena.c: WC_CIPHER_AES_ECB for AES-256, both directions. WC_MPFS_ATHENA_AES_MIN_SZ (32) declines shorter requests to software: XTS sends its tweak and ciphertext-stealing tail as one-block wc_AesEncryptDirect() requests, and one engine round trip per block loses to software. The self-test covers distinct and in-place buffers, the shape XTS uses.
  • CTR counter carry: the engine increments only the low 32 bits of the counter block, so any stream crossing that boundary diverged from wc_AesCtrEncrypt(). Each transfer now stops at the wrap and aes->reg is advanced in software; the self-test runs a stream across it.
  • aes.c: the 64-bit GMULT() table path reads at odd offsets and had no WOLFSSL_USE_ALIGN guard, unlike the 32-bit path; a strict-alignment 64-bit target now takes the byte loop, and the unreachable copy of it is removed.
  • configure.ac turns on AES-ECB with --with-mpfs-athena --enable-aesxts; CI legs for ECB alone and the XTS build; README.

AES-128 and AES-192 requests stay in software, as before.

Testing

MPFS250TS Video Kit, E51 bare metal under wolfBoot's test-app: the self-test, the full wolfcrypt_test() (AES-XTS through the engine, the AES-CTR wrap vector that failed before, AES-GCM where it trapped before) and the benchmark. Host: make check with --enable-aesxts --enable-aesecb --enable-cryptocb, testwolfcrypt with and without WOLFSSL_USE_ALIGN, every port CI leg compiled.

…y its CTR counter past the engine's 32-bit wrap
@dgarske dgarske self-assigned this Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #12055

Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfcrypt-port-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): .github/workflows/mpfs-athena-compile.yml, configure.ac, wolfcrypt/src/port/microchip/README.md
Coverage: 4 of 4 in-scope changed file(s) opened by the reviewer

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Max

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.

2 participants