I hate computers. How do abstractions even work :/

I'd actually be interested in hearing from @dreid, @glyph, @lvh or some
other twisted folks if they have an idea about how to do this better (maybe
we should at least move teh duplicated branches to a common validate
function?), most projects I work on have solved this issue by not making
"backend" a public API, and thus it being illegal to call it with wrong
arguments, but obviously we've got another route.


On Tue, May 27, 2014 at 8:40 AM, Paul Kehrer <notifications@github.com>wrote:

> In tests/hazmat/backends/test_openssl.py:
>
> > @@ -277,6 +277,22 @@ def test_generate_rsa_parameters_supported(self):
> >          assert backend.generate_rsa_parameters_supported(3, 1024) is True
> >          assert backend.generate_rsa_parameters_supported(3, 511) is False
> >
> > +    def test_generate_bad_public_exponent(self):
> > +        with pytest.raises(ValueError):
> > +            backend.generate_rsa_private_key(public_exponent=1, key_size=2048)
> > +
> > +        with pytest.raises(ValueError):
> > +            backend.generate_rsa_private_key(public_exponent=4, key_size=2048)
> > +
> > +    def test_cant_generate_insecure_tiny_key(self):
> > +        with pytest.raises(ValueError):
> > +            backend.generate_rsa_private_key(public_exponent=65537,
> > +                                             key_size=511)
> > +
> > +        with pytest.raises(ValueError):
> > +            backend.generate_rsa_private_key(public_exponent=65537,
> > +                                             key_size=256)
>
> If we remove the logic from the backend then we provide a means to crash
> the process from within Python (just pass an even integer to
> generate_rsa_private_key), so I think checks need to be enforced at both
> layers.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/pyca/cryptography/pull/1082/files#r13077521>
> .
>



-- 
"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