4335740abe
In order to use this feature, GPG "modern" (v2.1) is required [1]. Also, since TREZOR protocol does not support arbitrary long fields, TREZOR firmware needs to be adapted with the following patch [2], to support signing fixed-size digests of GPG messages of arbitrary size. [1] https://gist.github.com/vt0r/a2f8c0bcb1400131ff51 [2] https://gist.github.com/romanz/b66f5df1ca8ef15641df8ea5bb09fd47
19 lines
419 B
Python
19 lines
419 B
Python
import struct
|
|
|
|
|
|
def crc24(blob):
|
|
CRC24_INIT = 0xB704CEL
|
|
CRC24_POLY = 0x1864CFBL
|
|
|
|
crc = CRC24_INIT
|
|
for octet in bytearray(blob):
|
|
crc ^= (octet << 16)
|
|
for _ in range(8):
|
|
crc <<= 1
|
|
if crc & 0x1000000:
|
|
crc ^= CRC24_POLY
|
|
assert 0 <= crc < 0x1000000
|
|
crc_bytes = struct.pack('>L', crc)
|
|
assert crc_bytes[0] == b'\x00'
|
|
return crc_bytes[1:]
|