Commit graph

1014 commits

Author SHA1 Message Date
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
Paul Kehrer
b4cf8acc72
add note that load_pem_private_key is the wrong func for SSH keys (#7315) 2022-06-06 02:11:03 +00:00
Yang Yang
387048108e
Doc: Add parameter nonce for class ChaCha20 (#7202) 2022-05-07 09:59:31 +00:00
Paul Kehrer
19546b9ccc
Add support for PSS.AUTO and PSS.DIGEST_LENGTH (#7082)
* add PSS auto support for verification

* add support for PSS.DIGEST_LENGTH

* review comments
2022-04-16 15:16:25 +00:00
Paul Kehrer
7659fe4fd6
serialize certs to pkcs7 (#7034)
* serialize certs to pkcs7

* missed assert
2022-04-04 02:14:14 +00:00
Paul Kehrer
74e4202bd1
SIV support (#7029)
* SIV support

* empty commit to see if codecov sees the 3.0 coverage this time
2022-04-02 23:44:01 -04:00
Paul Kehrer
25cdad7d07
support 12-15 byte nonce sizes in OCB3 (#7011)
* support 12-15 byte nonce sizes in OCB3

* Update tests/hazmat/primitives/test_aead.py

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

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2022-03-29 12:00:28 +00:00
ajoino
9d357cffb7
Serialize PKCS12 CA alias/friendlyName (#6910)
* PKCS12 serialization wrapper supports PKCS12Certificate cas

* Added code from Felix's gist to serialize_key_and_certificate_to_pkcs12. Doesn't break current behaviour/tests, need to write validate new behaviour, write tests, and format code.

* Simplified instance check

* Tried to write tests, but I cannot figure out how to read the friendlyName from parsed_more_certs.

* Fixed test function and renamed it.

* Fixed formatting.

* Commiting before trying black

* Formatted updates to make flake8 and black happy.

* Fixed first review comments.

* remove forgotten print statement

* use backend.openssl_assert instead of if ...

* Documented changes.

* Updated documentation.
2022-03-29 07:03:09 -04:00
whiteowl3
fa75d77410
allow ed pk12, better tests (#6865)
* dont block pk12 serialization of ed pairs

* mimic test_ec curve skipping to satisfy alpine ci
2022-02-27 07:15:49 +08:00
April King
5ac3fdc46c
Found another place where ancient PBKDF2 iterations were listed (#6816) 2022-01-24 22:44:10 +00:00
Natalia Maximo
e91d3047e9
fix: fixed confusing typo on DSA docs (#6662) 2021-11-27 00:15:38 +00:00
Paul Kehrer
ffb40e6228
OCB3 support (#6607)
* OCB3 support in aead package

* improve comment
2021-11-14 23:10:06 -05:00
Paul Kehrer
7a2823bdff
deprecate backend part 6 of n (#6524) 2021-11-03 18:51:23 -04:00
Paul Kehrer
1eccc52b63
deprecate backend part 5 of n (#6523)
* deprecate backend part 5 of n

* remove doc8
2021-11-03 07:22:58 -04:00
Paul Kehrer
e333fa3279
deprecate backend part 4 of n (#6522) 2021-11-02 17:49:25 -04:00
Paul Kehrer
1040b39be5
deprecate backend part 3 of n (#6521)
finish the asymmetric docs
2021-11-02 17:48:18 -04:00
Paul Kehrer
dcf82c6c00
deprecate backend part 2 of n (#6518) 2021-11-02 12:14:45 +00:00
Alex Gaynor
9275fd07e3
Convert CRL creation to Rust (#6496)
* Convert CRL creation to Rust

* fixes

* small reflows

* Delete all teh code

* flake8
2021-10-31 05:40:28 +08:00
Alex Gaynor
2336005c51
Convert CSR creation to Rust (#6495)
* Convert CSR creation to Rust

* put this back

* unused

* coverage
2021-10-31 05:10:26 +08:00
Alex Gaynor
362877989e
remove docs for removed backend methods (#6493) 2021-10-29 12:30:48 +00:00
Alex Gaynor
2f244d826d
Convert x.509 certificate generation to Rust (#6479)
* Convert x.509 certificate generation to Rust

* flake8

* Coverage shenangins

* moar hashes

* moar hashes
2021-10-29 18:11:26 +08:00
Alex Gaynor
6765d4efe2
fixes #6486 -- update the bounds on how much data AEADs can handle (#6488) 2021-10-28 20:45:21 +08:00
Felix Fontein
17aeaa6f60
PKCS12: return 'friendly name' with PKCS12KeyAndCertificates API (#6348)
* Propose a new load_key_and_certificates_with_name API to return the PKCS12 'friendly name' as well.

* Extend load_key_and_certificates_with_name to return friendly names for all certificates; add serialize_key_and_certificates_with_names; add X509_alias_set1 to cffi; add basic tests for all these.

* Add changelog entry and documentation.

* Revert "Extend load_key_and_certificates_with_name to return friendly names for all certificates; add serialize_key_and_certificates_with_names; add X509_alias_set1 to cffi; add basic tests for all these."

This reverts commit 125935e8cf1d27028c5b593bb058e2716311fd72.

* Create new interface.

* Rename load_key_and_certificates_object -> load_pkcs12.

* Add constructor validation, improve repr tests.

* Mention '... or None'.

* Allow all private key types.

* Fix/improve tests.

* Ignore type errors when intentionally passing wrong types.

* Fix type; linting.

* Use correct ignore.
2021-10-06 17:04:36 +08:00
kjackiewicz
5dfda63a97
Implement KBKDFCMAC (#6181)
* Implement KBKDFCMAC

Also adjust KBKDFHMAC to avoid code duplication.

* Add KBKDFCMAC unit tests

* Enable KBKDFCMAC vector tests

* Fix doc8 too long line issue in changelog

Adding bullet list entries after line 30 in the CHANGELOG.rst leads to
doc8 D001 error in line 30. Looks like a doc8 bug. Breaking the line in
the middle of the cross-reference solves the problem for now.

Also replace the trailing comma with a dot.

* Add KBKDFCMAC documentation and update changelog
2021-09-03 15:40:27 -07:00
match man
cd4ae74ef1
Add more demonstrative code to examples (#6234)
1. In signature generation code example, add a `key' assignment so it can be run solely.
2. In verify() code example, add a positive case before the negative one. Also use copy() to do self authentication.

Co-authored-by: Baofeng Wang <baofeng.wang67@gmail.com>
2021-08-29 08:45:19 -05:00
Paul Kehrer
db650fbc78
fix OAEP pdf link (#6195) 2021-08-08 13:13:44 -04:00
Paul Kehrer
87f43fb77e
parse certificates with pure rust (#6147)
* parse certificates with pure rust

* fix coverage

* various review comments

* save the buffer

* more feedback
2021-07-25 18:03:14 -04:00
Benjamin Peterson
37103b3b65
Remove straddling jargon "text". (#6067) 2021-05-25 13:16:36 -05:00
Yang Yang
0c4caa295e
Fix typo: ANSI X.923 to ANSI X9.23 (#5989) 2021-04-20 07:31:31 -04:00
Paul Kehrer
6f7a5fd9e9
properly document the return of load_ssh_private_key (#5927)
fixes #5862
2021-03-21 20:05:57 -04:00
Paul Kehrer
bd63f3a1a4
document that we support more keys in our asymmetric loaders. (#5926)
fixes #5911
2021-03-21 20:05:37 -04:00
Ajitomi, Daisuke
8ca4d5a014
Add exceptions to Ed25519PrivateKey and Edd25519PublicKey methods. (#5898) 2021-03-07 12:50:20 -06:00
Paul Kehrer
bdca10e3f7
tell people SM3/SM4 are available for compat/compliance reasons (#5878)
* tell people SM3/SM4 are available for compat/compliance reasons

* add to changelog and linkcheck fix

* tweaked language
2021-02-28 16:26:12 -05:00
tobyp
f69f27b1dd
Add SM4 symmetric block cipher (#5834)
Co-authored-by: Tobias Peter <tobias.peter@infineon.com>
2021-02-28 13:57:50 -06:00
tobyp
0cb83aeb71
Add SM3 hash algorithm (#5833)
Co-authored-by: Tobias Peter <tobias.peter@infineon.com>
2021-02-28 13:19:44 -06:00
Paul Kehrer
a98e708d45
remove DSAParametersWithNumbers (#5724)
Merged into DSAParameters, just like we did years ago for everything
else. Somehow we missed this one.
2021-01-31 17:24:37 -05:00
Paul Kehrer
6a8c0b55b9
make PrivateKeyWithSerialization an alias of PrivateKey (#5722)
* make PrivateKeyWithSerialization an alias of PrivateKey

* black
2021-01-31 11:37:26 -05:00
Chkoupinator
928262531c
Added information on what encrypt raises (#5686)
* Added information on what encrypt raises

Added a note on RSA's Encrypt explanation for newcomers such as myself, so that they don't have to waste 4 hours trying to figure out what is causing the ValueError like I did 😅

* Moved the note under the raises ValueError section

* Removed whitespaces causing issues

* Update rsa.rst

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

Co-authored-by: Paul Kehrer <paul.l.kehrer@gmail.com>

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
Co-authored-by: Paul Kehrer <paul.l.kehrer@gmail.com>
2021-01-09 11:08:26 -06:00
Paul Kehrer
08afd16f28
we didn't actually commit the final doc fixes for the recover PR (#5614) 2020-12-09 10:04:20 -05:00