-
Notifications
You must be signed in to change notification settings - Fork 104
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
Include use of loaded 'libctx' context in KEM and SIG procedures (#557) #599
Conversation
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.
Thanks very much for the contribution @RodriM11 ! Just wondering while CI tests this: Would it be feasible to add a test validating this improvement?
I wondered that myself when coding it and here is what I came up with. I tested it executing the available test (introducing minor variations to the DRBG procedure, for example) and analyzing the code executed to check that indeed was performing as I expected (but this is clearly not a way to test this). Since the modifications are pertaining to internal structures and not ones directly accessible in a test, it gets harder to do so. The modifications amount to use the
To have a test of this behavior without having to incur on these problems, I would propose to construct the test in the following way:
|
Thanks for your thoughts pertaining as to how to test this @RodriM11 . I agree that "toggling" DRBG in specific libctxs (other than default) is a good idea how to check this. Pertaining to the 3 initial "inconveniences" you see, allow me to ask whether they are really problematic, or rather, can be simplified:
Would these thoughts simplify things? I'd much rather have 1 "basic" test than none at all -- although I'd still argue it be pretty complete considering the design of the system within which it runs. |
Thank you for your insight @baentsch! I agree with you on the DRBG part, in fact I think an instantiation of a libctx context with openssl's |
You're right: That's a very fair point/assumption I didn't consider.
Sounds like a good plan.
Well, is this sufficient (for testing the new code)? I'm a bit unsure as to whether there is a relation between the liboqs DRBG and the openssl |
Yes, you are absolutely right. The improvement of adding the libctx context in |
Will this change also affect the fetching properties (e.g. |
No, it will not. The inclusion made is pertaining to cases in which cryptographic operations are to be performed, impacting elements like the DRBG to consume and so on, and no fetching property was used in those (and none is established now). It is true though that, with these changes, the API's used to use the |
ahh -- then I get it. Sensible approach to make things easier. Thanks for the idea and explanation. Looking forward to seeing the test then! Completely independent of this, of course, is the (at least to me only now obvious) shortcoming of |
Included libctx use in classical keys recreation, formmating changes
I have added the test, along with the correct LLVM formatting (I apologize for my first commit). Regarding |
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.
Please see the single comment; more problematic is that this code base does not permit a clean build as per this error message:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LIBOQS_CRYPTO_LIBRARY
linked by target "oqs_test_libctx" in directory /home/mib/git/rodrim11/oqs-provider/test
--> Is something not checked in? To reproduce, I cloned your repo clean and ran scripts/fullbuild.sh
there...
Signed-off-by: RodriM11 <[email protected]>
I was checking the construction too. The problem is that I was both making a poor choice as to how to link The |
Signed-off-by: RodriM11 <[email protected]>
I apologize for the amount of commits (I can close this PR and create a "clean" one if desired). Turns out that the way I constructed the test was not "random" enough for RSA procedures, as I was always relying on a fixed, constant string of all equal bytes (spent more time that I should have today realizing it haha). I modified the test to "reset" on each iteration, and using the fact that |
Thanks for these improvements! The PR branch now builds for me in the default config again.
Ah, then I understand why the test is not run when doing a default build (shared lib provider, statically linked liboqs symbols). Now, I'm not sure as part of which CI test the new test would be executed: just triggered a full run so you can check and point it out if/where run-- if not, please consider adding a (github-based CI) build config that causes the test to be run. Or if you're unfamiliar with GH CI, just let me know how the build should be done so I can run it locally and add it to CI.
No reason to apologize: Things improve over time and that's fair to be visible (and I'd squash-merge eventually anyway). The one reason why a new "single-commit" PR might be good were if you wanted to get the DCO "test" to pass (see open-quantum-safe/liboqs#1760 for info; I keep apologizing for this and don't think this is sensible, but LinuxFoundation demanded use of this procedure (in essence, always adding "-s" to each commit) as part of their take-over of this project. |
Signed-off-by: RodriM11 <[email protected]>
I have checked the CI tests and, except from the first CircleCI tests (in which it was being run), no other CI I saw actually compiled the test (since, as you pointed out, the default construction, shared |
That indeed would be good. I basically now can follow the jist of the new test and agree that it tests what it should. Also, it now builds by default, and it shows your new libctx improvement passes (and fails on the original code). Good work & Thanks again! I have some comments on the code that I'll still add to this PR so you could address them before proceeding to a "clean, ready-to-merge PR": OK? |
Yes, sounds good. |
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.
Many nits, conceptually this all looks good. Looking forward to the "final PR". Thanks again, @RodriM11 and have a good start into 2025!
Signed-off-by: RodriM11 <[email protected]>
I have added the requested changes in this PR in case any further revision is desired. I will proceed to close this PR and open a new, clean one if no further changes are requested. Thanks for your help, and happy holidays! |
Thanks @RodriM11 -- not all my PR comments have been addressed, so you may want to take another look before doing a "clean" PR. Happy New Year also to you! |
I think that the comments you highlighted were actually addressed on my last commit (nit typos, the |
{"x448", 56, 56, 56, 0}, | ||
}; | ||
|
||
static OSSL_LIB_CTX *libctx = NULL; |
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.
My question pertains to why this is required to be statically allocated and not passed as parameter?
Only one question remaining pertaining to "libctx" being a (file-)global static variable: Why can't it be a stack-only parameter passed between (test) functions? Otherwise, all good for me: Please do a final PR for this now. Accordingly closing this PR for now. |
Inclusion of use of OSSL_LIB_CTX * context in which the oqsprovider is loaded to KeyGen, Encaps, Decaps (KEM) and KeyGen, Sign, Verify (SIG) operations.
This PR is associated with issue #557. I apologize for the delay in the commit.