!rofs: add AES decryption and authentication via AES-CMAC#155
!rofs: add AES decryption and authentication via AES-CMAC#155adamgreloch wants to merge 2 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @adamgreloch, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces significant security enhancements to the Read-Only File System (ROFS) by integrating AES decryption and authentication via AES-CMAC. It enables the ROFS to handle encrypted images, verifying their integrity upon initialization and decrypting file contents on the fly when a key is provided.
Highlights
- AES-CMAC Image Authentication: Implemented AES-CMAC to verify the integrity and authenticity of the ROFS image during initialization, preventing tampering.
- AES-CTR Data Decryption: Added support for AES-CTR mode decryption, allowing individual file contents within the ROFS image to be decrypted transparently during read operations.
- Integration of libtinyaes: Incorporated the libtinyaes library to provide the underlying cryptographic primitives for AES and CMAC operations.
- Extended ROFS Header: Modified the ROFS header to include space for the AES-CMAC, increasing its size and ensuring compatibility with authenticated images.
- Key-based Initialization: The rofs_init function now accepts an optional encryption key, enabling the ROFS to operate in either encrypted or unencrypted modes.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request adds AES-CTR decryption and AES-CMAC authentication to rofs. The changes are well-structured and integrate the new cryptographic features effectively. However, I've identified a critical bug in the file read logic that could lead to incorrect data decryption. I've also included several medium-severity recommendations to improve code quality, consistency in error handling, and to address code duplication. Addressing these points will enhance the robustness and maintainability of the new functionality.
b831a35 to
5e9b3cf
Compare
Unit Test Results9 462 tests +2 8 873 ✅ +3 50m 20s ⏱️ - 1m 10s Results for commit c029675. ± Comparison against base commit 3840bae. This pull request removes 1 and adds 3 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
5e9b3cf to
ac2b420
Compare
ac2b420 to
36306f2
Compare
f3bb787 to
0db4dd1
Compare
Breaking change: changes the header structure JIRA: NIL-693
mkrofs host utility from p-r-hostutils depends on rofs layout definition. Thanks to separate header, the fs layout can be exposed to that utility by building `librofs-header` make target in `phoenix-rtos-filesystems` JIRA: NIL-693
0db4dd1 to
c029675
Compare
JIRA: NIL-693
Description
Motivation and Context
Types of changes
Breaking change: rofs header structure has been altered to support cryptographic signatures
How Has This Been Tested?
Checklist:
Special treatment