renode-infrastructure icon indicating copy to clipboard operation
renode-infrastructure copied to clipboard

OpenTitan_AES: Add AES CBC mode support

Open rknastenka opened this issue 6 months ago • 0 comments

Description

This PR introduces Cipher Block Chaining (CBC) mode support to the OpenTitan_AES peripheral. It implements initialization vector (IV) register handling and proper integration with the underlying .NET cryptography engine.

Dependency Note

⚠️ Important: This PR is stacked directly on top of my previous bug fix in PR #205 (which addresses the underlying 128-bit vs 256-bit key-slicing issue outlined in Issue renode/renode#914).

  • If PR #205 is reviewed and merged first, this PR will automatically update to show only the clean, isolated CBC diff.
  • All 10 peripheral tests (including the original ECB tests and the new CBC NIST verification vectors) pass perfectly when both changes are active.

Changes

  • OpenTitan_AES.cs:
    • Added CipherBlockChaining mode handling inside ConfigureAES().
    • Implemented internal IV tracking and automated register processing.
    • Explicitly configured PaddingMode.None to ensure hardware-accurate block alignment.
  • OpenTitan_AES_Test.cs:
    • Added comprehensive 128-bit CBC test vector verification (ShouldEncryptInCBCModeWithNistVector) using official NIST SP 800-38A Example F.2.1 vectors.

How Has This Been Tested?

Ran the full OpenTitan_AES_Tests suite locally using the Release configuration:

dotnet test src/Infrastructure/src/Emulator/Peripherals/Test/PeripheralsTests/PeripheralsTests.csproj -c Release --filter "FullyQualifiedName~OpenTitan_AES_Tests" -p:SignAssembly=false

image

rknastenka avatar Jun 01 '26 09:06 rknastenka