Skip to content

Commit 61c7990

Browse files
Addressed various review comments.
1 parent 917e294 commit 61c7990

6 files changed

Lines changed: 21 additions & 6 deletions

File tree

ChangeLog.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
wolfCrypt-py Release NEXT (TBD, 2026)
2+
==========================================
3+
4+
* Add extra nonce parameter to Random generator
5+
6+
17
wolfCrypt-py Release 5.8.4 (Jan 7, 2026)
28
==========================================
39

requirements/test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
-r prod.txt
22
tox
33
pytest
4+
types-cffi

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
u"Programming Language :: Python :: 3.7",
7575
u"Programming Language :: Python :: 3.8",
7676
u"Programming Language :: Python :: 3.9",
77+
u"Programming Language :: Python :: 3.10",
7778
u"Topic :: Security",
7879
u"Topic :: Security :: Cryptography",
7980
u"Topic :: Software Development"
@@ -83,5 +84,5 @@
8384
install_requires=["cffi>=1.0.0"],
8485
cffi_modules=["./scripts/build_ffi.py:ffibuilder"],
8586

86-
package_data={"wolfcrypt": ["*.dll"]}
87+
package_data={"wolfcrypt": ["*.dll", "**/*.pyi"]}
8788
)

wolfcrypt/_ffi/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import _cffi_backend
2-
import _ffi.lib as lib
2+
import wolfcrypt._ffi.lib as lib
33

44
ffi: _cffi_backend.FFI
55

wolfcrypt/random.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Random:
3434
"""
3535

3636
def __init__(self, nonce: __builtins__.bytes = b"", device_id: int = _lib.INVALID_DEVID) -> None:
37-
self.native_object = _ffi.new("WC_RNG *")
37+
self.native_object: _lib.RNG | None = _ffi.new("WC_RNG *")
3838

3939
ret = _lib.wc_InitRngNonce_ex(self.native_object, nonce, len(nonce), _ffi.NULL, device_id)
4040
if ret < 0: # pragma: no cover

wolfcrypt/utils.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,19 @@
2727

2828
def t2b(string: bytes | bytearray | memoryview | str) -> bytes:
2929
"""
30-
Converts text to binary.
30+
Converts text to bytes.
3131
3232
Passes through bytes unchanged.
3333
Objects of type bytearray or memoryview are converted to bytes.
3434
Encodes str to UTF-8 bytes.
35+
36+
:param string: text to convert to bytes.
37+
:raises TypeError: if string is not one of the supported types.
3538
"""
36-
if isinstance(string, (bytes, bytearray, memoryview)):
39+
if isinstance(string, bytes):
40+
return string
41+
if isinstance(string, (bytearray, memoryview)):
3742
return bytes(string)
38-
return str(string).encode("utf-8")
43+
if isinstance(string, str):
44+
return str(string).encode("utf-8")
45+
raise TypeError(f"String parameter of wrong type {type(string).__name__}, expected bytes, bytearray, memoryview or str")

0 commit comments

Comments
 (0)