mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-03-22 02:55:43 +00:00
fix(core): make custom noise implementation compatible with standard
This commit is contained in:
parent
6ddfff4376
commit
8594ff19c3
@ -98,6 +98,7 @@ class Handshake:
|
||||
trezor_ephemeral_pubkey = curve25519.publickey(self.trezor_ephemeral_privkey)
|
||||
self.h = _hash_of_two(PROTOCOL_NAME, device_properties)
|
||||
self.h = _hash_of_two(self.h, host_ephemeral_pubkey)
|
||||
self.h = _hash_of_two(self.h, b"")
|
||||
self.h = _hash_of_two(self.h, trezor_ephemeral_pubkey)
|
||||
point = curve25519.multiply(
|
||||
self.trezor_ephemeral_privkey, host_ephemeral_pubkey
|
||||
@ -156,6 +157,7 @@ class Handshake:
|
||||
)
|
||||
aes_ctx = aesgcm(self.k, IV_1)
|
||||
aes_ctx.auth(self.h)
|
||||
self.h = _hash_of_two(self.h, memoryview(encrypted_payload))
|
||||
aes_ctx.decrypt_in_place(memoryview(encrypted_payload)[:-16])
|
||||
if __debug__:
|
||||
log.debug(
|
||||
@ -165,7 +167,6 @@ class Handshake:
|
||||
if tag != encrypted_payload[-16:]:
|
||||
raise ThpDecryptionError()
|
||||
|
||||
self.h = _hash_of_two(self.h, memoryview(encrypted_payload)[:-16])
|
||||
self.key_receive, self.key_send = _hkdf(self.ck, b"")
|
||||
if __debug__:
|
||||
log.debug(
|
||||
|
Loading…
Reference in New Issue
Block a user