-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow OBJECT_OP_UNWRAP to modify attributes #728
base: develop
Are you sure you want to change the base?
Conversation
42d04e1
to
828e2c8
Compare
Please rebase on develop and mark as ready when ready. |
828e2c8
to
42006eb
Compare
42006eb
to
84d1af0
Compare
84d1af0
to
14749ef
Compare
Hello @jschlyter |
@coderabbitai review |
✅ Actions performedReview triggered.
|
WalkthroughThe changes in the Changes
Suggested reviewers
Poem
Tip 🌐 Web search-backed reviews and chat
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
🔇 Additional comments (2)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be nice with a test in SymmetricAlgorithmTests.cpp
similar to its testNonModifiableDesKeyGeneration
.
14749ef
to
9e67f7e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
src/lib/test/SymmetricAlgorithmTests.h (1)
44-58
: Add the new test to the test suite.The new method
aesWrapUnwrapNonModifiableGeneric
is not included in the test suite. Consider adding it to ensure the new functionality is tested.Apply this diff to add the test:
CPPUNIT_TEST_SUITE(SymmetricAlgorithmTests); CPPUNIT_TEST(testAesEncryptDecrypt); CPPUNIT_TEST(testDesEncryptDecrypt); #ifdef HAVE_AES_KEY_WRAP CPPUNIT_TEST(testAesWrapUnwrap); +CPPUNIT_TEST(testAesWrapUnwrapNonModifiable); #endif CPPUNIT_TEST(testNullTemplate);You'll also need to add the corresponding public test method. Let me know if you'd like me to help with that implementation.
🧹 Nitpick comments (2)
src/lib/test/SymmetricAlgorithmTests.cpp (2)
1189-1190
: Add documentation for the test method.Please add comments explaining that this test verifies unwrapping behavior when CKA_MODIFIABLE is set to false.
+// Test that unwrapping works correctly when CKA_MODIFIABLE is set to false. +// This verifies the fix for issue #707 which allows OBJECT_OP_UNWRAP to modify attributes +// even when CKA_MODIFIABLE is false. void SymmetricAlgorithmTests::aesWrapUnwrapNonModifiableGeneric(CK_MECHANISM_TYPE mechanismType, CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hKey)
1189-1288
: Consider refactoring to reduce code duplication.This method shares a lot of code with
aesWrapUnwrapGeneric
. Consider extracting the common functionality into helper methods to improve maintainability.For example:
- Extract key generation and wrapping into a helper method
- Extract unwrapping and verification into another helper method
- Pass CKA_MODIFIABLE value as a parameter
+// Helper method for key generation and wrapping +void wrapKey(CK_SESSION_HANDLE hSession, CK_MECHANISM_TYPE mechanismType, + CK_OBJECT_HANDLE hKey, CK_BBOOL bExtractable, + CK_BYTE_PTR& wrappedPtr, CK_ULONG& wrappedLen) { + // Common key generation and wrapping code +} + +// Helper method for unwrapping and verification +void unwrapAndVerifyKey(CK_SESSION_HANDLE hSession, CK_MECHANISM_TYPE mechanismType, + CK_OBJECT_HANDLE hKey, CK_BBOOL bModifiable, + CK_BYTE_PTR wrappedPtr, CK_ULONG wrappedLen) { + // Common unwrapping and verification code +}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/lib/P11Attributes.cpp
(1 hunks)src/lib/test/SymmetricAlgorithmTests.cpp
(1 hunks)src/lib/test/SymmetricAlgorithmTests.h
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/lib/P11Attributes.cpp
🔇 Additional comments (1)
src/lib/test/SymmetricAlgorithmTests.h (1)
91-91
: LGTM! Method signature follows existing patterns.The new method
aesWrapUnwrapNonModifiableGeneric
follows the established pattern of similar methods in the class, maintaining consistency in the codebase.
…ify attributes when CKA_MODIFIABLE is true
9e67f7e
to
1c98eb5
Compare
I have added a |
Allow attributes update when CKA_MODIFIABLE is false and the operation is UNWRAP.
Here is my proposed fix for #707
Summary by CodeRabbit
New Features
Bug Fixes