Address more review comments.
Also added a line to the change log to mention that typing information has been added.pull/125/head
parent
66b2ffb7c8
commit
97766d708b
|
|
@ -28,6 +28,7 @@ wolfCrypt-py Release 5.9.2 (Jul 1, 2026)
|
|||
* Address many small issues found by Fenrir
|
||||
* Add reseed support to random number generator
|
||||
* The RsaPublic key parameter is now mandatory as it is always needed by an internal function call.
|
||||
* Add typing annotations
|
||||
|
||||
|
||||
wolfCrypt-py Release 5.8.4 (Jan 7, 2026)
|
||||
|
|
|
|||
|
|
@ -17,9 +17,6 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
from typing import cast
|
||||
|
||||
from _cffi_backend import Lib
|
||||
|
||||
from wolfcrypt._version import __version__, __wolfssl_version__
|
||||
|
||||
|
|
@ -53,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(cast(Lib, _lib), "wc_GenerateSeed"))
|
||||
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:
|
||||
|
|
|
|||
|
|
@ -2397,19 +2397,18 @@ if _lib.ML_DSA_ENABLED:
|
|||
return mldsa_priv
|
||||
|
||||
@classmethod
|
||||
def make_key_from_seed(cls, mldsa_type: MlDsaType, seed: bytes | list[int] | tuple[int]) -> MlDsaPrivate:
|
||||
def make_key_from_seed(cls, mldsa_type: MlDsaType, seed: bytes) -> MlDsaPrivate:
|
||||
"""
|
||||
Deterministically generate the key from a seed.
|
||||
|
||||
:param mldsa_type: ML-DSA type
|
||||
:type mldsa_type: MlDsaType
|
||||
:param seed: the (32 byte) seed from which to deterministically create the key
|
||||
:type seed: bytes or list/tuple of int (value in the range 0-255)
|
||||
:type seed: bytes
|
||||
"""
|
||||
mldsa_priv = cls(mldsa_type)
|
||||
|
||||
if not isinstance(seed, (list, tuple, bytes)):
|
||||
raise TypeError("seed must be bytes or list/tuple")
|
||||
seed = bytes(seed)
|
||||
|
||||
if len(seed) != cls.ML_DSA_KEYGEN_SEED_LENGTH:
|
||||
raise ValueError(
|
||||
|
|
@ -2549,12 +2548,12 @@ if _lib.ML_DSA_ENABLED:
|
|||
|
||||
return _ffi.buffer(signature, out_size[0])[:]
|
||||
|
||||
def sign_with_seed(self, message: BytesOrStr, seed: bytes | list[int] | tuple[int], ctx: BytesOrStr | None = None) -> bytes:
|
||||
def sign_with_seed(self, message: BytesOrStr, seed: bytes, ctx: BytesOrStr | None = None) -> bytes:
|
||||
"""
|
||||
:param message: message to be signed
|
||||
:type message: bytes or str
|
||||
:param seed: 32-byte seed for deterministic signature generation.
|
||||
:type seed: bytes or list/tuple of int (value in the range 0-255)
|
||||
:type seed: bytes
|
||||
:param ctx: context, maximum 255 bytes (optional by default but that requires support for no-context
|
||||
signing/verification compiled in; pass empty string "" for FIPS-204 empty-context signing).
|
||||
:type ctx: bytes or str. None for no-context signing.
|
||||
|
|
@ -2570,8 +2569,7 @@ if _lib.ML_DSA_ENABLED:
|
|||
out_size = _ffi.new("word32 *")
|
||||
out_size[0] = in_size
|
||||
|
||||
if not isinstance(seed, (list, tuple, bytes)):
|
||||
raise TypeError("seed must be bytes or list/tuple")
|
||||
seed = bytes(seed)
|
||||
|
||||
if len(seed) != ML_DSA_SIGNATURE_SEED_LENGTH:
|
||||
raise ValueError(
|
||||
|
|
|
|||
Loading…
Reference in New Issue