python: use stdlib blake2s on python 3.6+

commit 6d407c84d7 did not replace everything
pull/1180/head
Pavol Rusnak 4 years ago
parent 1e58c86a9a
commit 5536fbb98a

@ -1,6 +1,9 @@
#!/usr/bin/env python3
import glob
import pyblake2
try:
from hashlib import blake2s
except ImportError:
from pyblake2 import blake2s
ALIGNED_SIZE = 128 * 1024
@ -12,8 +15,8 @@ for fn in sorted(files):
raise ValueError(fn, "too big")
data_00 = data + b"\x00" * (ALIGNED_SIZE - len(data))
data_ff = data + b"\xff" * (ALIGNED_SIZE - len(data))
h_00 = pyblake2.blake2s(data=data_00).digest()
h_ff = pyblake2.blake2s(data=data_ff).digest()
h_00 = blake2s(data=data_00).digest()
h_ff = blake2s(data=data_ff).digest()
h_00 = "".join(["\\x%02x" % i for i in h_00])
h_ff = "".join(["\\x%02x" % i for i in h_ff])
print(" // %s (padded with 0x00)\n if (0 == memcmp(hash, \"%s\", 32)) return sectrue;" % (fn, h_00))

@ -4,10 +4,15 @@ from typing import Any, List, Optional
import click
import construct as c
import pyblake2
from trezorlib import cosi, firmware
try:
from hashlib import blake2s
except ImportError:
from pyblake2 import blake2s
SYM_OK = click.style("\u2714", fg="green")
SYM_FAIL = click.style("\u274c", fg="red")
@ -47,7 +52,7 @@ def compute_vhash(vendor_header):
m = vendor_header.sig_m
n = vendor_header.sig_n
pubkeys = vendor_header.pubkeys
h = pyblake2.blake2s()
h = blake2s()
h.update(struct.pack("<BB", m, n))
for i in range(8):
if i < n:

Loading…
Cancel
Save