From db049c6638b46e18c9ce7f05938dcff72cd065c7 Mon Sep 17 00:00:00 2001 From: Jason Robinson Date: Tue, 31 Jul 2018 23:55:37 +0300 Subject: [PATCH] Fix RSA object usage in type hints It seems little-boxes replaced our crypto library which caused a bit of a mayhem since some of the internal objects don't match. If we need that library after all, will need to drop these type hints. --- federation/outbound.py | 6 +++--- federation/protocols/diaspora/protocol.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/federation/outbound.py b/federation/outbound.py index 3422d96..86a6419 100644 --- a/federation/outbound.py +++ b/federation/outbound.py @@ -2,7 +2,7 @@ import json import logging from typing import List, Tuple, Union -from Crypto.PublicKey.RSA import RsaKey +from Crypto.PublicKey.RSA import _RSAobj from federation.entities.diaspora.mappers import get_outbound_entity from federation.entities.mixins import BaseEntity @@ -15,7 +15,7 @@ logger = logging.getLogger("federation") def handle_create_payload( - entity:BaseEntity, author_user:UserType, to_user_key:RsaKey=None, parent_user:UserType=None) -> str: + entity:BaseEntity, author_user:UserType, to_user_key:_RSAobj=None, parent_user:UserType=None) -> str: """Create a payload with the correct protocol. Any given user arguments must have ``private_key`` and ``handle`` attributes. @@ -41,7 +41,7 @@ def handle_create_payload( def handle_send( entity: BaseEntity, author_user: UserType, - recipients: List[Union[Tuple[str, RsaKey], str]]=None, + recipients: List[Union[Tuple[str, _RSAobj], str]]=None, parent_user: UserType=None, ) -> None: """Send an entity to remote servers. diff --git a/federation/protocols/diaspora/protocol.py b/federation/protocols/diaspora/protocol.py index d96dadf..8e77b61 100644 --- a/federation/protocols/diaspora/protocol.py +++ b/federation/protocols/diaspora/protocol.py @@ -4,7 +4,7 @@ from base64 import urlsafe_b64decode from typing import Callable, Tuple, Union, Dict from urllib.parse import unquote -from Crypto.PublicKey.RSA import RsaKey +from Crypto.PublicKey.RSA import _RSAobj from lxml import etree from federation.entities.mixins import BaseEntity @@ -122,7 +122,7 @@ class Protocol: raise NoSenderKeyFoundError("Could not find a sender contact to retrieve key") MagicEnvelope(doc=self.doc, public_key=sender_key, verify=True) - def build_send(self, entity:BaseEntity, from_user:UserType, to_user_key:RsaKey=None) -> Union[str, Dict]: + def build_send(self, entity:BaseEntity, from_user:UserType, to_user_key:_RSAobj=None) -> Union[str, Dict]: """ Build POST data for sending out to remotes.