Skip to content

Commit

Permalink
Code formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Vlad Gheorghiu <[email protected]>
  • Loading branch information
vsoftco committed Feb 5, 2025
1 parent 4d39b92 commit 1a29e93
Showing 1 changed file with 10 additions and 30 deletions.
40 changes: 10 additions & 30 deletions oqs/oqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,7 @@ def _load_liboqs() -> ct.CDLL:
assert liboqs # noqa: S101
except RuntimeError:
# We don't have liboqs, so we try to install it automatically
_install_liboqs(
target_directory=oqs_install_dir, oqs_version_to_install=OQS_VERSION
)
_install_liboqs(target_directory=oqs_install_dir, oqs_version_to_install=OQS_VERSION)
# Try loading it again
try:
liboqs = _load_shared_obj(
Expand Down Expand Up @@ -243,13 +241,9 @@ def oqs_version() -> str:

oqs_python_ver = oqs_python_version()
if oqs_python_ver:
oqs_python_ver_major, oqs_python_ver_minor, oqs_python_ver_patch = version(
oqs_python_ver
)
oqs_python_ver_major, oqs_python_ver_minor, oqs_python_ver_patch = version(oqs_python_ver)
# Warn the user if the liboqs version differs from liboqs-python version
if not (
oqs_ver_major == oqs_python_ver_major and oqs_ver_minor == oqs_python_ver_minor
):
if not (oqs_ver_major == oqs_python_ver_major and oqs_ver_minor == oqs_python_ver_minor):
warnings.warn(
f"liboqs version (major, minor) {oqs_version()} differs from liboqs-python version "
f"{oqs_python_version()}",
Expand Down Expand Up @@ -303,9 +297,7 @@ class KeyEncapsulation(ct.Structure):
("decaps_cb", ct.c_void_p),
]

def __init__(
self, alg_name: str, secret_key: Union[int, bytes, None] = None
) -> None:
def __init__(self, alg_name: str, secret_key: Union[int, bytes, None] = None) -> None:
"""
Create new KeyEncapsulation with the given algorithm.
Expand Down Expand Up @@ -459,15 +451,9 @@ def is_kem_enabled(alg_name: str) -> bool:
return native().OQS_KEM_alg_is_enabled(ct.create_string_buffer(alg_name.encode()))


_KEM_alg_ids = [
native().OQS_KEM_alg_identifier(i) for i in range(native().OQS_KEM_alg_count())
]
_supported_KEMs: tuple[str, ...] = tuple(
[i.decode() for i in _KEM_alg_ids]
) # noqa: N816
_enabled_KEMs: tuple[str, ...] = tuple(
[i for i in _supported_KEMs if is_kem_enabled(i)]
) # noqa: N816
_KEM_alg_ids = [native().OQS_KEM_alg_identifier(i) for i in range(native().OQS_KEM_alg_count())]
_supported_KEMs: tuple[str, ...] = tuple([i.decode() for i in _KEM_alg_ids]) # noqa: N816
_enabled_KEMs: tuple[str, ...] = tuple([i for i in _supported_KEMs if is_kem_enabled(i)]) # noqa: N816


def get_enabled_kem_mechanisms() -> tuple[str, ...]:
Expand Down Expand Up @@ -508,9 +494,7 @@ class Signature(ct.Structure):
("verify_cb", ct.c_void_p),
]

def __init__(
self, alg_name: str, secret_key: Union[int, bytes, None] = None
) -> None:
def __init__(self, alg_name: str, secret_key: Union[int, bytes, None] = None) -> None:
"""
Create new Signature with the given algorithm.
Expand Down Expand Up @@ -755,13 +739,9 @@ def is_sig_enabled(alg_name: str) -> bool:
return native().OQS_SIG_alg_is_enabled(ct.create_string_buffer(alg_name.encode()))


_sig_alg_ids = [
native().OQS_SIG_alg_identifier(i) for i in range(native().OQS_SIG_alg_count())
]
_sig_alg_ids = [native().OQS_SIG_alg_identifier(i) for i in range(native().OQS_SIG_alg_count())]
_supported_sigs: tuple[str, ...] = tuple([i.decode() for i in _sig_alg_ids])
_enabled_sigs: tuple[str, ...] = tuple(
[i for i in _supported_sigs if is_sig_enabled(i)]
)
_enabled_sigs: tuple[str, ...] = tuple([i for i in _supported_sigs if is_sig_enabled(i)])


def get_enabled_sig_mechanisms() -> tuple[str, ...]:
Expand Down

0 comments on commit 1a29e93

Please sign in to comment.