# Path: newsreap/Utils.py
# SEEK_SET = 0
# 
# Path: newsreap/Logging.py
# NEWSREAP_ENGINE = '%s.engine' % NEWSREAP_LOGGER


from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPublicKey
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.exceptions import UnsupportedAlgorithm
from os.path import isfile
from base64 import b64encode
from base64 import b64decode
from StringIO import StringIO
from gzip import GzipFile
from newsreap.Utils import SEEK_SET
from newsreap.Logging import NEWSREAP_ENGINE
import logging
            fileobj.write(b64decode(encoded))
        except TypeError:
            return False

        fileobj.seek(0L, SEEK_SET)
        private_key = None
        with GzipFile(fileobj=fileobj, mode="rb") as f:
            private_key = f.read()

        if not private_key:
            return False

        # We were successful
        if not self.load(private_key=private_key):
            return False

        return True

    def decode_public_key(self, encoded):
        """
        Based on spotnab, this is the gzipped version of the key
        with base64 applied to it.  We decode it and load it.

        """
        fileobj = StringIO()
        try:
            fileobj.write(b64decode(encoded))
        except TypeError:
            return False


# Path: newsreap/Utils.py
# SEEK_SET = 0
# 
# Path: newsreap/Logging.py
# NEWSREAP_ENGINE = '%s.engine' % NEWSREAP_LOGGER


# Path: newsreap/NNTPCryptography.py
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPublicKey
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.exceptions import UnsupportedAlgorithm
from os.path import isfile
from base64 import b64encode
from base64 import b64decode
from StringIO import StringIO
from gzip import GzipFile
from newsreap.Utils import SEEK_SET
from newsreap.Logging import NEWSREAP_ENGINE
import logging

            fileobj.write(b64decode(encoded))
        except TypeError:
            return False

        fileobj.seek(0L, SEEK_SET)
        private_key = None
        with GzipFile(fileobj=fileobj, mode="rb") as f:
            private_key = f.read()

        if not private_key:
            return False

        # We were successful
        if not self.load(private_key=private_key):
            return False

        return True

    def decode_public_key(self, encoded):
        """
        Based on spotnab, this is the gzipped version of the key
        with base64 applied to it.  We decode it and load it.

        """
        fileobj = StringIO()
        try:
            fileobj.write(b64decode(encoded))
        except TypeError:
            return False


        fileobj.seek(0L, SEEK_SET)