Crypt module#549
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR adds a new 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
Modules/crypt-module/source/crypt.cpp (1)
126-133: 🔒 Security & Privacy | 🔴 Critical | ⚡ Quick winFix IV derivation here —
%=leaves every byte at0, so CBC always uses an all-zero IV and encryptions become deterministic for a given plaintext/key. If any input byte is0, this also becomes undefined behavior. This should be^=(or another non-zero mixing step).Modules/crypt-module/source/crypt.cpp:126Modules/crypt-module/source/hash.cpp (1)
14-25: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winOut-of-bounds read in
djb2_data.The loop unconditionally reads
*data_bytes++before checkinglength(OOB read forlength == 0), and reads one extra byte past the buffer at the end of every call (c = *data_bytes++on the last iteration readsdata[length]). The hash result is unaffected since the extra byte is discarded, but this is undefined behavior that can fault on guarded/boundary memory, e.g. hashing arbitrary key/config buffers fromcrypt.cpp.🐛 Proposed fix
uint32_t djb2_data(const void* data, size_t length) { uint32_t hash = 5381; auto* data_bytes = static_cast<const uint8_t*>(data); - uint8_t c = *data_bytes++; - size_t index = 0; - while (index < length) { - hash = ((hash << 5) + hash) + (uint32_t)c; // hash * 33 + c - c = *data_bytes++; - index++; - } + for (size_t index = 0; index < length; index++) { + hash = ((hash << 5) + hash) + (uint32_t)data_bytes[index]; // hash * 33 + c + } return hash; }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e8f36b5c-98c4-4eb9-a59a-ff8af1751a32
📒 Files selected for processing (15)
CMakeLists.txtFirmware/CMakeLists.txtModules/crypt-module/CMakeLists.txtModules/crypt-module/include/tactility/crypt.hModules/crypt-module/include/tactility/crypt_module.hModules/crypt-module/include/tactility/hash.hModules/crypt-module/source/crypt.cppModules/crypt-module/source/hash.cppModules/crypt-module/source/module.cppTactility/CMakeLists.txtTactility/Source/Tactility.cppTactility/Source/app/chat/ChatSettings.cppTactility/Source/service/wifi/WifiApSettings.cppTactilityCore/CMakeLists.txtTests/Tactility/CMakeLists.txt
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 42e0f1b6-4015-43e0-b501-7b8e5ac9063d
📒 Files selected for processing (27)
.github/workflows/tests.ymlTests/CMakeLists.txtTests/crypt-module/CMakeLists.txtTests/crypt-module/Source/CryptTest.cppTests/crypt-module/Source/HashTest.cppTests/crypt-module/Source/Main.cppbuild-tests/Libraries/FreeRTOS-Kernel/libfreertos_kernel.abuild-tests/Libraries/FreeRTOS-Kernel/portable/libfreertos_kernel_port.abuild-tests/Libraries/mbedtls/3rdparty/everest/libeverest.abuild-tests/Libraries/mbedtls/3rdparty/p256-m/libp256m.abuild-tests/Libraries/mbedtls/library/libmbedcrypto.abuild-tests/Libraries/mbedtls/library/libmbedtls.abuild-tests/Libraries/mbedtls/library/libmbedx509.abuild-tests/Makefilebuild-tests/Modules/crypt-module/Makefilebuild-tests/Modules/crypt-module/cmake_install.cmakebuild-tests/Tactility/Makefilebuild-tests/TactilityCore/Makefilebuild-tests/Tests/CTestTestfile.cmakebuild-tests/Tests/Tactility/Makefilebuild-tests/Tests/TactilityCore/TactilityCoreTestsbuild-tests/Tests/cmake_install.cmakebuild-tests/Tests/crypt-module/CTestTestfile.cmakebuild-tests/Tests/crypt-module/CryptModuleTestsbuild-tests/Tests/crypt-module/Makefilebuild-tests/Tests/crypt-module/cmake_install.cmakebuild-tests/cmake_install.cmake
💤 Files with no reviewable changes (1)
- build-tests/TactilityCore/Makefile
✅ Files skipped from review due to trivial changes (9)
- build-tests/Tests/cmake_install.cmake
- build-tests/Tests/crypt-module/CTestTestfile.cmake
- .github/workflows/tests.yml
- build-tests/Tests/CTestTestfile.cmake
- build-tests/Tests/crypt-module/cmake_install.cmake
- build-tests/Modules/crypt-module/cmake_install.cmake
- build-tests/Tactility/Makefile
- build-tests/Tests/Tactility/Makefile
- build-tests/Makefile
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ff39a4b4-f9ca-4ba1-b864-e0ba5b85876c
📒 Files selected for processing (5)
.gitignoreModules/crypt-module/include/tactility/crypt.hModules/crypt-module/source/crypt.cppTactility/Source/service/wifi/WifiApSettings.cppTests/crypt-module/Source/CryptTest.cpp
✅ Files skipped from review due to trivial changes (1)
- .gitignore
🚧 Files skipped from review as they are similar to previous changes (1)
- Tests/crypt-module/Source/CryptTest.cpp
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a9940a46-a59f-4dbe-ad9a-24603d9f54f3
📒 Files selected for processing (3)
Buildscripts/release-sdk.pyModules/crypt-module/source/module.cppTactility/Source/service/wifi/WifiApSettings.cpp
Uh oh!
There was an error while loading. Please reload this page.