Commit graph

1934 commits

Author SHA1 Message Date
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
Alex Gaynor
263bad82ed
Refs #5075 -- added the remainder of the wycheproof rsa tests (#5237) 2020-04-26 12:36:11 -05:00
Alex Gaynor
069691a27b
Added wycheproof RSA PKCSv1 encryption tests (#5234) 2020-04-26 10:44:49 -05:00
Alex Gaynor
01eb304b08
Dropped support for LibreSSL 2.7, 2.8, and 2.9.0 (2.9.1+ are still supported) (#5231) 2020-04-25 22:42:20 -05:00
Alex Gaynor
37e11ccb99
Refs #5075 -- use ed448_test.json from wycheproof (#5191) 2020-04-12 10:02:02 -05:00
Alex Gaynor
ebb04592d2
Refs #5075 -- use hkdf_*.json from wycheproof (#5190) 2020-04-12 09:58:07 -05:00
Alex Gaynor
b77145a009
Refs #5075 -- use rsa_oaep_*.json from wycheproof (#5100) 2020-04-11 20:57:56 -05:00
Alex Gaynor
3b2102af54
Removed deprecated behavior in AKI.from_issuer_subject_key_identifier (#5182) 2020-04-05 20:00:55 -05:00
Torin Carey
e94a9f493b
Replace floating point arithmetic with integer arithmetic (#5181) 2020-04-04 17:30:59 -04:00
Alex Gaynor
aece5b3d47
Drop support for OpenSSL 1.0.1 (#5178) 2020-04-04 16:08:08 -05:00
Andrea De Pasquale
87b2749c52
Allow NameAttribute.value to be an empty string (#5109)
* Allow NameAttribute.value to be an empty string

RFC 4514 https://tools.ietf.org/html/rfc4514 does not mention that
"AttributeValue" can not be an empty (zero-length) string.

Fixes #5106

* reverse order to match fix from another PR

Co-authored-by: Paul Kehrer <paul.l.kehrer@gmail.com>
2020-03-19 15:23:35 -04:00
Thomas Erbesdobler
ed71c5cc07
Reversed the order of RDNs in x509.Name.rfc4514_string() (#5120)
RFC4514 requires in section 2.1 that RDNs are converted to string
representation in reversed order.
2020-03-02 21:26:07 -05:00
Alex Gaynor
c0dbbb52fb Refs #5075 -- use ecdsa_*.json from wycheproof (#5099) 2020-01-12 22:42:21 -05:00
Alex Gaynor
c8c78bb4c5 Refs #5075 -- use dsa_*.json from wycheproof (#5098) 2020-01-12 21:33:25 -05:00
Alex Gaynor
f95abfeb61 Refs #5075 -- use rsa_signature_*.json from wycheproof (#5078)
* Refs #5075 -- use rsa_signature_*.json from wycheproof

* for azure
2020-01-12 19:35:51 -05:00