Repository navigation
Conversation
dstebila
force-pushed
the
fix-constructor-followups
branch
2 times, most recently
from
December 5, 2026 16:32
938902b to
1dedfc9
Compare
- Signature.__init__ never copied suf_cma from the native struct, so Signature.suf_cma and details["is_suf_cma"] were always False. - KeyEncapsulation and Signature now raise RuntimeError naming the algorithm when OQS_KEM_new/OQS_SIG_new returns NULL, matching StatefulSignature, instead of a ValueError from the NULL dereference that callers could mistake for an invalid key length. - Narrow the secret_key annotation on both constructors to Optional[bytes]; an int was advertised but always raised TypeError. Follow-up to #165. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Douglas Stebila <dstebila@uwaterloo.ca>
dstebila
force-pushed
the
fix-constructor-followups
branch
from
December 5, 2026 17:02
1dedfc9 to
2969455
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #165. Stacked on #165: until that merges, this diff also shows its commit. I'll rebase onto
mainonce #165 is in.Changes
Signature.suf_cmawas always False.Signature.__init__copiedeuf_cmaand the other fields from the nativeOQS_SIGstruct but never copiedsuf_cma, soSignature.suf_cmaanddetails["is_suf_cma"]read the wrapper's own zero-initialised ctypes field. For example, ML-DSA reported False.OQS_KEM_new/OQS_SIG_newnow raisesRuntimeError. Previously the first.contentsaccess raisedValueError: NULL pointer access, which callers could mistake for theValueErrorraised for a wrong-length key. The new message names the algorithm and matches whatStatefulSignature.__init__already does.secret_keytype annotation narrowed toOptional[bytes]on both constructors. It advertisedint, but an int always raisedTypeErrorin the length check.Tests
test_sig.test_suf_cma_matches_native: for every enabled signature,suf_cmaanddetails["is_suf_cma"]match the native struct.test_kem/test_sigtest_new_returning_null_raises_runtime_error: patchesOQS_*_newto return NULL and expects aRuntimeErrornaming the algorithm.Tested locally on macOS (Python 3.12) against liboqs
0.17.0-rc1, built with the same options as the automatic install:ValueError: NULL pointer access, and the SUF-CMA test withML-DSA-44: suf_cma does not match liboqs (True).nose2ran 2008 tests, OK.🤖 Generated with Claude Code