Why do we even need our own check for `key_size < len(data)` if OpenSSL
will catch it?


On Thu, Apr 24, 2014 at 3:34 PM, Alex Gaynor <alex.gaynor@gmail.com> wrote:

> k
>
>
> On Thu, Apr 24, 2014 at 3:33 PM, Paul Kehrer <notifications@github.com>wrote:
>
>> In tests/hazmat/primitives/test_rsa.py:
>>
>> > +    )
>> > +    def test_rsa_encrypt_key_too_small(self, key_size, pad, backend):
>> > +        private_key = rsa.RSAPrivateKey.generate(
>> > +            public_exponent=65537,
>> > +            key_size=key_size,
>> > +            backend=backend
>> > +        )
>> > +        public_key = private_key.public_key()
>> > +        with pytest.raises(ValueError):
>> > +            public_key.encrypt(
>> > +                b"\x00" * (key_size // 8 - 1),
>> > +                pad,
>> > +                backend
>> > +            )
>> > +
>> > +    def test_rsa_encrypt_data_too_large(self, backend):
>>
>> There's a check in the code that raises if key_size < data, but there's
>> also the intermediate case where the data is smaller than key_size but is
>> still too large due to PKCS1v15/OAEP minimum padding. They're two different
>> code paths so I separated the tests.
>>
>> —
>> Reply to this email directly or view it on GitHub<https://github.com/pyca/cryptography/pull/962/files#r11976044>
>> .
>>
>
>
>
> --
> "I disapprove of what you say, but I will defend to the death your right
> to say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
> "The people's good is the highest law." -- Cicero
> GPG Key fingerprint: 125F 5C67 DFE9 4084
>



-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
GPG Key fingerprint: 125F 5C67 DFE9 4084