diff --git a/Makefile b/Makefile index 07e068a..4a6fd07 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,4 @@ test: . venv/bin/activate; cd ./src; python -m pytest lint: - . venv/bin/activate; \ - cd ./src - flake8 --ignore=E252,W504,W503 --max-line-length=120 . \ - && mypy --follow-imports=skip --ignore-missing-imports . + . venv/bin/activate; flake8 --ignore=E252,W504,W503 --max-line-length=120 ./src/ && mypy --follow-imports=skip --ignore-missing-imports ./src/ diff --git a/src/tests/__init__.py b/src/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/tests/test_key_derivation/test_mnemonic.py b/src/tests/test_key_derivation/test_mnemonic.py index a676357..c155124 100644 --- a/src/tests/test_key_derivation/test_mnemonic.py +++ b/src/tests/test_key_derivation/test_mnemonic.py @@ -8,6 +8,7 @@ from key_derivation.mnemonic import ( with open('tests/test_key_derivation/test_vectors/mnemonic.json', 'r') as f: test_vectors = load(f) + @pytest.mark.parametrize( 'language,language_test_vectors', [(a, b) for a, b in test_vectors.items()] diff --git a/src/utils/crypto.py b/src/utils/crypto.py index b5b2124..2f45ce2 100644 --- a/src/utils/crypto.py +++ b/src/utils/crypto.py @@ -25,8 +25,8 @@ def scrypt(*, password: str, salt: str, n: int, r: int, p: int, dklen: int) -> b def PBKDF2(*, password: str, salt: bytes, dklen: int, c: int, prf: str) -> bytes: assert('sha' in prf) _hash = _sha256 if 'sha256' in prf else _sha512 - password = password.encode("utf-8") - res = _PBKDF2(password=password, salt=salt, dkLen=dklen, count=c, hmac_hash_module=_hash) + password_bytes = password.encode("utf-8") + res = _PBKDF2(password=password_bytes, salt=salt, dkLen=dklen, count=c, hmac_hash_module=_hash) # type: ignore return res if isinstance(res, bytes) else res[0] # PyCryptodome can return Tuple[bytes]