Optimized KWP implementation. - #4
Conversation
… memory instead of EEPROM.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request updates the applet's build ID and replaces the existing AES Key Wrap with Padding (KWP) implementation with a new DecryptAESKWP method, supported by an increased iobuf allocation. Review feedback highlights that DecryptAESKWP should return the decrypted plaintext length rather than a boolean to ensure keybuf_size is correctly updated and padding is not processed as key data. Additionally, the implementation is missing a lower bound check for plaintext length required by RFC 5649 and lacks safeguards against data corruption if iobuf is passed as an input or output buffer.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This change optimizes the KWP unwrapping implementation to do as much work as possible in transient memory. Because of this change, the
iobufbuffer was increased to 2800 to support 4096 keys since they have to now fit entirely iniobufduring the KWP process.The core operation is as the following:
N==1, do a single round of ECB. Skip to step 5.iobuf(transient memory).Unsigned64class, since those are also not in transient memory.iobufto the output buffer.iobuf.The main optimizations come from doing all the work in transient memory, as well as not using the
Unsigned64classes.One downside is that
DecryptAESKWPwill not work ifiobufis passed as either the input buffer or the output buffer, however, the TPS currently does not do that, so I don't believe it is a major concern. If it is an issue, a separate transient buffer can be allocated just for the KWP work.Performance Comparison (4096 keys)
Benchmarks were done on a SC230.