Fix StatefulSignature segfault when liboqs lacks STFL keygen support#144
Merged
Conversation
Closes #121. liboqs typedefs OQS_SIG_STFL to OQS_SIG when built without OQS_HAZARDOUS_EXPERIMENTAL_ENABLE_SIG_STFL_KEY_SIG_GEN, so OQS_SIG_STFL_new() returns a struct with an incompatible layout. StatefulSignature.__init__ then segfaulted reading alg_version as a c_char_p over non-pointer data. Detect the build mode before touching the struct: prefer the upstream OQS_SIG_STFL_keygen_and_sign_supported() API (open-quantum-safe/liboqs#2434); fall back to a struct-layout probe (safe c_char_p read at offset 8) for older liboqs. Also add keypair_cb/sign_cb NULL guards in generate_keypair and sign as defense in depth, and document the build-flag requirement in the README. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Douglas Stebila <dstebila@uwaterloo.ca>
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.
Fixes #121.
liboqs typedefs
OQS_SIG_STFLtoOQS_SIGwhen built withoutOQS_HAZARDOUS_EXPERIMENTAL_ENABLE_SIG_STFL_KEY_SIG_GEN, soOQS_SIG_STFL_new()returns a struct with an incompatible layout.StatefulSignature.__init__then segfaulted readingalg_versionas ac_char_pover non-pointer data.Detect the build mode before touching the struct: prefer the upstream
OQS_SIG_STFL_keygen_and_sign_supported()API (added in open-quantum-safe/liboqs#2434); fall back to a struct-layout probe (safec_char_pread at offset 8) for older liboqs. Also addkeypair_cb/sign_cbNULL guards ingenerate_keypairandsignas defense in depth, and document the build-flag requirement in the README.Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com