Commit 0fbee98
authored
This commit refactors the `AesCcm` class to simplify its public interface,
decoupling the high-level API from the underlying cryptographic execution.
Key improvements:
- Redesigned the API from a series of procedural method calls
(`Init()`, `Header()`, `Payload()`, `Finalize()`) into a unified,
stateful model. Callers now pre-configure the operation parameters using
dedicated setters (`SetKey()`, `SetNonce()`, `SetAuthData()`,
`SetTagLength()`) and execute the entire cryptographic operation in a
single step via unified `Process()` methods.
- Introduced a nested `Engine` class to encapsulate the low-level AES-CCM
mathematical and cryptographic state. The `Engine` provides clean internal
interfaces for both optimized one-shot (single-part) and multi-part
operations.
- This architectural separation allows the outer `AesCcm` class to focus on
parameter validation, high-level buffer management, and complex `Message`
chunk iterations, while the `Engine` remains focused purely on the
cryptographic core. This also provides a clean extension point to easily
route one-shot operations to platform-specific hardware acceleration APIs
in the future.
- Updated `Mac` and `Mle` modules to use the simplified APIs, reducing
boilerplate code.
- Retained a static `Perform()` wrapper to support the legacy public
`otCrypto` API.
- Updated unit tests to validate the new stateful interfaces, including
robust in-place message chunk processing and separate-buffer
validations.
1 parent a055c4b commit 0fbee98
7 files changed
Lines changed: 569 additions & 281 deletions
File tree
- src/core
- api
- crypto
- mac
- thread
- tests/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
69 | 67 | | |
70 | 68 | | |
71 | 69 | | |
72 | 70 | | |
73 | 71 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 72 | + | |
| 73 | + | |
85 | 74 | | |
0 commit comments