Merge pull request #276 from ralexstokes/fix-secio-impl

Fix secio impl
This commit is contained in:
Alex Stokes 2019-09-03 23:01:45 +02:00 committed by GitHub
commit 506093216c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
from dataclasses import dataclass from dataclasses import dataclass
import itertools
from typing import Optional, Tuple from typing import Optional, Tuple
import multihash import multihash
@ -180,7 +181,7 @@ def _select_parameter_from_order(
else: else:
return supported_parameters.split(",")[0] return supported_parameters.split(",")[0]
for first, second in zip(first_choices, second_choices): for first, second in itertools.product(first_choices, second_choices):
if first == second: if first == second:
return first return first
raise IncompatibleChoices() raise IncompatibleChoices()
@ -245,7 +246,12 @@ async def _establish_session_parameters(
if not remote_peer: if not remote_peer:
remote_peer = remote_peer_from_proposal remote_peer = remote_peer_from_proposal
elif remote_peer != remote_peer_from_proposal: elif remote_peer != remote_peer_from_proposal:
raise PeerMismatchException() raise PeerMismatchException(
{
"expected_remote_peer": remote_peer,
"received_remote_peer": remote_peer_from_proposal,
}
)
session_parameters.remote_peer = remote_peer session_parameters.remote_peer = remote_peer
curve_param, cipher_param, hash_param, order = _select_encryption_parameters( curve_param, cipher_param, hash_param, order = _select_encryption_parameters(