renode-infrastructure
renode-infrastructure copied to clipboard
OpenTitan_AES: Add AES CBC mode support
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
CipherBlockChainingmode handling insideConfigureAES(). - Implemented internal IV tracking and automated register processing.
- Explicitly configured
PaddingMode.Noneto ensure hardware-accurate block alignment.
- Added
OpenTitan_AES_Test.cs:- Added comprehensive 128-bit CBC test vector verification (
ShouldEncryptInCBCModeWithNistVector) using official NIST SP 800-38A Example F.2.1 vectors.
- Added comprehensive 128-bit CBC test vector verification (
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