Address more review comments.
parent
97766d708b
commit
7f82b412e3
|
|
@ -24,7 +24,7 @@ classifiers = [
|
|||
dynamic = ["version"]
|
||||
dependencies = [
|
||||
"cffi>=1.17",
|
||||
"typing-extensions",
|
||||
"typing-extensions>=4.4.0",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ if top_level_py not in ["setup.py", "build_ffi.py"]:
|
|||
|
||||
if hasattr(_lib, 'WC_RNG_SEED_CB_ENABLED'):
|
||||
if _lib.WC_RNG_SEED_CB_ENABLED:
|
||||
ret = _lib.wc_SetSeed_Cb(_ffi.addressof(_lib, "wc_GenerateSeed")) # ty:ignore[no-matching-overload]
|
||||
ret = _lib.wc_SetSeed_Cb(_ffi.addressof(_lib, "wc_GenerateSeed")) # ty: ignore[no-matching-overload]
|
||||
if ret < 0:
|
||||
raise WolfCryptApiError("wc_SetSeed_Cb failed", ret)
|
||||
if _lib.FIPS_ENABLED and _lib.FIPS_VERSION >= 5:
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ from wolfcrypt._ffi import ffi as _ffi
|
|||
from wolfcrypt._ffi import lib as _lib
|
||||
from wolfcrypt.exceptions import WolfCryptError, WolfCryptApiError
|
||||
from wolfcrypt.hashes import _Hash
|
||||
from .types import SupportsRsaSign, SupportsRsaVerify
|
||||
from .wc_types import SupportsRsaSign, SupportsRsaVerify
|
||||
|
||||
if _lib.SHA_ENABLED:
|
||||
from wolfcrypt.hashes import Sha # ty: ignore[possibly-missing-import]
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ from wolfcrypt.exceptions import WolfCryptError, WolfCryptApiError
|
|||
from wolfcrypt.hashes import hash_type_to_cls
|
||||
from wolfcrypt.random import Random
|
||||
from wolfcrypt.utils import BytesOrStr, t2b
|
||||
from .types import SupportsRsaSign, SupportsRsaVerify
|
||||
from .wc_types import SupportsRsaSign, SupportsRsaVerify
|
||||
|
||||
if _lib.ASN_ENABLED:
|
||||
from wolfcrypt.asn import pem_to_der # ty: ignore[possibly-missing-import]
|
||||
|
|
@ -2408,12 +2408,15 @@ if _lib.ML_DSA_ENABLED:
|
|||
"""
|
||||
mldsa_priv = cls(mldsa_type)
|
||||
|
||||
try:
|
||||
memoryview(seed)
|
||||
except TypeError as exception:
|
||||
raise TypeError("seed must support the buffer protocol, such as `bytes` or `bytearray`") from exception
|
||||
|
||||
seed = bytes(seed)
|
||||
|
||||
if len(seed) != cls.ML_DSA_KEYGEN_SEED_LENGTH:
|
||||
raise ValueError(
|
||||
f"Seed for generating ML-DSA key must be {cls.ML_DSA_KEYGEN_SEED_LENGTH} bytes"
|
||||
)
|
||||
raise ValueError(f"Seed for generating ML-DSA key must be {cls.ML_DSA_KEYGEN_SEED_LENGTH} bytes")
|
||||
|
||||
ret = _lib.wc_dilithium_make_key_from_seed(mldsa_priv.native_object, seed)
|
||||
|
||||
|
|
@ -2569,12 +2572,15 @@ if _lib.ML_DSA_ENABLED:
|
|||
out_size = _ffi.new("word32 *")
|
||||
out_size[0] = in_size
|
||||
|
||||
try:
|
||||
memoryview(seed)
|
||||
except TypeError as exception:
|
||||
raise TypeError("seed must support the buffer protocol, such as `bytes` or `bytearray`") from exception
|
||||
|
||||
seed = bytes(seed)
|
||||
|
||||
if len(seed) != ML_DSA_SIGNATURE_SEED_LENGTH:
|
||||
raise ValueError(
|
||||
f"Seed for generating a signature must be {ML_DSA_SIGNATURE_SEED_LENGTH} bytes."
|
||||
)
|
||||
raise ValueError(f"Seed for generating a signature must be {ML_DSA_SIGNATURE_SEED_LENGTH} bytes.")
|
||||
|
||||
if ctx is not None:
|
||||
ctx_bytestype = t2b(ctx)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# types.py
|
||||
# wc_types.py
|
||||
#
|
||||
# Copyright (C) 2026 wolfSSL Inc.
|
||||
#
|
||||
Loading…
Reference in New Issue