20 lines
725 B
Python
20 lines
725 B
Python
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
|
|
|
|
|
|
def test_sha256_file_and_ed25519_verification(tmp_path):
|
|
from dx_productivity.update.verification import sha256_file, verify_ed25519
|
|
|
|
payload = b"release payload"
|
|
path = tmp_path / "payload.bin"
|
|
path.write_bytes(payload)
|
|
private_key = Ed25519PrivateKey.generate()
|
|
signature = private_key.sign(payload)
|
|
|
|
assert sha256_file(path) == "d11a02dfb3d8dfdc9229678b67f948c32aabeb9e5d409434b171cd7e5275774f"
|
|
assert verify_ed25519(
|
|
private_key.public_key().public_bytes_raw(), payload, signature
|
|
)
|
|
assert not verify_ed25519(
|
|
private_key.public_key().public_bytes_raw(), b"changed", signature
|
|
)
|