Skip to content

Fix StatefulSignature segfault when liboqs lacks STFL keygen support#144

Merged
dstebila merged 1 commit into
mainfrom
sig-stfl-segfault
May 14, 2026
Merged

Fix StatefulSignature segfault when liboqs lacks STFL keygen support#144
dstebila merged 1 commit into
mainfrom
sig-stfl-segfault

Conversation

@dstebila
Copy link
Copy Markdown
Member

Fixes #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 (added in 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

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>
@dstebila dstebila added this to the 0.16.0 milestone May 14, 2026
@dstebila dstebila merged commit ca22c48 into main May 14, 2026
9 of 14 checks passed
@dstebila dstebila deleted the sig-stfl-segfault branch May 14, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stateful sigs segfault on macOS and Linux

1 participant