Commit graph

2310 commits

Author SHA1 Message Date
Alex Gaynor
2ca57be0c4
Use pyo3's facilities for exceptions (#8785) 2023-04-22 13:32:59 -06:00
Alex Gaynor
8d616959f9
Convert HMAC to Rust (#8781) 2023-04-22 12:20:57 -06:00
Alex Gaynor
1bc46c7298
Added a benchmark for hmac (#8776) 2023-04-21 21:24:11 +00:00
Alex Gaynor
8397cd2a05
Convert hashes to Rust (#8775) 2023-04-21 14:06:41 -06:00
Alex Gaynor
923fe070ba
Added a benchmark for hashing (#8774) 2023-04-21 17:40:19 +00:00
Paul Kehrer
9c09a67204
drop libressl 3.5.x support (#8741)
OpenBSD 7.1 is no longer supported so neither is LibreSSL 3.5.x
2023-04-16 07:34:00 -04:00
Paul Kehrer
45bddbfb19
add support for aes256-gcm@openssh.com decryption for SSH keys (#8738)
* add support for aes256-gcm@openssh.com decryption for SSH keys

* review feedback

* skip when bcrypt isn't present
2023-04-15 04:05:11 +00:00
Alex Gaynor
edf5bd5184
Remove unused parameter (#8707) 2023-04-11 12:41:16 +08:00
Alex Gaynor
cef2be76e8
Convert ed448 to Rust (#8705) 2023-04-11 07:41:53 +08:00
Alex Gaynor
f5c750deab
Convert ed25519 to Rust (#8697) 2023-04-10 12:55:57 +00:00
Alex Gaynor
d5db3d4bfc
Added extra test cases for Ed25519 serialization (#8703) 2023-04-10 12:39:03 +00:00
Paul Kehrer
577c9bb7a8
support equality checks on all public asymmetric key types (#8700)
* support equality checks on all public asymmetric key types

* review feedback
2023-04-10 12:13:21 +00:00
Paul Kehrer
f724c9b2fd
Support msCertificateTemplate extension (#8695)
* support ms certificate template

* contortions for rust coverage

* review feedback
2023-04-10 03:10:41 +00:00
Alex Gaynor
122211bb45
Remove coverage workaround that might not be required anymore (#8690) 2023-04-10 05:48:42 +08:00
Alex Gaynor
22759dbab0
Switch from pytest-subtests to a mini-version that's faster (#8613) 2023-03-29 02:28:17 +00:00
Alex Gaynor
89228a9deb
Added support for OCSP AcceptableResponses extension (#8617)
fixes #8589
2023-03-27 00:51:04 +00:00
Alex Gaynor
e565402f2f
Add benchmark for loading DER certificates (#8597) 2023-03-24 22:16:56 +00:00
Alex Gaynor
7e62312797
Upgrade to pyo3 0.18 (#6935)
* Upgrade to pyo3 0.16

* Upgrade to pyo3 0.17

* Upgrade to pyo3 0.18
2023-03-24 21:23:13 +00:00
Paul Kehrer
ffc10f9bb0
remove a test dep (#8446) 2023-03-24 13:41:35 +00:00
Paul Kehrer
b5170bf26d
drop python 3.6 support (#8448)
* drop python 3.6 support

* Update tests/hazmat/bindings/test_openssl.py

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

---------

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2023-03-24 13:15:13 +00:00
Paul Kehrer
5e6476a4c6
drop support for openssl < 1.1.1d (#8449)
This removes the OS random engine, which contained the only CPython PSF
licensed code in the repository. Accordingly, that license has now been
removed.
2023-03-24 08:36:58 -04:00
Alex Gaynor
c8328c03af
Migrate x25519 to use rust-openssl (#7933) 2023-03-24 11:48:40 +08:00
Paul Kehrer
28c5b8f6f8
remove hypothesis from our test suite (#8560)
we weren't really getting any value from it and we haven't expanded our
use in numerous years
2023-03-21 11:54:09 +00:00
Alex Gaynor
f371af837a
Added support for handling python buffers in Rust code (#8556)
This is extra mega cursed, and strictly speaking unsound. It does, however, match the status quo ante, where someone mutating a buffer while its being used in cffi code will basically always be UB.
2023-03-21 08:16:53 +08:00
Alex Gaynor
45a5100e4e
Simplify/unify Rust and Python OpenSSL error handling (#8552) 2023-03-20 09:41:48 +08:00
Alex Gaynor
8b45a09f14
fix logic for this skip (#8542) 2023-03-18 10:09:00 +08:00
Alex Gaynor
80acb6a54f
skip memleak tests on pypy (#8540)
See: https://github.com/pyca/cryptography/pull/7933#issuecomment-1471865194 + https://foss.heptapod.net/pypy/pypy/-/issues/3905#note_290457 to understand why
2023-03-18 05:34:15 +08:00
Alex Gaynor
8882c3c88d
Support handling OpenSSL errors from Rust code (#8530) 2023-03-16 13:05:33 +08:00
Alex Gaynor
6c39999b40
Ressurect the PoC of OpenSSL from Rust (#7164) 2023-03-15 13:06:16 +08:00
Alex Gaynor
5e3061c05e
Stop validating keys in ECDH exchange (#8490)
The theory here is that we're already doing sufficient validation key loading, and this is purely duplicative.

Note that there's at least _some_ validationg that was previously occurring only ECDH, the LowOrderPublic check that can be seen in wycheproof.
2023-03-11 12:14:27 +08:00
Paul Kehrer
ce05282e58
cache ECDH values in wycheproof too (#8487)
this alters and renames the caching function a bit since it caches *to
the group* object but the actual values (in ECDH) come from the testcase
itself
2023-03-10 07:31:10 -05:00
Paul Kehrer
f046fd5844
speed up RSA key loading in tests a bit more (#8486) 2023-03-09 21:07:34 -05:00
Alex Gaynor
31f0dcabda
Cache some keys that are reused in wycheproof tests (#8479) 2023-03-10 05:17:42 +08:00
Alex Gaynor
a8e5fca2c2
Small cleanups: (#8476)
- Avoid typing.cast
- Consolidate bn_ctx allocations
2023-03-09 13:26:14 +00:00
Paul Kehrer
7f54011429
add EC key load benchmark (#8473) 2023-03-08 05:27:14 +00:00
Marti Raudsepp
79e38a379e
Make Union type aliases a documented public API (#8168)
* Rename Union type aliases to CamelCase

Many `typing.Union` type aliases were previously using `UPPER_SNAKE_CASE`, but Python's convention is `CamelCase` for these (e.g. https://docs.python.org/3/library/typing.html#type-aliases)

* Add utils.deprecated for the old non-underscore type aliases

* Added documentation for new type aliases & minor tweaks

* Use 'versionadded:: 40.0.0'

* Fix CertificatePublicKeyTypes vs CertificateIssuerPublicKeyTypes. Rename CertificatePrivateKeyTypes to CertificateIssuerPrivateKeyTypes

* Fix imports (ruff)

* Fix one more versionadded

* Tweak docs & Reorder: CertificateIssuerPublicKeyTypes before CertificateIssuerPrivateKeyTypes

* Fix test mypy errors using cast()

* Fix black, oops

* Revert "Fix black, oops"

This reverts commit 85344e231d697bdc0940e105f7aed729445f9743.

* Revert "Fix test mypy errors using cast()"

This reverts commit b272d8ca95fbbbc62060663f9e8930a139a7a43e.

* Revert type of SubjectKeyIdentifier.from_public_key arg

* Changelog tweak
2023-03-07 19:20:32 +08:00
Paul Kehrer
99a27f30f6
refactor PBKDF2HMAC test vectors and skip one test (#8467)
The test in question has 2**24 iterations and doesn't represent an
interesting edge case in the algorithm, just a high iteration count.
2023-03-06 18:56:26 -05:00
Alex Gaynor
fe91d4e68f
Remove a zillion pointless backenda args in x509 tests (#8466) 2023-03-07 06:04:08 +08:00
Paul Kehrer
0b2d648a4d
remove memleak tests for x509 paths that no longer use openssl (#8461) 2023-03-06 05:05:46 +00:00
Paul Kehrer
ba46c3a39d
use the rsa fixtures in x509 too (#8460)
* use the rsa fixtures in x509 too

* use strings in __all__
2023-03-06 03:51:20 +00:00
Paul Kehrer
b522ec0092
double the speed of our rsa tests (#8458)
* double the speed of our rsa tests

this both creates a reusable fixture for our most commonly used private
keys as well as disables key validation. as always, disabling key
validation should not be done unless you never parse untrusted key
input. unsurprisingly, our tests are trusted and understood input (and
we also continue to have tests where we run check key to verify that it
catches corrupt things)

* fix typing

* explain why we don't use the rsa_key_2048 fixture in the blinding test
2023-03-06 02:19:52 +00:00
Paul Kehrer
550355b552
remove pytz test dependency (#8447) 2023-03-05 08:59:23 -05:00
Alex Gaynor
d05a8ac6cd
Update to the new wycheproof (#8403) 2023-02-28 05:07:54 +00:00
Paul Kehrer
280b42efb6
raise UnsupportedAlgorithm instead of ValueError in x509 builder sign (#8397)
Also change the typing to be an explicit union
2023-02-26 18:52:12 -05:00
Alex Gaynor
bc61b605c7
fixes #8298 -- correctly generate content-type header in PKCS#7 SMIME (#8389) 2023-02-26 10:09:35 +08:00
Jake
de8deb9e94
Enforce max number of SSH certificate principals (#8376)
* Enforce max number of SSH certificate principals

There is an undocumented limit for the maximum number of valid principals accepted by the openssh tooling, as seen at:
* 2726764269/sshkey.h (L108)
* 25c8a2bbcc/sshkey.c (L1801)
* 6180b0fa4f/ssh-keygen.c (L1833)

This change enforces that same restriction as currently a SSH certificate can be generated that is invalid against the default sshd server. Consideration might be given for any non openssh servers that accept openssh certificates, if they exist and want to allow a greater number of principals.

Of note, the 256 limit is not found in the spec for SSH certificates as defined at https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.certkeys. It instead seems to be arbitrarily chosen by the project as some limit was needed.

* Address formatting error.

* Comment on valid_prinicpals size limit plus test added.

---------

Co-authored-by: Jake <jake@vaultish.com>
2023-02-23 07:03:47 -05:00
David Buchanan
db6905d69c
Add shortcut methods for exporting EC keys as raw bytes (#8357)
* WIP: Add raw export alias method for x25519 keys

* Ditto for x448, ed448, ed25519

* Document new private_bytes_raw public_bytes_raw methods

* docs: Populate versionadded to be 40

* docs: Fix PublicFormat -> PrivateFormat where applicable

* formatting

* Update tests for test_pub_priv_bytes_raw in x25519, x448, ed448 (TODO: ed25519)

* Add test_pub_priv_bytes_raw test for Ed25519
2023-02-22 08:09:34 -05:00
Paul Kehrer
f59a7d42fb
update to latest pytest-subtests and add the new flag (#8301)
* update to latest pytest-subtests and add the new flag

* crimez

* lol
2023-02-16 03:24:35 +00:00
Paul Kehrer
8eeaf22b2c
fix some binding declarations (#8273)
* fix some binding declarations

also adds a comment about why we deliberately incorrectly declare some
of them, sigh

* it's actually safe to do this since no high bit mode options exist
2023-02-12 22:23:38 +00:00
gbansaghi
182857a08f
Disallow wildcards in DNSName for name constraints (#8272)
* Disallow wildcards in DNSName for name constraints

As discussed in #8253, wildcards are unnecessary according to RFC 5280, and cause issues with at least Firefox.

* update changelog
2023-02-12 17:29:32 +00:00