Commit graph

1948 commits

Author SHA1 Message Date
Alex Gaynor
49109ce1a6
Always rely on OpenSSL's builtin locking callbacks (#5561) 2020-11-11 13:35:47 -06:00
Paul Kehrer
b59d2de9cf
GCM IV size limits (#5553)
* GCM IV size limits

OpenSSL 3.0.0 is going to enforce these size limits so we might as well
put them in now.

* fix the tests

* black

* these cases can't happen if we're limiting IV size already
2020-11-09 13:56:53 -05:00
Benjamin Peterson
15771e2ec2
padding: Tip-toe around bytes subclasses. (#5548)
This change allows future's newbytes class to be padded again.

Fixes https://github.com/pyca/cryptography/issues/5547.
2020-11-04 07:49:47 -08:00
Alex Gaynor
b165616703
Disable blinding for RSA pub keys (#5524) 2020-10-27 15:51:20 -07:00
Alex Gaynor
d3eae8d7db
Delete all the 1.0.2 code (#5511) 2020-10-25 22:41:40 -07:00
Paul Kehrer
cf9bd6a36b
move blinding to __init__ on both RSA public and private (#5506)
* move blinding to __init__ on both RSA public and private

* change signature to guarantee this test is testing what we think
2020-10-25 20:15:11 -04:00
frennkie
611c4a340f
PKCS7SignatureBuilder now supports new option NoCerts when signing (#5500) 2020-10-25 07:50:18 -07:00
Paul Kehrer
836a92a28f
chunking didn't actually work (#5499) 2020-10-25 09:15:18 -04:00
Paul Kehrer
085d1e44c6
allow additional certificates to be added to a pkcs7 (#5498)
* allow additional certificates to be added to a pkcs7

* be more verbose about what these additional certs might be used for

* missing test
2020-10-25 09:11:48 -04:00
Paul Kehrer
95c4f68c1b
PKCS7SignatureBuilder now supports three serializations (#5497)
* PKCS7SignatureBuilder now supports three serializations

PEM, DER, and SMIME. SMIME embeds the S/MIME headers and has the
detached signature concept.

* thanks libre
2020-10-24 21:17:06 -04:00
Paul Kehrer
5edf5b828a
migrate smime builder to pkcs7 module and rename (#5496)
* migrate smime builder to pkcs7 module and rename

* missed a rename
2020-10-24 20:10:25 -04:00
Paul Kehrer
20c0388086
smime signer support (#5465)
* smime signer support

* fix ed25519 check

* change some wording

* python 2.7...

* review feedback

* s/secure/signed

* do some verification in the tests

* review feedback

* doc return value
2020-09-19 19:07:26 -04:00
Paul Kehrer
1a9e2e1ad7
allow bytes-like for padding (#5462)
this doesn't improve efficiency in any way (copies galore!), but it does
make it consistent between a cipher context and a padding context
2020-09-13 20:04:18 -04:00
Alex Gaynor
8bc6920444
Break users on OpenSSL 1.0.2 (#5438)
fixes #5432
2020-08-28 09:55:41 -05:00
Paul Kehrer
bda138768a
new black, actually slightly different than the old black (#5429) 2020-08-26 22:59:43 -04:00
Paul Kehrer
f90ba1808e
chunked update_into (#5419)
* chunked update_into

* all pointer arithmetic all the time

* review feedback
2020-08-24 00:41:33 -04:00
Paul Kehrer
42ad3b0cd8
be consistent in our testing (#5409)
* be consistent in our testing

we don't use default_backend this way in our tests

* more black
2020-08-16 16:49:01 -04:00
Alex Gaynor
fce9a79215
fixes #4706 -- don't internal error on corrupt private key (#5307)
* fixes #4706 -- don't internal error on corrupt private key

* Temporary disable paramiko
2020-08-15 11:50:13 -05:00
Paul Kehrer
40bfc7f75b
remove KDF backend requirements (#5389) 2020-08-14 23:48:08 -04:00
Paul Kehrer
77099636b6
separate these into two test files (#5383)
* separate these into two test files

AES-GCM is so painful in collection that I want it in another file

* fix flake8
2020-08-10 00:57:17 -04:00
Paul Kehrer
c898871daa
support PKCS7 certificate parsing (#5371)
* support PKCS7 certificate parsing

* refcounts are different in 1.0.2

* rename the functions

* black

* empty commit

* review feedback
2020-08-04 23:50:02 -04:00
Alex Gaynor
7fc93ee784
Remove unused code (#5360) 2020-07-28 16:09:43 -05:00
Paul Kehrer
d54b6f0fa3
more error simplification (#5354)
X509 signing for RSA keys that are too small. Let's just say signing
failed and attach the more specific problem as the error stack. A bit
uglier, but far more generic and stable to OpenSSL/LibreSSL/BoringSSL

Also be a bit more generic for OCSP signing
2020-07-27 00:10:04 -04:00
Paul Kehrer
bc609feef8
simplify more errors (#5353)
the quest to stop using unstable openssl error codes continues
2020-07-26 22:36:39 -04:00
Paul Kehrer
ace8a92be9
remove idna support finally (#5351)
* remove idna support finally

* remove unused import
2020-07-26 13:07:31 -04:00
Alex Gaynor
73b128d755
Refs #5113 -- build against openssl with no ct (#5343) 2020-07-24 19:16:44 -05:00
Alex Gaynor
60aa04481f
Paint it Black by the Rolling Stones (#5324) 2020-07-20 13:06:29 -05:00
Paul Kehrer
4a245a657a
test FIPS mode on centos8 (#5323)
* test FIPS mode on centos8

* remove branch we don't take

* simpler

* better comment

* rename

* revert some things that don't matter

* small cleanups
2020-07-20 12:10:29 -04:00
Paul Kehrer
2fdb7472af
PKCS12 support (#5325)
* generate_pkcs12 (#4952)

* pkcs12 support

* simplify

* remove fixtures

* reorg and other improvements. memleak check

* ugh

* more fixes

* last changes hopefully

Co-authored-by: Tomer Shalev <tshalev@proofpoint.com>
2020-07-20 10:26:43 -04:00
Paul Kehrer
972c886f6f
refactor DH a bit to generate less parameters (#5326)
speeds things up a bit and makes it easier to do the FIPS PR
2020-07-19 22:46:20 -04:00
Paul Kehrer
084da16ebc
disable the osrandom engine on 1.1.1d+ (#5317)
* disable the osrandom engine on 1.1.1d+

* skip (and run) some tests on 1.1.1d+

* simplify our conditionals

* Update src/_cffi_src/openssl/src/osrandom_engine.c

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>

* words

* more words

* language

* get coverage more cleverly

* a word

* Update .github/workflows/ci.yml

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2020-07-19 12:33:18 -04:00
Paul Kehrer
1604ea7ec0
test exceptions and properly reject duplicate attributes in csrbuilder (#5319) 2020-07-18 22:11:23 -04:00
Alex Gaynor
b8656fc001
Implement __deepcopy__ for x509 certificates (#5318)
fixes #5129
2020-07-18 20:55:38 -05:00
Paul Kehrer
c51f7957dd
raise a valueerror on multi-SINGLERESP valued OCSP responses (#5316)
InternalErrors are bad when we know they're reachable
2020-07-18 20:59:56 -04:00
Paul Kehrer
aded1cd02f
support encoding attributes via CertificateSigningRequestBuilder (#5315)
* support encoding attributes via CertificateSigningRequestBuilder

* use a constant. now you know what 12 means!

* pep8
2020-07-18 20:55:25 -04:00
Paul Kehrer
e41177372f
change KeyUsage repr to be less confusing (#5314)
fixes #5127
2020-07-18 18:40:06 -04:00
Paul Kehrer
b8146690ec
support unstructured name x509 attributes (#5313) 2020-07-18 18:35:25 -04:00
Paul Kehrer
28e2783a81
support x509 request challenge password parsing (#4944)
* support x509 request challenge password parsing

* switch to a more generic (but not too generic) attribute parsing

* make it raise a valueerror

* Update tests/x509/test_x509.py

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2020-07-05 22:29:32 -04:00
Paul Kehrer
7a233b9a60
support 4096 bit DSA parsing from numbers classes (#5301)
* support 4096 bit DSA parsing from numbers classes

* need to get local linting fixed.

* reorder

* add a link to more reasons why DSA sucks
2020-07-05 21:19:39 -04:00
Alex Gaynor
7d915fa4f9
Enforce that X.509 versions on valid on parse. (#5299)
Closes #5290
2020-07-05 14:51:59 -05:00
Paul Kehrer
210dc86628
Support parsing SCTs in OCSPResponse (#5298)
* Support parsing SCTs in OCSPResponse

* s/typically/only and pep8

* remove unused vector

Co-authored-by: Szilárd Pfeiffer <szilard.pfeiffer@balasys.hu>
2020-07-05 11:01:07 -04:00
Paul Kehrer
13fae162da
add SubjectInformationAccess extension support (#5295)
* add SubjectInformationAccess extension support

* fixes
2020-07-02 01:13:33 -04:00
Paul Kehrer
63d337e5cc
constrain RSA key generation more heavily (#5288)
* constrain RSA key generation more heavily

* constraint to just 3 & 65537

* explain change
2020-06-28 00:18:00 -04:00
Jakub Stasiak
9719375294
Disallow ttl=None in (Multi)Fernet.decrypt_at_time() (#5280)
* Disallow ttl=None in (Multi)Fernet.decrypt_at_time()

Since the introduction of the _at_time() methods in #5256[1] there's
been this little voice in the back of my mind telling me that maybe it's
not the best idea to allow ttl=None in decrypt_at_time(). It's been like
this for convenience and code reuse reasons.

Then I submitted a patch for cryptography stubs in typeshed[2] and I had
to decide whether to define decrypt_at_time()'s ttl as int and be
incompatible with cryptography's behavior or Optional[int] and advertise
an API that can be misused much too easily. I went ahead with int.

Considering the above I decided to propose this patch. Some amount of
redundancy (and a new test to properly cover the
MultiFernet.decrypt_at_time() implementation) is a price to prevent
clients from shooting themselves in the foot with the tll=None gun since
setting ttl to None disabled timestamp checks even if current_time was
provided.

[1] https://github.com/pyca/cryptography/pull/5256
[2] https://github.com/python/typeshed/pull/4238

* Actually test the return value here

* Fix formatting
2020-06-24 21:51:54 -04:00
David Benjamin
3f4944d4e5
Fix up crl_delta_crl_indicator.pem. (#5283)
The CRL is missing a CRL number and should mark the delta CRL extension
as critical. RFC 5280 says the following:

Section 5.2.3:

> CRL issuers conforming to this profile MUST include this extension
> [CRL number] in all CRLs and MUST mark this extension as
> non-critical.

Section 5.2.4:

> The delta CRL indicator is a critical CRL extension that identifies a
> CRL as being a delta CRL.

> When a conforming CRL issuer generates a delta CRL, the delta CRL
> MUST include a critical delta CRL indicator extension.

Sadly, RFC 5280 is often unclear about the difference between issuer
requirements and verifier requirements, but test certificates should
conform to issuer requirements where possible, in case the underly
library becomes stricter. Section 5.2.4 includes further text which
implies a delta CRL without a CRL number is unusable for a verifier
anyway:

> A complete CRL and a delta CRL MAY be combined if the following four
> conditions are satisfied:
>
> [...]
>
>   (d)  The CRL number of the complete CRL is less than the CRL number
>        of the delta CRL.  That is, the delta CRL follows the complete
>        CRL in the numbering sequence.

Note I have not updated the signature in crl_delta_crl_indicator.pem.
The test does not care, and it is unclear which key to sign it with.
2020-06-24 21:50:49 -04:00
Marko Kreen
0f8626093c
Support OpenSSH private key serialization format (#5146)
* ssh.py contains load/serialize code.
* Add PrivateFormat.OpenSSH to .private_bytes() format.
* Add load_ssh_private_key().
* Use new code for PublicFormat.OpenSSH too.
* load_ssh_public_key() now supports reading signed public keys.
* Supported algorithms: rsa, dsa, ec, ed25519.
* Optional dependency on 'bcrypt' package via [ssh] extra
2020-06-20 19:06:26 -05:00
Marko Kreen
0b03617084
Unify X.509 signature algorithm validation (#5276)
- Use common implementation
- OCSP signing was using different validation
- Check if private key is usable for signing
2020-06-14 16:12:06 -05:00
Jakub Stasiak
0d0d70bd78
Add a way to pass current time to Fernet (#5256)
* Add a way to pass current time to Fernet

The motivation behind this is to be able to unit test code using Fernet
easily without having to monkey patch global state.

* Reformat to satisfy flake8

* Trigger a Fernet.encrypt() branch missing from coverage

* Revert specifying explicit current time in MultiFernet.rotate()

Message's timestamp is not verified anyway since ttl is None.

* Change the Fernet's explicit current time API slightly

This's been suggested in code review.

* Fix a typo

* Fix a typo

* Restore full MultiFernet test coverage and fix a typo

* Restore more coverage

time.time() is not called by MultiFernet.rotate() anymore so the monkey
patching and lambda need to go, because the patched function is not used
and coverage calculation will rightfully notice it.

* Remove an unused import

* Document when the *_at_time Fernet methods were added
2020-06-14 13:30:18 -05:00
Marko Kreen
9470f67a30
Cleanup serialize (#5149)
* Additional tests for public/private_bytes

They expose few places that raise TypeError and AssertionError!
before, and ValueError later.

* Cleanup of private_bytes() backend

Also pass key itself down to backend.

* Cleanup of public_bytes() backend

* Test handling of unsupported key type
2020-05-25 13:17:25 -05:00
Alex Gaynor
12e85b5916
Added wycheproof hmac vectors (#5238) 2020-04-26 15:53:58 -05:00