Commit graph

2598 commits

Author SHA1 Message Date
Gonzalo Atienza
9c11549e2c
mac-docs-updates (#11644) 2024-09-22 21:23:47 -04:00
Gonzalo Atienza
184aa0fe4c
docs-chacha20-update (#11617) 2024-09-17 15:49:44 -04:00
Paul Kehrer
408b9f8a7a
argon2id test vectors (#11523) 2024-09-02 13:38:17 -04:00
Paul Kehrer
002419dcd6
properly document what key types raw works with (#11507) 2024-08-30 03:35:46 +00:00
Paul Kehrer
e4757c48ab
webstore.ansi.org is now behind cloudflare (#11477)
* webstore.ansi.org is now behind cloudflare

* CMU is also bad at certificates
2024-08-22 20:53:08 -04:00
David Benjamin
8755923903
Bump RSA-512 test keys to RSA-2048 (#11443)
* Bump RSA-512 test keys to RSA-2048

RSA-512 was broken in 1999. cryptography.io should not be requesting
its backend library support it in 2024.

* Update test-vectors.rst

The replacement keys were generated fresh, and this document seems to
just cite the external ones.

* Document custom test vectors
2024-08-17 18:38:57 +00:00
Alex Gaynor
e6cf6cab99
fix preview ruff warning (#11435) 2024-08-15 09:45:08 -07:00
William Woodruff
0db3ed8707
extensions: EKU must contain at least one member (#11383)
* extensions: EKU must contain at least one member

Signed-off-by: William Woodruff <william@trailofbits.com>

* record changes

Signed-off-by: William Woodruff <william@trailofbits.com>

* empty EKU test vector

Signed-off-by: William Woodruff <william@trailofbits.com>

* typo

Signed-off-by: William Woodruff <william@trailofbits.com>

---------

Signed-off-by: William Woodruff <william@trailofbits.com>
2024-08-02 15:06:46 +00:00
Alex Gaynor
5f20b23dc6
Added additional notes to cert verification docs (#11380)
Closes #11376
2024-08-01 21:12:01 +00:00
DandyDrop
2c5664b93b
Update fernet.rst (#11335) 2024-07-22 18:40:21 +00:00
Alex Gaynor
42788a0353
Fix exchange with keys that had Q automatically computed (#11309)
fixes #10790
closes #10864
closes #11218
2024-07-20 08:05:18 -07:00
Facundo Tuesca
0faaffc2f5
Add support for encrypting S/MIME messages (#10889)
* Add support for encrypting S/MIME messages

* Move PKCS7 decrypt test function to Rust

* Use symmetric encryption function from PKCS12

* Remove debug file write from tests

* Remove unneeded backend parameter

* docs and changelog
2024-07-18 08:52:09 -07:00
Facundo Tuesca
783223f5f6
docs: Add instructions to build the docs (#11290)
* docs: Add instructions to build the docs

* docs: Fix single backticks

* docs: remove troubleshooting section

* Update docs/development/getting-started.rst

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

---------

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2024-07-17 21:07:37 +00:00
Paul Kehrer
2b371f418b
add support for CipherContext.update_nonce (#10437)
* add support for CipherContext.reset_nonce

This only supports ChaCha20 and ciphers in CTR mode.

* expand tests to reset to different nonces
2024-07-05 18:54:12 -04:00
Daniel Lenski
8a7f27be3d
Add rsa_recover_private_exponent function (#11193)
Given the RSA public exponent (`e`), and the RSA primes (`p`, `q`), it is possible
to calculate the corresponding private exponent `d = e⁻¹ mod λ(n)` where
`λ(n) = lcm(p-1, q-1)`.

With this function added, it becomes possible to use the library to reconstruct an RSA
private key given *only* `p`, `q`, and `e`:

    from cryptography.hazmat.primitives.asymmetric import rsa

    n = p * q
    d = rsa.rsa_recover_private_exponent(e, p, q)  # newly-added piece
    iqmp = rsa.rsa_crt_iqmp(p, q)                  # preexisting
    dmp1 = rsa.rsa_crt_dmp1(d, p)                  # preexisting
    dmq1 = rsa.rsa_crt_dmq1(d, q)                  # preexisting

    assert rsa.rsa_recover_prime_factors(n, e, d) in ((p, q), (q, p))  # verify consistency

    privk = rsa.RSAPrivateNumbers(p, q, d, dmp1, dmq1, iqmp, rsa.RSAPublicNumbers(e, n)).private_key()

Older RSA implementations, including the original RSA paper, often used the
Euler totient function `ɸ(n) = (p-1) * (q-1)` instead of `λ(n)`.  The
private exponents generated by that method work equally well, but may be
larger than strictly necessary (`λ(n)` always divides `ɸ(n)`).  This commit
additionally implements `_rsa_recover_euler_private_exponent`, so that tests
of the internal structure of RSA private keys can allow for either the Euler
or the Carmichael versions of the private exponents.

It makes sense to expose only the more modern version (using the Carmichael
totient function) for public usage, given that it is slightly more
computationally efficient to use the keys in this form, and that some
standards like FIPS 186-4 require this form.  (See
https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf#page=63)
2024-07-05 15:14:04 -07:00
Magnus Watn
eae331491c
Add _utc datetime methods to x509.ocsp (#11183)
Fixes #11170.
2024-06-30 12:08:56 -04:00
Alex Gaynor
85fba50add
Remove buster from CI (#11182)
* Remove buster from CI

It is EOL

* Update installation.rst
2024-06-30 14:07:09 +03:00
William Woodruff
f370b09810
policy/extension: improve extension policy errors (#11162)
* policy/extension: improve extension policy errors

* verification: ValidationError::ExtensionError variant

Begin cleaning things up.

* policy/extension: remove redundant clone

* ensure that we render the ext OID

* lib: coverage for other display arms

* relocate custom vector

* test-vectors: typo
2024-06-25 21:51:24 -04:00
Alex Gaynor
61a5e672e6
fixed rst syntax in test-vectors.rst (#11153) 2024-06-25 08:00:12 +03:00
Nathan Easton
73717542c4
Update reference.rst (#11137)
* Update reference.rst

This code snippet works when importing the extension oid

* Apply suggestions from code review

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

---------

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2024-06-22 13:16:50 +00:00
Alex Gaynor
da45641e46
Convert PKCS7PaddingContext to Rust (#11089) 2024-06-10 12:22:36 -04:00
Paul Kehrer
5dc620daa4
document creating a CA hierarchy: root -> int -> ee (#11031)
* document creating a CA hierarchy: root -> int -> ee

* fix things
2024-05-27 13:00:44 +00:00
Dimitri Papadopoulos Orfanos
1ce23d008a
Fix more misspellings (#10933)
* Fix more misspellings

* Apply codespell suggestion: implementor → implementer

This is not exactly a misspelling, but:
* From Garner's Modern English Usage (4 ed.)
  	Although the variant spelling ✳implementor predominated for much of
  	the late 20th century, today implementer is considered standard.
* The Google Ngram Viewer shows a ratio of almost 10:1 in 2019.
2024-05-05 16:12:27 +00:00
Alex Gaynor
07642cfe48
Test on rolling for arm64 (#10897)
* Test on rolling for arm64

* Update installation.rst
2024-04-25 20:32:32 -07:00
Facundo Tuesca
83d90df3df
Add timezone-aware API variant for x509.InvalidityDate.invalidity_date (#10848) 2024-04-21 15:09:12 -04:00
Alex Gaynor
368e3505d5
Document that we test with ubuntu 24.04 (#10831) 2024-04-16 07:40:29 -06:00
Paul Kehrer
126c144aee
Update testing docs (#10829) 2024-04-16 12:23:40 +00:00
Julien Castiaux
031d407e4d
Add public_key_algorithm_oid to certificate and CSR (#10517) 2024-03-27 14:32:35 -04:00
Alex Gaynor
e9954a0a31
fixes #10631 -- remove documentation for method that was removed (#10632)
* fixes #10631 -- remove documentation for method that was removed

* Update CHANGELOG.rst
2024-03-23 12:53:01 +00:00
Alex Gaynor
8436316862
Wycheproof lives under C2SP now (#10628) 2024-03-22 19:34:41 -04:00
William Woodruff
4a3e7dcc97
verification: client verification APIs (#10345)
* verification: WIP client verification skeleton

Signed-off-by: William Woodruff <william@yossarian.net>

* verify: fill in build_client_verifier

Signed-off-by: William Woodruff <william@yossarian.net>

* implement ClientVerifier.verify

Signed-off-by: William Woodruff <william@yossarian.net>

* verification: make Python 3.8 happy

Signed-off-by: William Woodruff <william@yossarian.net>

* switch to a full VerifiedClient type

Signed-off-by: William Woodruff <william@yossarian.net>

* remove the SubjectOwner::None hack

Signed-off-by: William Woodruff <william@yossarian.net>

* docs: fix ClientVerifier

Signed-off-by: William Woodruff <william@yossarian.net>

* verification: replace match with if

Signed-off-by: William Woodruff <william@yossarian.net>

* return GNs directly, not whole extension

Signed-off-by: William Woodruff <william@yossarian.net>

* docs/verification: document UnsupportedGeneralNameType raise

Signed-off-by: William Woodruff <william@yossarian.net>

* lib: RFC822 checks on NCs

* test_limbo: enable client tests

* tests: flake

* test_verification: more Python API coverage

* verification: filter GNs by NC support

* verification: forbid unsupported NC GNs

This is what we should have been doing originally, per
RFC 5280 4.2.1.10:

> If a name constraints extension that is marked as critical
> imposes constraints on a particular name form, and an instance of
> that name form appears in the subject field or subjectAltName
> extension of a subsequent certificate, then the application MUST
> either process the constraint or reject the certificate.

* docs/verification: remove old sentence

Signed-off-by: William Woodruff <william@yossarian.net>

* verification: ensure the right EKU for client/server paths

Signed-off-by: William Woodruff <william@yossarian.net>

* test_limbo: fixup EKU assertion

* verification: feedback

---------

Signed-off-by: William Woodruff <william@yossarian.net>
2024-03-20 21:00:00 -04:00
Alex Gaynor
dcf6ac240d
Updates for ruff 0.3.1 (#10548) 2024-03-07 10:57:37 -08:00
Facundo Tuesca
0a1098fcf0
Support for ECDSA deterministic signing (RFC 6979) (#10369)
* Add support for deterministic ECDSA (RFC 6979)
2024-02-26 19:13:47 +00:00
Alex Gaynor
43b8b7910d
Raise MSRV to 1.65 (#10481) 2024-02-25 23:04:40 +00:00
Facundo Tuesca
c97808ca77
Add test vectors for deterministic ECDSA (RFC6979) (#10438) 2024-02-20 06:57:07 -08:00
Paul Kehrer
608ce9520f
add RC2-128-CBC vector (#10402)
vector created using golang's x/crypto internal impl and verified
against openssl
2024-02-16 22:20:14 -05:00
Paul Kehrer
ccd392ed50
mark ARC4 and TripleDES with the right version added for decrepit (#10325) 2024-02-02 03:41:25 +00:00
Paul Kehrer
c7ec8a6eed
fix decrepit example (#10324)
* fix decrepit example

* Update docs/hazmat/decrepit/ciphers.rst

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

---------

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2024-02-02 03:33:48 +00:00
Paul Kehrer
fd46c01cac
Update install docs (#10309)
We also test OpenSSL 3.2
2024-01-31 12:09:22 +00:00
Paul Kehrer
722a6393e6
migrate ARC4 and TripleDES to decrepit (#10286) 2024-01-29 19:42:21 -05:00
Paul Kehrer
1729edef70
add decrepit namespace and put SEED, IDEA, Blowfish, and CAST5 in it (#10284) 2024-01-28 17:34:33 -05:00
Paul Kehrer
98d764801d
increase toctree depth on primitives (#10282)
this makes the landing page for hazmat/primtives in the docs much more
useful.
2024-01-28 15:40:02 -05:00
Paul Kehrer
3da3a3703b
support bytes-like consistently across our asym sign/verify APIs (#10260)
and update our docs to show it as well
2024-01-25 21:09:27 +00:00
Paul Kehrer
08b24d87a6
explicitly support bytes-like for signature/data in RSA sign/verify (#10259)
this was never documented but previously worked in <42. we now also
document that this is supported to confuse ourselves less.
2024-01-25 19:51:59 +00:00
Paul Kehrer
075925fd55
allow SPKI RSA keys to be parsed even if they have an incorrect delimiter (#10248)
* allow SPKI RSA keys to be parsed even if they have an incorrect delimiter

This allows RSA SPKI keys (typically delimited with PUBLIC KEY) to be parsed
even if they are using the RSA PUBLIC KEY delimiter.

* formatting

* use original error if nothing parses, don't let it parse non-RSA
2024-01-25 01:54:23 +00:00
Hacksawfred3232
bd0a0648a8
Added warning about SHA1 being used for response signing in ocsp.rst (#10204)
* Update ocsp.rst

Added warning about SHA1 being used for sign()

* Update ocsp.rst

Fixed spelling issues, at least according to en-GB dictionary.

* Update ocsp.rst

Spell checker didn't catch "algorithim" somehow.

* Update ocsp.rst

Attempting to rephrase the warning.

* Update ocsp.rst

Removing rouge space.
2024-01-19 01:26:45 +00:00
Alex Gaynor
ad4ba0af95
Develop a local nox target (#10173)
This formats code, runs linters, and tests.

And it does these in an order that's optimized for fast local feedback
2024-01-14 20:43:55 -02:00
William Woodruff
a1ed534adb
docs/x509: fix verification example (#10169)
* docs/x509: fix verification example

Signed-off-by: William Woodruff <william@trailofbits.com>

* x509/verification: doctest

Signed-off-by: William Woodruff <william@trailofbits.com>

---------

Signed-off-by: William Woodruff <william@trailofbits.com>
2024-01-12 21:05:59 +00:00
Paul Kehrer
30e5ee2493
add some more EC vectors (#10134) 2024-01-05 18:03:57 +00:00
Alex Gaynor
e31a34398e
Another test case for explicit parameter private key (#10132) 2024-01-05 12:57:12 -03:00