Skip to content
Open
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
7 changes: 2 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,8 @@ indent-width = 4
target-version = "py310"

[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E4", "E7", "E9", "F", "B", "UP"]
ignore = ["UP031", "UP025", "UP032"]
select = ["E", "F", "B", "UP", "C4", "DTZ", "EXE", "FA", "INT", "ISC", "ICN", "LOG", "G", "RSE", "SLOT", "TID", "TC", "FLY", "PERF", "W", "FURB"]
ignore = ["E501"]

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
VERSIONFILE = "wolfcrypt/_version.py"
verstrline = open(VERSIONFILE).read()
VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
mo = re.search(VSRE, verstrline, re.M)
mo = re.search(VSRE, verstrline, re.MULTILINE)
if mo:
verstr = mo.group(1)
else:
raise RuntimeError(f"Unable to find version string in {VERSIONFILE}.")
VSRE = r"^__wolfssl_version__ = ['\"]([^'\"]*)['\"]"
mo = re.search(VSRE, verstrline, re.M)
mo = re.search(VSRE, verstrline, re.MULTILINE)
if mo:
wolfverstr = mo.group(1)
else:
Expand Down
22 changes: 11 additions & 11 deletions tests/test_hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,27 @@ def vectors():

if _lib.SHA256_ENABLED:
vectorArray[Sha256]=TestVector(
digest=t2b("96e02e7b1cbcd6f104fe1fdb4652027a" +
digest=t2b("96e02e7b1cbcd6f104fe1fdb4652027a"
"5505b68652b70095c6318f9dce0d1844")
)

if _lib.SHA384_ENABLED:
vectorArray[Sha384]=TestVector(
digest=t2b("4c79d80531203a16f91bee325f18c6aada47f9382fe44fc1" +
digest=t2b("4c79d80531203a16f91bee325f18c6aada47f9382fe44fc1"
"1f92917837e9b7902f5dccb7d3656f667a1dce3460bc884b")
)

if _lib.SHA512_ENABLED:
vectorArray[Sha512]=TestVector(
digest=t2b("88fcf67ffd8558d713f9cedcd852db47" +
"9e6573f0bd9955610a993f609637553c" +
"e8fff55e644ee8a106aae19c07f91b3f" +
digest=t2b("88fcf67ffd8558d713f9cedcd852db47"
"9e6573f0bd9955610a993f609637553c"
"e8fff55e644ee8a106aae19c07f91b3f"
"2a2a6d40dfa7302c0fa6a1a9a5bfa03f")
)
if _lib.SHA3_ENABLED:
vectorArray[Sha3]=TestVector(
digest=t2b("6170dedf06f83c3305ec18b7558384a5" +
"a62d86e42c143d416aaec32f971986c1" +
digest=t2b("6170dedf06f83c3305ec18b7558384a5"
"a62d86e42c143d416aaec32f971986c1"
"e84edf61df308cc6d8c310d1956e1908")
)
if _lib.HMAC_ENABLED:
Expand All @@ -96,18 +96,18 @@ def vectors():
)
if _lib.SHA256_ENABLED:
vectorArray[HmacSha256]=TestVector(
digest=t2b("9041ac8c66fc350a1a0d5f4fff9d8ef74721d5a43ec8893a2" +
digest=t2b("9041ac8c66fc350a1a0d5f4fff9d8ef74721d5a43ec8893a2"
"875cf69576c45c2")
)
if _lib.SHA384_ENABLED:
vectorArray[HmacSha384]=TestVector(
digest=t2b("f8c589ddf5489404f85c3c718a8345f207fb1ed6c6f5ecb09" +
digest=t2b("f8c589ddf5489404f85c3c718a8345f207fb1ed6c6f5ecb09"
"8e8be8aeb1aaa9f0c6dd84c141410b29a47a1a2b3a85ae0")
)
if _lib.SHA512_ENABLED:
vectorArray[HmacSha512]=TestVector(
digest=t2b("7708a12ca110cd81a334bd4e8bddc4314acd3ed218bbff7c6" +
"486e149fc145e9f5c05f05e919f7c2bc027266e986679984c" +
digest=t2b("7708a12ca110cd81a334bd4e8bddc4314acd3ed218bbff7c6"
"486e149fc145e9f5c05f05e919f7c2bc027266e986679984c"
"3ade1a14084ad7627a65c3671a2d05")
)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_mldsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_sign_verify(mldsa_type, rng):
# Verify with wrong message
wrong_message = b"This is a wrong message for ML-DSA signature"
assert not mldsa_pub.verify(signature, wrong_message)

# Verify a signature generated without a context but where a context
# is provided during verify
ctx = b"This is a test context for ML-DSA signature"
Expand Down
4 changes: 2 additions & 2 deletions wolfcrypt/ciphers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2279,7 +2279,7 @@ def verify(self, signature, message, ctx=None):
return res[0] == 1

class MlDsaPrivate(_MlDsaBase):

@classmethod
def make_key(cls, mldsa_type, rng=None):
"""
Expand Down Expand Up @@ -2451,7 +2451,7 @@ def sign(self, message, rng=None, ctx=None):
)
if ret < 0: # pragma: no cover
raise WolfCryptApiError("wc_dilithium_sign_msg() error", ret)

if in_size != out_size[0]:
raise WolfCryptError(f"{in_size=} and {out_size[0]=} don't match")

Expand Down
Loading