Skip to content
Merged
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
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
if mo:
verstr = mo.group(1)
else:
raise RuntimeError("Unable to find version string in %s." % (VERSIONFILE,))
raise RuntimeError(f"Unable to find version string in {VERSIONFILE}.")
VSRE = r"^__wolfssl_version__ = ['\"]([^'\"]*)['\"]"
mo = re.search(VSRE, verstrline, re.M)
if mo:
wolfverstr = mo.group(1)
else:
raise RuntimeError("Unable to find version string in %s." % (VERSIONFILE,))
raise RuntimeError(f"Unable to find version string in {VERSIONFILE}.")


# long_description
Expand Down
6 changes: 3 additions & 3 deletions tests/test_delete_descriptor_binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ def test_lib_fn_class_attr_is_staticmethod(cls, attr):
"""
raw = inspect.getattr_static(cls, attr)
assert isinstance(raw, staticmethod), (
"%s.%s must be wrapped in staticmethod(...) to prevent Python's "
f"{cls.__name__}.{attr} must be wrapped in staticmethod(...) to prevent Python's "
"descriptor protocol from injecting `self` as an extra positional "
"argument when the underlying callable is a plain Python function "
"(e.g. a test mock). Got %r." % (cls.__name__, attr, type(raw))
f"(e.g. a test mock). Got {type(raw)!r}."
)


Expand Down Expand Up @@ -179,7 +179,7 @@ def recorder(*args, **kwargs):
assert kwargs == {}
assert args == (native,), (
"Random.__del__ must call _delete with only native_object, "
"but got args=%r" % (args,)
f"but got {args=!r}"
)
finally:
Random._delete = original
4 changes: 2 additions & 2 deletions wolfcrypt/asn.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def der_to_pem(der, pem_type):
if pem_length <= 0:
raise WolfCryptApiError("Error getting required PEM buffer length.", pem_length)

pem = _ffi.new("byte[%d]" % pem_length)
pem = _ffi.new(f"byte[{pem_length}]")
pem_length = _lib.wc_DerToPemEx(der, len(der), pem, pem_length,
_ffi.NULL, pem_type)
if pem_length <= 0:
Expand All @@ -80,7 +80,7 @@ def make_signature(data, hash_cls, key=None):
hash_obj.update(data)
digest = hash_obj.digest()

plaintext_sig = _ffi.new("byte[%d]" % _lib.MAX_DER_DIGEST_SZ)
plaintext_sig = _ffi.new(f"byte[{_lib.MAX_DER_DIGEST_SZ}]")
hash_oid = hash_oid_from_class(hash_cls)
plaintext_len = _lib.wc_EncodeSignature(plaintext_sig, digest,
len(digest), hash_oid)
Expand Down
197 changes: 83 additions & 114 deletions wolfcrypt/ciphers.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion wolfcrypt/hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def digest(self):
way by this function; you can continue updating the object
after calling this function.
"""
result = _ffi.new("byte[%d]" % self.digest_size)
result = _ffi.new(f"byte[{self.digest_size}]")

if self._native_object:
obj = _ffi.new(self._native_type)
Expand Down
6 changes: 3 additions & 3 deletions wolfcrypt/hkdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def HKDF(hash_cls, in_key, salt=None, info=None, out_len=None):
if out_len is None:
out_len = hash_cls.digest_size

out = _ffi.new("byte[%d]" % out_len)
out = _ffi.new(f"byte[{out_len}]")
ret = _lib.wc_HKDF(
hash_cls._type,
in_key,
Expand Down Expand Up @@ -92,7 +92,7 @@ def HKDF_Extract(hash_cls, salt, in_key):
in_key = t2b(in_key)

out_len = hash_cls.digest_size
out = _ffi.new("byte[%d]" % out_len)
out = _ffi.new(f"byte[{out_len}]")

ret = _lib.wc_HKDF_Extract(hash_cls._type, salt, len(salt), in_key, len(in_key), out)
if ret != 0:
Expand Down Expand Up @@ -122,7 +122,7 @@ def HKDF_Expand(hash_cls, prk, info, out_len):
if out_len is None or out_len <= 0:
raise ValueError("out_len must be a positive integer")

out = _ffi.new("byte[%d]" % out_len)
out = _ffi.new(f"byte[{out_len}]")

ret = _lib.wc_HKDF_Expand(
hash_cls._type, prk, len(prk), info, len(info), out, out_len
Expand Down
2 changes: 1 addition & 1 deletion wolfcrypt/pwdbased.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def PBKDF2(password, salt, iterations, key_length, hash_type):
if isinstance(password, str):
password = str.encode(password)

key = _ffi.new("byte[%d]" %key_length)
key = _ffi.new(f"byte[{key_length}]")
ret = _lib.wc_PBKDF2(key, password, len(password), salt, len(salt),
iterations, key_length, hash_type)

Expand Down
2 changes: 1 addition & 1 deletion wolfcrypt/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def bytes(self, length: int) -> __builtins__.bytes:
"""
Generate and return a random sequence of length bytes.
"""
result = _ffi.new("byte[%d]" % length)
result = _ffi.new(f"byte[{length}]")

assert self.native_object is not None
ret = _lib.wc_RNG_GenerateBlock(self.native_object, result, length)
Expand Down
Loading