Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/python_detailed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ env:
LD_LIBRARY_PATH: /usr/local/lib
WIN_LIBOQS_INSTALL_PATH: C:\liboqs
VERSION: 0.14.0
PYOQS_ENABLE_FAULTHANDLER: "1"

concurrency:
group: test-python-detailed-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/python_simplified.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ concurrency:
group: test-python-simplified-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

env:
PYOQS_ENABLE_FAULTHANDLER: "1"

jobs:
build:
Expand Down
20 changes: 14 additions & 6 deletions oqs/oqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
import subprocess
import tempfile # to install liboqs on demand
import time
import faulthandler

faulthandler.enable()
import os

try:
import tomllib # Python 3.11+
Expand Down Expand Up @@ -52,6 +50,18 @@
logger.setLevel(logging.INFO)
logger.addHandler(logging.StreamHandler(stdout))

# To identify issues in native code, we enable faulthandler.
# As an example, this will print a stack trace if a segfault occurs,
# if the STFL key generation flag was not set when building liboqs.
if os.environ.get("PYOQS_ENABLE_FAULTHANDLER", "0") == "1":
import faulthandler

faulthandler.enable()
logger.info("liboqs-python faulthandler is enabled")
else:
logger.info("liboqs-python faulthandler is disabled")


# Expected return value from native OQS functions
OQS_SUCCESS: Final[int] = 0
OQS_ERROR: Final[int] = -1
Expand Down Expand Up @@ -111,9 +121,7 @@ def _load_shared_obj(
elif platform.system() == "Windows":
# Try both oqs.dll and liboqs.dll in the install path
for dll_name in (name, f"lib{name}"):
paths.append(
path.absolute() / Path(dll_name).with_suffix(".dll")
)
paths.append(path.absolute() / Path(dll_name).with_suffix(".dll"))
else: # Linux/FreeBSD/UNIX
paths.append(path.absolute() / Path(f"lib{name}").with_suffix(".so"))
# https://stackoverflow.com/questions/856116/changing-ld-library-path-at-runtime-for-ctypes
Expand Down
1 change: 1 addition & 0 deletions oqs/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def deserialize_stateful_signature_key(
public_key_bytes = one_asym_key["publicKey"].asOctets()
return private_key_bytes, public_key_bytes


def _may_generate_stfl_key(
key_name: str, dir_name: str
) -> tuple[Optional[bytes], Optional[bytes]]:
Expand Down