Skip to content

back to SWE-Agent summary

SWE-Agent: python-rsa

Pytest Summary for test tests

status count
error 14
failed 71
passed 2
total 87
collected 87

Failed pytests:

test_cli.py::KeygenTest::test_keygen_no_args

test_cli.py::KeygenTest::test_keygen_no_args
cls = 

    @classmethod
    def setUpClass(cls):
        # Ensure there is a key to use
>       cls.pub_key, cls.priv_key = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_cli.py:85: TypeError

test_cli.py::KeygenTest::test_keygen_priv_out_der

test_cli.py::KeygenTest::test_keygen_priv_out_der
cls = 

    @classmethod
    def setUpClass(cls):
        # Ensure there is a key to use
>       cls.pub_key, cls.priv_key = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_cli.py:85: TypeError

test_cli.py::KeygenTest::test_keygen_priv_out_pem

test_cli.py::KeygenTest::test_keygen_priv_out_pem
cls = 

    @classmethod
    def setUpClass(cls):
        # Ensure there is a key to use
>       cls.pub_key, cls.priv_key = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_cli.py:85: TypeError

test_cli.py::KeygenTest::test_keygen_priv_stdout

test_cli.py::KeygenTest::test_keygen_priv_stdout
cls = 

    @classmethod
    def setUpClass(cls):
        # Ensure there is a key to use
>       cls.pub_key, cls.priv_key = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_cli.py:85: TypeError

test_cli.py::KeygenTest::test_keygen_pub_out_pem

test_cli.py::KeygenTest::test_keygen_pub_out_pem
cls = 

    @classmethod
    def setUpClass(cls):
        # Ensure there is a key to use
>       cls.pub_key, cls.priv_key = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_cli.py:85: TypeError

test_cli.py::EncryptDecryptTest::test_empty_decrypt

test_cli.py::EncryptDecryptTest::test_empty_decrypt
cls = 

    @classmethod
    def setUpClass(cls):
        # Ensure there is a key to use
>       cls.pub_key, cls.priv_key = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_cli.py:85: TypeError

test_cli.py::EncryptDecryptTest::test_empty_encrypt

test_cli.py::EncryptDecryptTest::test_empty_encrypt
cls = 

    @classmethod
    def setUpClass(cls):
        # Ensure there is a key to use
>       cls.pub_key, cls.priv_key = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_cli.py:85: TypeError

test_cli.py::EncryptDecryptTest::test_encrypt_decrypt

test_cli.py::EncryptDecryptTest::test_encrypt_decrypt
cls = 

    @classmethod
    def setUpClass(cls):
        # Ensure there is a key to use
>       cls.pub_key, cls.priv_key = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_cli.py:85: TypeError

test_cli.py::EncryptDecryptTest::test_encrypt_decrypt_unhappy

test_cli.py::EncryptDecryptTest::test_encrypt_decrypt_unhappy
cls = 

    @classmethod
    def setUpClass(cls):
        # Ensure there is a key to use
>       cls.pub_key, cls.priv_key = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_cli.py:85: TypeError

test_cli.py::SignVerifyTest::test_empty_sign

test_cli.py::SignVerifyTest::test_empty_sign
cls = 

    @classmethod
    def setUpClass(cls):
        # Ensure there is a key to use
>       cls.pub_key, cls.priv_key = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_cli.py:85: TypeError

test_cli.py::SignVerifyTest::test_empty_verify

test_cli.py::SignVerifyTest::test_empty_verify
cls = 

    @classmethod
    def setUpClass(cls):
        # Ensure there is a key to use
>       cls.pub_key, cls.priv_key = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_cli.py:85: TypeError

test_cli.py::SignVerifyTest::test_sign_verify

test_cli.py::SignVerifyTest::test_sign_verify
cls = 

    @classmethod
    def setUpClass(cls):
        # Ensure there is a key to use
>       cls.pub_key, cls.priv_key = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_cli.py:85: TypeError

test_cli.py::SignVerifyTest::test_sign_verify_unhappy

test_cli.py::SignVerifyTest::test_sign_verify_unhappy
cls = 

    @classmethod
    def setUpClass(cls):
        # Ensure there is a key to use
>       cls.pub_key, cls.priv_key = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_cli.py:85: TypeError

test_cli.py::PrivatePublicTest::test_private_to_public

test_cli.py::PrivatePublicTest::test_private_to_public
cls = 

    @classmethod
    def setUpClass(cls):
        # Ensure there is a key to use
>       cls.pub_key, cls.priv_key = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_cli.py:85: TypeError

test_common.py::TestByteSize::test_bad_type

test_common.py::TestByteSize::test_bad_type
self = 

    def test_bad_type(self):
>       self.assertRaises(TypeError, byte_size, [])
E       AssertionError: TypeError not raised by byte_size

tests/test_common.py:40: AssertionError

test_common.py::TestByteSize::test_values

test_common.py::TestByteSize::test_values
self = 

    def test_values(self):
>       self.assertEqual(byte_size(1 << 1023), 128)
E       AssertionError: None != 128

tests/test_common.py:23: AssertionError

test_common.py::TestByteSize::test_zero

test_common.py::TestByteSize::test_zero
self = 

    def test_zero(self):
>       self.assertEqual(byte_size(0), 1)
E       AssertionError: None != 1

tests/test_common.py:37: AssertionError

test_common.py::TestBitSize::test_bad_type

test_common.py::TestBitSize::test_bad_type
self = 

    def test_bad_type(self):
>       self.assertRaises(TypeError, bit_size, [])
E       AssertionError: TypeError not raised by bit_size

tests/test_common.py:68: AssertionError

test_common.py::TestBitSize::test_negative_values

test_common.py::TestBitSize::test_negative_values
self = 

    def test_negative_values(self):
>       self.assertEqual(bit_size(-1023), 10)
E       AssertionError: None != 10

tests/test_common.py:60: AssertionError

test_common.py::TestBitSize::test_values

test_common.py::TestBitSize::test_values
self = 

    def test_values(self):
>       self.assertEqual(bit_size(1023), 10)
E       AssertionError: None != 10

tests/test_common.py:52: AssertionError

test_common.py::TestBitSize::test_zero

test_common.py::TestBitSize::test_zero
self = 

    def test_zero(self):
>       self.assertEqual(bit_size(0), 0)
E       AssertionError: None != 0

tests/test_common.py:49: AssertionError

test_common.py::TestInverse::test_normal

test_common.py::TestInverse::test_normal
self = 

    def test_normal(self):
>       self.assertEqual(3, inverse(7, 4))
E       AssertionError: 3 != None

tests/test_common.py:78: AssertionError

test_common.py::TestInverse::test_not_relprime

test_common.py::TestInverse::test_not_relprime
self = 

    def test_not_relprime(self):
>       self.assertRaises(ValueError, inverse, 4, 8)
E       AssertionError: ValueError not raised by inverse

tests/test_common.py:82: AssertionError

test_integers.py::IntegerTest::test_enc_dec

test_integers.py::IntegerTest::test_enc_dec
self = 

    def setUp(self):
>       (self.pub, self.priv) = rsa.newkeys(64)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_integers.py:25: TypeError

test_integers.py::IntegerTest::test_sign_verify

test_integers.py::IntegerTest::test_sign_verify
self = 

    def setUp(self):
>       (self.pub, self.priv) = rsa.newkeys(64)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_integers.py:25: TypeError

test_key.py::BlindingTest::test_blinding

test_key.py::BlindingTest::test_blinding
self = 

    def test_blinding(self):
        """Test blinding and unblinding.

        This is basically the doctest of the PrivateKey.blind method, but then
        implemented as unittest to allow running on different Python versions.
        """

        pk = rsa.key.PrivateKey(3727264081, 65537, 3349121513, 65063, 57287)

        message = 12345
        encrypted = rsa.core.encrypt_int(message, pk.e, pk.n)

>       blinded_1, unblind_1 = pk.blind(encrypted)  # blind before decrypting
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_key.py:24: TypeError

test_key.py::KeyGenTest::test_custom_exponent

test_key.py::KeyGenTest::test_custom_exponent
self = 

    def test_custom_exponent(self):
>       pub, priv = rsa.key.newkeys(16, exponent=3)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_key.py:42: TypeError

test_key.py::KeyGenTest::test_custom_getprime_func

test_key.py::KeyGenTest::test_custom_getprime_func
self = 

    def test_custom_getprime_func(self):
        # List of primes to test with, in order [p, q, p, q, ....]
        # By starting with two of the same primes, we test that this is
        # properly rejected.
        primes = [64123, 64123, 64123, 50957, 39317, 33107]

        def getprime(_):
            return primes.pop(0)

        # This exponent will cause two other primes to be generated.
        exponent = 136407

>       (p, q, e, d) = rsa.key.gen_keys(
            64, accurate=False, getprime_func=getprime, exponent=exponent
        )
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_key.py:72: TypeError

test_key.py::KeyGenTest::test_default_exponent

test_key.py::KeyGenTest::test_default_exponent
self = 

    def test_default_exponent(self):
>       pub, priv = rsa.key.newkeys(16)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_key.py:48: TypeError

test_key.py::KeyGenTest::test_exponents_coefficient_calculation

test_key.py::KeyGenTest::test_exponents_coefficient_calculation
self = 

    def test_exponents_coefficient_calculation(self):
        pk = rsa.key.PrivateKey(3727264081, 65537, 3349121513, 65063, 57287)

        self.assertEqual(pk.exp1, 55063)
        self.assertEqual(pk.exp2, 10095)
>       self.assertEqual(pk.coef, 50797)
E       AssertionError: None != 50797

tests/test_key.py:58: AssertionError

test_key.py::HashTest::test_hash_possible

test_key.py::HashTest::test_hash_possible
self = 

    def test_hash_possible(self):
>       pub, priv = rsa.key.newkeys(16)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_key.py:83: TypeError

test_load_save_keys.py::DerTest::test_load_malformed_private_key

test_load_save_keys.py::DerTest::test_load_malformed_private_key
self = 
der_decode = 

    @mock.patch("pyasn1.codec.der.decoder.decode")
    def test_load_malformed_private_key(self, der_decode):
        """Test loading malformed private DER keys."""

        # Decode returns an invalid exp2 value.
        der_decode.return_value = (
            [0, 3727264081, 65537, 3349121513, 65063, 57287, 55063, 0, 50797],
            0,
        )

        with warnings.catch_warnings(record=True) as w:
            # Always print warnings
            warnings.simplefilter("always")

            # Load 3 keys
            for _ in range(3):
                key = rsa.key.PrivateKey.load_pkcs1(PRIVATE_DER, "DER")

            # Check that 3 warnings were generated.
>           self.assertEqual(3, len(w))
E           AssertionError: 3 != 0

tests/test_load_save_keys.py:122: AssertionError

test_load_save_keys.py::DerTest::test_load_private_key

test_load_save_keys.py::DerTest::test_load_private_key
self = 

    def test_load_private_key(self):
        """Test loading private DER keys."""

        key = rsa.key.PrivateKey.load_pkcs1(PRIVATE_DER, "DER")
        expected = rsa.key.PrivateKey(3727264081, 65537, 3349121513, 65063, 57287)

>       self.assertEqual(expected, key)
E       AssertionError: PrivateKey(3727264081, 65537, 3349121513, 65063, 57287) != None

tests/test_load_save_keys.py:98: AssertionError

test_load_save_keys.py::DerTest::test_load_public_key

test_load_save_keys.py::DerTest::test_load_public_key
self = 

    def test_load_public_key(self):
        """Test loading public DER keys."""

        key = rsa.key.PublicKey.load_pkcs1(PUBLIC_DER, "DER")
        expected = rsa.key.PublicKey(3727264081, 65537)

>       self.assertEqual(expected, key)
E       AssertionError: PublicKey(3727264081, 65537) != None

tests/test_load_save_keys.py:148: AssertionError

test_load_save_keys.py::DerTest::test_save_private_key

test_load_save_keys.py::DerTest::test_save_private_key
self = 

    def test_save_private_key(self):
        """Test saving private DER keys."""

        key = rsa.key.PrivateKey(3727264081, 65537, 3349121513, 65063, 57287)
        der = key.save_pkcs1("DER")

>       self.assertIsInstance(der, bytes)
E       AssertionError: None is not an instance of 

tests/test_load_save_keys.py:139: AssertionError

test_load_save_keys.py::DerTest::test_save_public_key

test_load_save_keys.py::DerTest::test_save_public_key
self = 

    def test_save_public_key(self):
        """Test saving public DER keys."""

        key = rsa.key.PublicKey(3727264081, 65537)
        der = key.save_pkcs1("DER")

>       self.assertIsInstance(der, bytes)
E       AssertionError: None is not an instance of 

tests/test_load_save_keys.py:156: AssertionError

test_load_save_keys.py::PemTest::test_load_from_disk

test_load_save_keys.py::PemTest::test_load_from_disk
self = 

    def test_load_from_disk(self):
        """Test loading a PEM file from disk."""

        fname = os.path.join(os.path.dirname(__file__), "private.pem")
        with open(fname, mode="rb") as privatefile:
            keydata = privatefile.read()
        privkey = rsa.key.PrivateKey.load_pkcs1(keydata)

>       self.assertEqual(15945948582725241569, privkey.p)
E       AttributeError: 'NoneType' object has no attribute 'p'

tests/test_load_save_keys.py:208: AttributeError

test_load_save_keys.py::PemTest::test_load_private_key

test_load_save_keys.py::PemTest::test_load_private_key
self = 

    def test_load_private_key(self):
        """Test loading private PEM files."""

        key = rsa.key.PrivateKey.load_pkcs1(PRIVATE_PEM, "PEM")
        expected = rsa.key.PrivateKey(3727264081, 65537, 3349121513, 65063, 57287)

>       self.assertEqual(expected, key)
E       AssertionError: PrivateKey(3727264081, 65537, 3349121513, 65063, 57287) != None

tests/test_load_save_keys.py:169: AssertionError

test_load_save_keys.py::PemTest::test_load_public_key

test_load_save_keys.py::PemTest::test_load_public_key
self = 

    def test_load_public_key(self):
        """Test loading public PEM files."""

        key = rsa.key.PublicKey.load_pkcs1(PUBLIC_PEM, "PEM")
        expected = rsa.key.PublicKey(3727264081, 65537)

>       self.assertEqual(expected, key)
E       AssertionError: PublicKey(3727264081, 65537) != None

tests/test_load_save_keys.py:189: AssertionError

test_load_save_keys.py::PemTest::test_save_private_key

test_load_save_keys.py::PemTest::test_save_private_key
self = 

    def test_save_private_key(self):
        """Test saving private PEM files."""

        key = rsa.key.PrivateKey(3727264081, 65537, 3349121513, 65063, 57287)
        pem = key.save_pkcs1("PEM")

>       self.assertIsInstance(pem, bytes)
E       AssertionError: None is not an instance of 

tests/test_load_save_keys.py:180: AssertionError

test_load_save_keys.py::PemTest::test_save_public_key

test_load_save_keys.py::PemTest::test_save_public_key
self = 

    def test_save_public_key(self):
        """Test saving public PEM files."""

        key = rsa.key.PublicKey(3727264081, 65537)
        pem = key.save_pkcs1("PEM")

>       self.assertIsInstance(pem, bytes)
E       AssertionError: None is not an instance of 

tests/test_load_save_keys.py:197: AssertionError

test_mypy.py::MypyRunnerTest::test_run_mypy

test_mypy.py::MypyRunnerTest::test_run_mypy
self = 

    def test_run_mypy(self):
        proj_root = pathlib.Path(__file__).parent.parent
        args = [
            "--incremental",
            "--ignore-missing-imports",
            f"--python-version={sys.version_info.major}.{sys.version_info.minor}",
        ] + [str(proj_root / dirname) for dirname in test_modules]

        result = mypy.api.run(args)

        stdout, stderr, status = result

        messages = []
        if stderr:
            messages.append(stderr)
        if stdout:
            messages.append(stdout)
        if status:
            messages.append("Mypy failed with status %d" % status)
        if messages and not all("Success" in message for message in messages):
>           self.fail("\n".join(["Mypy errors:"] + messages))
E           AssertionError: Mypy errors:
E           setup.cfg: [mypy]: python_version: Python 3.7 is not supported (must be 3.8 or higher)
E           
E           rsa/core.py:7: error: Missing return statement  [empty-body]
E           rsa/core.py:11: error: Missing return statement  [empty-body]
E           rsa/pem.py:6: error: Missing return statement  [empty-body]
E           rsa/pem.py:12: error: Missing return statement  [empty-body]
E           rsa/pem.py:16: error: Missing return statement  [empty-body]
E           rsa/pem.py:32: error: Missing return statement  [empty-body]
E           rsa/transform.py:7: error: Missing return statement  [empty-body]
E           rsa/transform.py:20: error: Missing return statement  [empty-body]
E           rsa/common.py:12: error: Missing return statement  [empty-body]
E           rsa/common.py:35: error: Missing return statement  [empty-body]
E           rsa/common.py:57: error: Missing return statement  [empty-body]
E           rsa/common.py:77: error: Missing return statement  [empty-body]
E           rsa/common.py:81: error: Missing return statement  [empty-body]
E           rsa/common.py:91: error: Missing return statement  [empty-body]
E           rsa/randnum.py:6: error: Missing return statement  [empty-body]
E           rsa/randnum.py:14: error: Missing return statement  [empty-body]
E           rsa/randnum.py:18: error: Missing return statement  [empty-body]
E           rsa/randnum.py:26: error: Missing return statement  [empty-body]
E           rsa/prime.py:10: error: Missing return statement  [empty-body]
E           rsa/prime.py:18: error: Missing return statement  [empty-body]
E           rsa/prime.py:32: error: Missing return statement  [empty-body]
E           rsa/prime.py:49: error: Missing return statement  [empty-body]
E           rsa/prime.py:61: error: Missing return statement  [empty-body]
E           rsa/prime.py:78: error: Missing return statement  [empty-body]
E           rsa/key.py:41: error: Missing return statement  [empty-body]
E           rsa/key.py:54: error: Missing return statement  [empty-body]
E           rsa/key.py:66: error: Missing return statement  [empty-body]
E           rsa/key.py:74: error: Missing return statement  [empty-body]
E           rsa/key.py:83: error: Missing return statement  [empty-body]
E           rsa/key.py:98: error: Missing return statement  [empty-body]
E           rsa/key.py:102: error: Missing return statement  [empty-body]
E           rsa/key.py:112: error: Missing return statement  [empty-body]
E           rsa/key.py:125: error: Missing return statement  [empty-body]
E           rsa/key.py:138: error: Missing return statement  [empty-body]
E           rsa/key.py:205: error: Missing return statement  [empty-body]
E           rsa/key.py:226: error: Missing return statement  [empty-body]
E           rsa/key.py:235: error: Missing return statement  [empty-body]
E           rsa/key.py:247: error: Missing return statement  [empty-body]
E           rsa/key.py:256: error: Missing return statement  [empty-body]
E           rsa/key.py:273: error: Missing return statement  [empty-body]
E           rsa/key.py:344: error: Missing return statement  [empty-body]
E           rsa/key.py:355: error: Missing return statement  [empty-body]
E           rsa/key.py:367: error: Missing return statement  [empty-body]
E           rsa/key.py:389: error: Missing return statement  [empty-body]
E           rsa/key.py:398: error: Missing return statement  [empty-body]
E           rsa/key.py:411: error: Missing return statement  [empty-body]
E           rsa/key.py:419: error: Missing return statement  [empty-body]
E           rsa/key.py:451: error: Missing return statement  [empty-body]
E           rsa/key.py:465: error: Missing return statement  [empty-body]
E           rsa/key.py:476: error: Missing return statement  [empty-body]
E           rsa/key.py:492: error: Missing return statement  [empty-body]
E           rsa/pkcs1.py:40: error: Missing return statement  [empty-body]
E           rsa/pkcs1.py:56: error: Missing return statement  [empty-body]
E           rsa/pkcs1.py:76: error: Missing return statement  [empty-body]
E           rsa/pkcs1.py:99: error: Missing return statement  [empty-body]
E           rsa/pkcs1.py:151: error: Missing return statement  [empty-body]
E           rsa/pkcs1.py:168: error: Missing return statement  [empty-body]
E           rsa/pkcs1.py:187: error: Missing return statement  [empty-body]
E           rsa/pkcs1.py:203: error: Missing return statement  [empty-body]
E           rsa/pkcs1.py:215: error: Missing return statement  [empty-body]
E           rsa/pkcs1.py:224: error: Missing return statement  [empty-body]
E           rsa/pkcs1.py:236: error: Missing return statement  [empty-body]
E           rsa/pkcs1_v2.py:8: error: Missing return statement  [empty-body]
E           rsa/parallel.py:15: error: Missing return statement  [empty-body]
E           rsa/cli.py:58: error: Missing return statement  [empty-body]
E           rsa/cli.py:58: note: If the method is meant to be abstract, use @abc.abstractmethod
E           rsa/cli.py:65: error: Missing return statement  [empty-body]
E           rsa/cli.py:65: note: If the method is meant to be abstract, use @abc.abstractmethod
E           rsa/cli.py:69: error: Missing return statement  [empty-body]
E           rsa/cli.py:69: note: If the method is meant to be abstract, use @abc.abstractmethod
E           rsa/cli.py:85: error: Missing return statement  [empty-body]
E           rsa/cli.py:85: note: If the method is meant to be abstract, use @abc.abstractmethod
E           rsa/cli.py:96: error: Incompatible types in assignment (expression has type "type[PrivateKey]", base class "CryptoOperation" defined the type as "type[PublicKey]")  [assignment]
E           rsa/cli.py:98: error: Missing return statement  [empty-body]
E           rsa/cli.py:98: note: If the method is meant to be abstract, use @abc.abstractmethod
E           rsa/cli.py:110: error: Incompatible types in assignment (expression has type "type[PrivateKey]", base class "CryptoOperation" defined the type as "type[PublicKey]")  [assignment]
E           rsa/cli.py:114: error: Missing return statement  [empty-body]
E           rsa/cli.py:114: note: If the method is meant to be abstract, use @abc.abstractmethod
E           Found 72 errors in 11 files (checked 28 source files)
E           
E           Mypy failed with status 1

tests/test_mypy.py:31: AssertionError

test_parallel.py::ParallelTest::test_parallel_primegen

test_parallel.py::ParallelTest::test_parallel_primegen
self = 

    def test_parallel_primegen(self):
        p = rsa.parallel.getprime(1024, 3)

>       self.assertFalse(rsa.prime.is_prime(p - 1))
E       TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'

tests/test_parallel.py:16: TypeError

test_pem.py::TestMarkers::test_values

test_pem.py::TestMarkers::test_values
self = 

    def test_values(self):
>       self.assertEqual(
            _markers("RSA PRIVATE KEY"),
            (b"-----BEGIN RSA PRIVATE KEY-----", b"-----END RSA PRIVATE KEY-----"),
        )
E       AssertionError: None != (b'-----BEGIN RSA PRIVATE KEY-----', b'-----END RSA PRIVATE KEY-----')

tests/test_pem.py:48: AssertionError

test_pem.py::TestBytesAndStrings::test_bytes_private

test_pem.py::TestBytesAndStrings::test_bytes_private
self = 

    def test_bytes_private(self):
        key = rsa.key.PrivateKey.load_pkcs1(private_key_pem.encode("ascii"))
>       self.assertEqual(prime1, key.p)
E       AttributeError: 'NoneType' object has no attribute 'p'

tests/test_pem.py:71: AttributeError

test_pem.py::TestBytesAndStrings::test_bytes_public

test_pem.py::TestBytesAndStrings::test_bytes_public
self = 

    def test_bytes_public(self):
        key = rsa.key.PublicKey.load_pkcs1_openssl_pem(public_key_pem.encode("ascii"))
>       self.assertEqual(prime1 * prime2, key.n)
E       AttributeError: 'NoneType' object has no attribute 'n'

tests/test_pem.py:63: AttributeError

test_pem.py::TestBytesAndStrings::test_unicode_private

test_pem.py::TestBytesAndStrings::test_unicode_private
self = 

    def test_unicode_private(self):
        key = rsa.key.PrivateKey.load_pkcs1(private_key_pem)
>       self.assertEqual(prime1 * prime2, key.n)
E       AttributeError: 'NoneType' object has no attribute 'n'

tests/test_pem.py:67: AttributeError

test_pem.py::TestBytesAndStrings::test_unicode_public

test_pem.py::TestBytesAndStrings::test_unicode_public
self = 

    def test_unicode_public(self):
        key = rsa.key.PublicKey.load_pkcs1_openssl_pem(public_key_pem)
>       self.assertEqual(prime1 * prime2, key.n)
E       AttributeError: 'NoneType' object has no attribute 'n'

tests/test_pem.py:59: AttributeError

test_pem.py::TestByteOutput::test_bytes_private

test_pem.py::TestByteOutput::test_bytes_private
self = 

    def test_bytes_private(self):
        key = rsa.key.PrivateKey.load_pkcs1(private_key_pem)
>       self.assertIsInstance(key.save_pkcs1(format="DER"), bytes)
E       AttributeError: 'NoneType' object has no attribute 'save_pkcs1'

tests/test_pem.py:85: AttributeError

test_pem.py::TestByteOutput::test_bytes_public

test_pem.py::TestByteOutput::test_bytes_public
self = 

    def test_bytes_public(self):
        key = rsa.key.PublicKey.load_pkcs1_openssl_pem(public_key_pem)
>       self.assertIsInstance(key.save_pkcs1(format="DER"), bytes)
E       AttributeError: 'NoneType' object has no attribute 'save_pkcs1'

tests/test_pem.py:80: AttributeError

test_pem.py::TestByteInput::test_bytes_private

test_pem.py::TestByteInput::test_bytes_private
self = 

    def test_bytes_private(self):
        key = rsa.key.PrivateKey.load_pkcs1(private_key_pem.encode("ascii"))
>       self.assertIsInstance(key.save_pkcs1(format="DER"), bytes)
E       AttributeError: 'NoneType' object has no attribute 'save_pkcs1'

tests/test_pem.py:99: AttributeError

test_pem.py::TestByteInput::test_bytes_public

test_pem.py::TestByteInput::test_bytes_public
self = 

    def test_bytes_public(self):
        key = rsa.key.PublicKey.load_pkcs1_openssl_pem(public_key_pem.encode("ascii"))
>       self.assertIsInstance(key.save_pkcs1(format="DER"), bytes)
E       AttributeError: 'NoneType' object has no attribute 'save_pkcs1'

tests/test_pem.py:94: AttributeError

test_pkcs1.py::BinaryTest::test_decoding_failure

test_pkcs1.py::BinaryTest::test_decoding_failure
self = 

    def setUp(self):
>       (self.pub, self.priv) = rsa.newkeys(256)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_pkcs1.py:27: TypeError

test_pkcs1.py::BinaryTest::test_enc_dec

test_pkcs1.py::BinaryTest::test_enc_dec
self = 

    def setUp(self):
>       (self.pub, self.priv) = rsa.newkeys(256)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_pkcs1.py:27: TypeError

test_pkcs1.py::BinaryTest::test_randomness

test_pkcs1.py::BinaryTest::test_randomness
self = 

    def setUp(self):
>       (self.pub, self.priv) = rsa.newkeys(256)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_pkcs1.py:27: TypeError

test_pkcs1.py::ExtraZeroesTest::test_append_zeroes

test_pkcs1.py::ExtraZeroesTest::test_append_zeroes
self = 

    def test_append_zeroes(self):
        cyphertext = self.cyphertext + bytes.fromhex("0000")
>       with self.assertRaises(rsa.DecryptionError):
E       AssertionError: DecryptionError not raised

tests/test_pkcs1.py:89: AssertionError

test_pkcs1.py::ExtraZeroesTest::test_prepend_zeroes

test_pkcs1.py::ExtraZeroesTest::test_prepend_zeroes
self = 

    def test_prepend_zeroes(self):
        cyphertext = bytes.fromhex("0000") + self.cyphertext
>       with self.assertRaises(rsa.DecryptionError):
E       AssertionError: DecryptionError not raised

tests/test_pkcs1.py:84: AssertionError

test_pkcs1.py::ExtraZeroesTest::test_unmodified

test_pkcs1.py::ExtraZeroesTest::test_unmodified
self = 

    def test_unmodified(self):
        message = rsa.decrypt(self.cyphertext, self.private_key)
>       self.assertEqual(message, self.plaintext)
E       AssertionError: None != b'Test'

tests/test_pkcs1.py:80: AssertionError

test_pkcs1.py::SignatureTest::test_alter_message

test_pkcs1.py::SignatureTest::test_alter_message
self = 

    def setUp(self):
>       (self.pub, self.priv) = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_pkcs1.py:95: TypeError

test_pkcs1.py::SignatureTest::test_apppend_zeroes

test_pkcs1.py::SignatureTest::test_apppend_zeroes
self = 

    def setUp(self):
>       (self.pub, self.priv) = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_pkcs1.py:95: TypeError

test_pkcs1.py::SignatureTest::test_find_signature_hash

test_pkcs1.py::SignatureTest::test_find_signature_hash
self = 

    def setUp(self):
>       (self.pub, self.priv) = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_pkcs1.py:95: TypeError

test_pkcs1.py::SignatureTest::test_hash_sign_verify

test_pkcs1.py::SignatureTest::test_hash_sign_verify
self = 

    def setUp(self):
>       (self.pub, self.priv) = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_pkcs1.py:95: TypeError

test_pkcs1.py::SignatureTest::test_multiple_signings

test_pkcs1.py::SignatureTest::test_multiple_signings
self = 

    def setUp(self):
>       (self.pub, self.priv) = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_pkcs1.py:95: TypeError

test_pkcs1.py::SignatureTest::test_prepend_zeroes

test_pkcs1.py::SignatureTest::test_prepend_zeroes
self = 

    def setUp(self):
>       (self.pub, self.priv) = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_pkcs1.py:95: TypeError

test_pkcs1.py::SignatureTest::test_sign_different_key

test_pkcs1.py::SignatureTest::test_sign_different_key
self = 

    def setUp(self):
>       (self.pub, self.priv) = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_pkcs1.py:95: TypeError

test_pkcs1.py::SignatureTest::test_sign_verify

test_pkcs1.py::SignatureTest::test_sign_verify
self = 

    def setUp(self):
>       (self.pub, self.priv) = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_pkcs1.py:95: TypeError

test_pkcs1.py::SignatureTest::test_sign_verify_sha3

test_pkcs1.py::SignatureTest::test_sign_verify_sha3
self = 

    def setUp(self):
>       (self.pub, self.priv) = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_pkcs1.py:95: TypeError

test_pkcs1.py::SignatureTest::test_split_hash_sign

test_pkcs1.py::SignatureTest::test_split_hash_sign
self = 

    def setUp(self):
>       (self.pub, self.priv) = rsa.newkeys(512)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_pkcs1.py:95: TypeError

test_pkcs1.py::PaddingSizeTest::test_too_little_padding

test_pkcs1.py::PaddingSizeTest::test_too_little_padding
self = 

        def test_too_little_padding(self):
            """Padding less than 8 bytes should be rejected."""

            # Construct key that will be small enough to need only 7 bytes of padding.
            # This key is 168 bit long, and was generated with rsa.newkeys(nbits=168).
            self.private_key = rsa.PrivateKey.load_pkcs1(
                b"""
    -----BEGIN RSA PRIVATE KEY-----
    MHkCAQACFgCIGbbNSkIRLtprxka9NgOf5UxgxCMCAwEAAQIVQqymO0gHubdEVS68
    CdCiWmOJxVfRAgwBQM+e1JJwMKmxSF0CCmya6CFxO8Evdn8CDACMM3AlVC4FhlN8
    3QIKC9cjoam/swMirwIMAR7Br9tdouoH7jAE
    -----END RSA PRIVATE KEY-----
            """
            )
>           self.public_key = rsa.PublicKey(n=self.private_key.n, e=self.private_key.e)
E           AttributeError: 'NoneType' object has no attribute 'n'

tests/test_pkcs1.py:201: AttributeError

test_pkcs1_v2.py::MGFTest::test_invalid_hasher

test_pkcs1_v2.py::MGFTest::test_invalid_hasher
self = 

    def test_invalid_hasher(self):
        """Tests an invalid hasher generates an exception"""
>       with self.assertRaises(ValueError):
E       AssertionError: ValueError not raised

tests/test_pkcs1_v2.py:74: AssertionError

test_pkcs1_v2.py::MGFTest::test_invalid_length

test_pkcs1_v2.py::MGFTest::test_invalid_length
self = 

    def test_invalid_length(self):
>       with self.assertRaises(OverflowError):
E       AssertionError: OverflowError not raised

tests/test_pkcs1_v2.py:78: AssertionError

test_pkcs1_v2.py::MGFTest::test_oaep_int_db_mask

test_pkcs1_v2.py::MGFTest::test_oaep_int_db_mask
self = 

    def test_oaep_int_db_mask(self):
        seed = (
            b"\xaa\xfd\x12\xf6\x59\xca\xe6\x34\x89\xb4\x79\xe5\x07\x6d\xde\xc2" b"\xf0\x6c\xb5\x8f"
        )
        db = (
            b"\xda\x39\xa3\xee\x5e\x6b\x4b\x0d\x32\x55\xbf\xef\x95\x60\x18\x90"
            b"\xaf\xd8\x07\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
            b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
            b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
            b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
            b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xd4\x36\xe9\x95\x69"
            b"\xfd\x32\xa7\xc8\xa0\x5b\xbc\x90\xd3\x2c\x49"
        )
        masked_db = (
            b"\xdc\xd8\x7d\x5c\x68\xf1\xee\xa8\xf5\x52\x67\xc3\x1b\x2e\x8b\xb4"
            b"\x25\x1f\x84\xd7\xe0\xb2\xc0\x46\x26\xf5\xaf\xf9\x3e\xdc\xfb\x25"
            b"\xc9\xc2\xb3\xff\x8a\xe1\x0e\x83\x9a\x2d\xdb\x4c\xdc\xfe\x4f\xf4"
            b"\x77\x28\xb4\xa1\xb7\xc1\x36\x2b\xaa\xd2\x9a\xb4\x8d\x28\x69\xd5"
            b"\x02\x41\x21\x43\x58\x11\x59\x1b\xe3\x92\xf9\x82\xfb\x3e\x87\xd0"
            b"\x95\xae\xb4\x04\x48\xdb\x97\x2f\x3a\xc1\x4f\x7b\xc2\x75\x19\x52"
            b"\x81\xce\x32\xd2\xf1\xb7\x6d\x4d\x35\x3e\x2d"
        )

        # dbMask = MGF(seed, length(DB))
        db_mask = pkcs1_v2.mgf1(seed, length=len(db))
        expected_db_mask = (
            b"\x06\xe1\xde\xb2\x36\x9a\xa5\xa5\xc7\x07\xd8\x2c\x8e\x4e\x93\x24"
            b"\x8a\xc7\x83\xde\xe0\xb2\xc0\x46\x26\xf5\xaf\xf9\x3e\xdc\xfb\x25"
            b"\xc9\xc2\xb3\xff\x8a\xe1\x0e\x83\x9a\x2d\xdb\x4c\xdc\xfe\x4f\xf4"
            b"\x77\x28\xb4\xa1\xb7\xc1\x36\x2b\xaa\xd2\x9a\xb4\x8d\x28\x69\xd5"
            b"\x02\x41\x21\x43\x58\x11\x59\x1b\xe3\x92\xf9\x82\xfb\x3e\x87\xd0"
            b"\x95\xae\xb4\x04\x48\xdb\x97\x2f\x3a\xc1\x4e\xaf\xf4\x9c\x8c\x3b"
            b"\x7c\xfc\x95\x1a\x51\xec\xd1\xdd\xe6\x12\x64"
        )

>       self.assertEqual(db_mask, expected_db_mask)
E       AssertionError: None != b'\x06\xe1\xde\xb26\x9a\xa5\xa5\xc7\x07\x[292 chars]x12d'

tests/test_pkcs1_v2.py:62: AssertionError

test_prime.py::PrimeTest::test_get_primality_testing_rounds

test_prime.py::PrimeTest::test_get_primality_testing_rounds
self = 

    def test_get_primality_testing_rounds(self):
        """Test round calculation for primality testing."""

>       self.assertEqual(rsa.prime.get_primality_testing_rounds(1 << 63), 10)
E       AssertionError: None != 10

tests/test_prime.py:124: AssertionError

test_prime.py::PrimeTest::test_is_prime

test_prime.py::PrimeTest::test_is_prime
self = 

    def test_is_prime(self):
        """Test some common primes."""

        # Test some trivial numbers
        self.assertFalse(rsa.prime.is_prime(-1))
        self.assertFalse(rsa.prime.is_prime(0))
        self.assertFalse(rsa.prime.is_prime(1))
>       self.assertTrue(rsa.prime.is_prime(2))
E       AssertionError: None is not true

tests/test_prime.py:31: AssertionError

test_prime.py::PrimeTest::test_mersenne_primes

test_prime.py::PrimeTest::test_mersenne_primes
self = 

    def test_mersenne_primes(self):
        """Tests first known Mersenne primes.

        Mersenne primes are prime numbers that can be written in the form
        `Mn = 2**n - 1` for some integer `n`. For the list of known Mersenne
        primes, see:
        https://en.wikipedia.org/wiki/Mersenne_prime#List_of_known_Mersenne_primes
        """

        # List of known Mersenne exponents.
        known_mersenne_exponents = [
            2,
            3,
            5,
            7,
            13,
            17,
            19,
            31,
            61,
            89,
            107,
            127,
            521,
            607,
            1279,
            2203,
            2281,
            4423,
        ]

        # Test Mersenne primes.
        for exp in known_mersenne_exponents:
>           self.assertTrue(rsa.prime.is_prime(2 ** exp - 1))
E           AssertionError: None is not true

tests/test_prime.py:119: AssertionError

test_prime.py::PrimeTest::test_miller_rabin_primality_testing

test_prime.py::PrimeTest::test_miller_rabin_primality_testing
self = 

    def test_miller_rabin_primality_testing(self):
        """Uses monkeypatching to ensure certain random numbers.

        This allows us to predict/control the code path.
        """

        randints = []

        def fake_randint(maxvalue):
            return randints.pop(0)

        orig_randint = rsa.randnum.randint
        rsa.randnum.randint = fake_randint
        try:
            # 'n is composite'
            randints.append(2630484832)  # causes the 'n is composite' case with n=3784949785
>           self.assertEqual(False, rsa.prime.miller_rabin_primality_testing(2787998641, 7))
E           AssertionError: False != None

tests/test_prime.py:61: AssertionError

test_strings.py::StringTest::test_enc_dec

test_strings.py::StringTest::test_enc_dec
self = 

    def setUp(self):
>       (self.pub, self.priv) = rsa.newkeys(384)
E       TypeError: cannot unpack non-iterable NoneType object

tests/test_strings.py:28: TypeError

test_transform.py::Test_int2bytes::test_accuracy

test_transform.py::Test_int2bytes::test_accuracy
self = 

    def test_accuracy(self):
>       self.assertEqual(int2bytes(123456789), b"\x07[\xcd\x15")
E       AssertionError: None != b'\x07[\xcd\x15'

tests/test_transform.py:21: AssertionError

test_transform.py::Test_int2bytes::test_chunk_size

test_transform.py::Test_int2bytes::test_chunk_size
self = 

    def test_chunk_size(self):
>       self.assertEqual(int2bytes(123456789, 6), b"\x00\x00\x07[\xcd\x15")
E       AssertionError: None != b'\x00\x00\x07[\xcd\x15'

tests/test_transform.py:27: AssertionError

test_transform.py::Test_int2bytes::test_codec_identity

test_transform.py::Test_int2bytes::test_codec_identity
self = 

    def test_codec_identity(self):
>       self.assertEqual(bytes2int(int2bytes(123456789, 128)), 123456789)
E       AssertionError: None != 123456789

tests/test_transform.py:24: AssertionError

test_transform.py::Test_int2bytes::test_correctness_against_base_implementation

test_transform.py::Test_int2bytes::test_correctness_against_base_implementation
self = 

    def test_correctness_against_base_implementation(self):
        # Slow test.
        values = [
            1 << 512,
            1 << 8192,
            1 << 77,
        ]
        for value in values:
>           self.assertEqual(bytes2int(int2bytes(value)), value, "Boom %d" % value)
E           AssertionError: None != 13407807929942597099574024998205846127479[109 chars]84096 : Boom 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084096

tests/test_transform.py:43: AssertionError

test_transform.py::Test_int2bytes::test_raises_OverflowError_when_chunk_size_is_insufficient

test_transform.py::Test_int2bytes::test_raises_OverflowError_when_chunk_size_is_insufficient
self = 

    def test_raises_OverflowError_when_chunk_size_is_insufficient(self):
>       self.assertRaises(OverflowError, int2bytes, 123456789, 3)
E       AssertionError: OverflowError not raised by int2bytes

tests/test_transform.py:46: AssertionError

test_transform.py::Test_int2bytes::test_raises_TypeError_when_not_integer

test_transform.py::Test_int2bytes::test_raises_TypeError_when_not_integer
self = 

    def test_raises_TypeError_when_not_integer(self):
>       self.assertRaises(TypeError, int2bytes, None)
E       AssertionError: TypeError not raised by int2bytes

tests/test_transform.py:53: AssertionError

test_transform.py::Test_int2bytes::test_raises_ValueError_when_negative_integer

test_transform.py::Test_int2bytes::test_raises_ValueError_when_negative_integer
self = 

    def test_raises_ValueError_when_negative_integer(self):
>       self.assertRaises(ValueError, int2bytes, -1)
E       AssertionError: ValueError not raised by int2bytes

tests/test_transform.py:50: AssertionError

test_transform.py::Test_int2bytes::test_zero

test_transform.py::Test_int2bytes::test_zero
self = 

    def test_zero(self):
>       self.assertEqual(int2bytes(0, 4), b"\x00" * 4)
E       AssertionError: None != b'\x00\x00\x00\x00'

tests/test_transform.py:31: AssertionError

Patch diff