Add clearer indication of "self encryption"

This commit is contained in:
Alex Stokes 2019-08-23 23:02:53 +02:00
parent 8e913a3faa
commit 0fa3331b8c
No known key found for this signature in database
GPG Key ID: 51CE1721B245C086
2 changed files with 12 additions and 3 deletions

View File

@ -2,6 +2,15 @@ class SecioException(Exception):
pass
class SelfEncryption(SecioException):
"""
Raised to indicate that a host is attempting to encrypt communications
with itself.
"""
pass
class PeerMismatchException(SecioException):
pass

View File

@ -28,6 +28,7 @@ from .exceptions import (
InvalidSignatureOnExchange,
PeerMismatchException,
SecioException,
SelfEncryption,
)
from .pb.spipe_pb2 import Exchange, Propose
@ -195,9 +196,8 @@ def _select_encryption_parameters(
elif second_score < first_score:
order = 1
# NOTE: if order is 0, "talking to self"
# TODO(ralexstokes) nicer error handling here...
assert order != 0
if order == 0:
raise SelfEncryption()
return (
_select_parameter_from_order(