Commit graph

1052 commits

Author SHA1 Message Date
Alex Gaynor
da45641e46
Convert PKCS7PaddingContext to Rust (#11089) 2024-06-10 12:22:36 -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
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
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
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
Alex Gaynor
6e106f5584
Update various links in the docs for permanent redirects (#10109) 2024-01-02 21:00:20 -03:00
Alex Gaynor
9e866cc50d
Update various links in the docs for permanent redirects (#10098) 2023-12-31 17:56:51 -03:00
Facundo Tuesca
ca4f40621d
Add support for AES-GCM-SIV using OpenSSL>=3.2.0 (#9843) 2023-12-02 09:39:19 -06:00
Paul Kehrer
e958374785
add support for signing PKCS7 using RSA PSS (#9829)
* add support for signing PKCS7 using RSA PSS

* mypy fixes
2023-11-04 04:59:39 +00:00
McCoy Patiño
da21e9670b
Add algorithm/MGF properties to asymmetric paddings (#9582)
* Add properties

* Update documentation

* Add tests

* Line length; Expose MGF class

* Remove unnecessary flags
2023-09-11 19:58:01 -04:00
Paul Kehrer
b2abc35bda
fix another NIST link (#9270) 2023-07-20 20:27:44 +00:00
Paul Kehrer
c5c99b2d1c
fix a link from the NIST CSRC migration (#9267) 2023-07-20 06:07:58 -04:00
Facundo Tuesca
f4b7707af5
Fixes for ChaCha20 documentation (#9192)
* Restore missing section from ChaCha20 docs

This change fixes the indentation of a note inside the ChaCha20
section of the docs, which caused the note to not render in the
resulting HTML.

* Fix ChaCha20 docs to specify non RFC-compliance

Currently, cryptography uses OpenSSL's ChaCha20 implementation,
which is based on the original algorithm designed by Daniel J.
Bernstein rather than the later standardized version (RFC 7539).

Since the documentation does not reflect this (it describes the RFC
version of the algorithm, rather than the original version we use),
this change fixes that.

* Remove random counter from ChaCha20 example docs

This changes the ChaCha20 example in the documentation to use a
normal user-defined variable for the counter part of the nonce,
rather than a randomized counter.
2023-07-07 10:59:23 -05:00
Alex Gaynor
c52e192ed8
Update link (#9102) 2023-06-21 06:22:44 +02:00
Paul Kehrer
31436a4866
admit to the existence of nuance in HKDF (#8987)
* admit to the existence of nuance in HKDF

* Update docs/hazmat/primitives/key-derivation-functions.rst

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

---------

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2023-05-30 02:32:57 +00:00
Paul Kehrer
49dee344a1
update MAC docs (#8777)
* Update hmac.rst

* Update poly1305.rst
2023-04-21 16:04:45 -06:00
Paul Kehrer
7d3f8a43d4
we made WithSerialization an alias to the main types long ago (#8698)
stop documenting them entirely
2023-04-10 00:13:55 -04: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
Marty Hill
a28ad12125
Update serialization.rst (#8464)
Proposed update to parameter in example call to pkcs12.serialize_key_and_certificates() on line 908.
2023-03-06 08:26:20 -05:00
Alex Gaynor
94debb12c6
fixes #8374 -- removed docs for removed method (#8377)
* fixes #8374 -- removed docs for removed method

* Update CHANGELOG.rst
2023-02-22 08:08:33 -06: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
Jake
50fec7e541
Fix SSHCertificateBuilder sample code (#8373)
Update SSHCertificateBuilder sample code to:
* Correctly use the signing key when signing the certificate, rather than the user's own private key.
* Generate the user's public key in one line, making it clearer to the reader that only the public key is an input to the certificate builder.
2023-02-22 07:03:26 -05:00
Paul Kehrer
5a34d492bc
embrace my inner nitpicker (#8361)
fixes all our versionadded/changed to match actual versions we released
2023-02-20 23:57:08 +00:00
Mat
b467358344
add support for bytes-like objects in data and associated_data in aead algorithms (#8187)
* add support for bytes-like objects in data and associated_data in aead algorithms

* flake

* flake again

* rework AESSIV _check_params

* flake and 80char columns

* associated_data cannot be None in _check_params, set to [] in calling function

* Update src/cryptography/hazmat/primitives/ciphers/aead.py

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

* flake fix

---------

Co-authored-by: mat gas <none@none.com>
Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2023-02-02 13:56:49 +00:00
Paul Kehrer
17da400b65
deprecate the rest of DSA support for SSH (#8013)
* deprecate the rest of DSA support for SSH

* review comments
2023-01-09 01:14:00 +00:00
Paul Kehrer
5c48b8917a
more rigorously document that our verify methods return none (#8010)
they raise an exception!
2023-01-08 08:59:47 -05:00
Paul Kehrer
79937e9242
switch to using integers for valid_after/valid_before in SSH certs (#8007)
* switch to using integers for valid_after/valid_before in SSH certs

* i know this, it's a unix timestamp

* one more review nit
2023-01-08 03:29:05 +00:00
Paul Kehrer
1b4ad81ff3
SSHCertificateBuilder (#8004)
* SSHCertificateBuilder

This adds support for generating SSH certificates

* add deterministic signing tests and valid_for_all_principals

* test another edge

* one of these two fixes makes no sense
2023-01-08 01:08:22 +00:00
Paul Kehrer
aca8de845e
support SSH certificate parsing (#7960)
* support SSH certificate parsing

DSA (deliberately) not supported

* make a unified API

* Update src/cryptography/hazmat/primitives/serialization/ssh.py

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

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2023-01-07 01:27:25 +00:00
Alex Gaynor
438f78179c
Typo fixes (#7942) 2022-12-28 06:40:50 +07:00
Mathias Ertl
75cb14730f
add canonical names to Sphinx class documentation (#7938) 2022-12-26 19:26:44 +00:00
April King
6f6b58d941
Update code to match Django recommendations (#7932) 2022-12-23 17:31:03 +00:00
Alex Gaynor
ae38e5f1e1
remove reference to raising NotImplementedError in update_into (#7781)
this hasn't happened in a long time
2022-11-07 04:58:02 +08:00
Paul Kehrer
34412de1b2
more warnings and context around RSA online decryption (#7699) 2022-10-12 11:14:56 -04:00
Paul Kehrer
01687d63a5
add unsafe_skip_rsa_key_validation (#7667)
* add unsafe_skip_rsa_key_validation

This allows users to skip RSA key validation when calling
load_pem_private_key, load_der_private_key, and
RSAPrivateNumbers.private_key. This is a significant performance
improvement but is **only safe if you know the key is valid**. If you
use this when the key is invalid OpenSSL makes no guarantees about what
might happen. Infinite loops, crashes, and all manner of terrible things
become possible if that occurs. Beware, beware, beware.

* Apply suggestions from code review

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

* remove unneeded variable

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2022-10-03 14:29:45 +00:00
sec00re
49d1e4f53c
docs: update of ChaCha20 specification in hazmat (#7622)
* docs: update of ChaCha20 specification in hazmat

Clarification of the term nonce, because it is not clear to the user that is the concatenation of 4-byte counter and 12-byte nonce. That is important for compatibility with other implementations.

* docs: reformat of ChaCha20 specification

* Update docs/hazmat/primitives/symmetric-encryption.rst

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

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2022-09-18 09:37:17 -04:00
Alex Gaynor
8bc691f580
fix comment, no version of openssl has these (#7596) 2022-09-11 16:22:15 +00:00
Alex Gaynor
1bc3d1c43d
Fix linkcheck -- ignore expired cert on SM3 website (#7583) 2022-09-09 23:07:36 +00:00
Paul Kehrer
1742975367
support setting more PKCS12 serialization encryption options (#7560)
* support setting more PKCS12 serialization encryption options

This is limited support, but makes it possible to set two different PBES
choices as well as set KDF rounds and MAC algorithm

* Apply suggestions from code review

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

* review feedback redux

* Update docs/hazmat/primitives/asymmetric/serialization.rst

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

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2022-09-05 12:25:19 +00:00
Paul Kehrer
2bb6785aef
add AES128/AES256 classes (#7542)
These let developers be more explicit about the allowable key lengths
for an AES key and make auditing the codebase a bit easier.

But that's not really why we're adding them. In some upcoming
serialization features we need to be able to specify AES 128 vs AES 256
and the current class doesn't work for that since it computes key
length from the key you provide it when instantiating the class.
That's incompatible with serialization where the key is derived
later in the process. C'est la vie.
2022-08-26 00:19:12 -04:00
Alex Gaynor
bfd88da7f2
PoC for making key serialization more configurable (#7520) 2022-08-22 11:22:01 +08:00
Jean Paul Galea
2477a09405
docs: add missing backquote (#7517) 2022-08-16 12:09:03 -05:00
Jean Paul Galea
da1a30b4ea
KBKDF: add CounterLocation.MiddleFixed (#7489)
* KBKDF: add CounterLocation.MiddleFixed

* tests_kbkdf: add new tests

- Test CounterLocation.MiddleFixed and blocation=

* test_kbkdf_vectors: make use of MIDDLE_FIXED

* docs: document KBKDF CounterLocation.MiddleFixed

* s/blocation/break_location/g

* CHANGELOG: document KBKDF{HMAC,CMAC} CounterLocation.MiddleFixed #7489

* kbkdf: fixed is static across n iterations, only the counter changes

* kbkdf: check break_location is 0..len(fixed)

- Update tests to assert exception is raised when
    break_location < 0 or > len(fixed)

- When asserting for "break_location is ignored when MiddleFixed",
    use break_location=0 instead of =10,
    to ensure we don't raise because of break_location > len(fixed)

- Assert that the right error messages are returned to the user.

* kbkdf: keyword-only break_location

* docs: document kw-only KBKDF{HMAC,CMAC}
2022-08-15 08:19:12 -04:00
Alex Gaynor
87d7e60c19
update link in docs (#7485) 2022-08-05 17:59:14 -10:00
Alex Gaynor
c6b121d321
Point people at AEADs in symmetric encryption docs (#7326) 2022-06-10 08:48:02 +08:00