Commit graph

2637 commits

Author SHA1 Message Date
David Buchanan
45da8087ab
fernet.rst: modernize password key derivation advice (#12409)
replace mention of bcrypt (which isn't supported by pyca/cryptography) with Argon2id
2025-02-06 06:30:50 -08:00
Alex Gaynor
3d4eb5f7a4
Added a test for RC2-CBC with an effectiveKeyLength (#12404)
* Added a test for RC2-CBC with an effectiveKeyLength

* Update docs/development/test-vectors.rst

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

---------

Co-authored-by: Paul Kehrer <paul.l.kehrer@gmail.com>
2025-02-06 00:52:22 +00:00
Paul Kehrer
6377a5ec0b
add a bunch of pkcs8 test vectors (#12396)
* add a bunch of pkcs8 test vectors

these are encrypted PKCS8 keys for various parameters we haven't
explicitly tested in the past

* I hate the spellchecker so much
2025-02-04 23:57:42 +00:00
Tanmay Ghai
938c6881d7
updated CertificateBuilder docs (#12386) 2025-02-04 02:33:18 +00:00
Paul Kehrer
0ef7c1fa19
add XOFHash (#12380)
* add XOFHash

* refactors for comments

* use cfg_if

* fix docs, fix linting

* don't expose squeeze on unsupported things

* smaller strides

* ellipsis
2025-02-01 17:26:59 -08:00
Paul Kehrer
d20eea8809
raise ValueError if DH parameter numbers are invalid (#12373) 2025-01-31 23:34:21 +00:00
Alex Gaynor
fe5f3a9217
Two more testscases for key loading (#12370)
* Two more testscases for key loading

* Update tests/hazmat/primitives/test_serialization.py

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

---------

Co-authored-by: Paul Kehrer <paul.l.kehrer@gmail.com>
2025-01-31 18:20:31 +00:00
ohemorange
3b689cedb1
Update reference.rst:load_der_x509_certificate to note ValueError raised (#12364)
* Update reference.rst:load_der_x509_certificate to note error raised

It raises the error and therefore should be noted in the documentation.

```
>>> x509.load_der_x509_certificate(b64.b64decode("foobar".encode()))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: error parsing asn1 value: ParseError { kind: InvalidLength }
```

* Update docs/x509/reference.rst

Thanks!

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

---------

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2025-01-30 02:59:28 +00:00
Alex Gaynor
652867baaa
fixes #12307 -- added unsafe_skip_rsa_key_validation kwarg to ssh private key loading (#12342) 2025-01-25 17:29:54 +00:00
Alex Gaynor
023a2597ec
Added tests for various malformed PEM files (#12338) 2025-01-24 16:06:53 -08:00
Alex Gaynor
45381b4266
Added two new PKCS#8 test cases (#12333)
* Added two new PKCS#8 test cases

* Added two more testcases

* Spelling
2025-01-24 11:04:53 -08:00
Alex Gaynor
5d16313b42
Added tests for two more PKCS#8 key situations (#12310) 2025-01-19 08:04:56 -08:00
Alex Gaynor
17119de16f
Added new test cases for invalid EC keys (#12309) 2025-01-18 20:03:57 -08:00
Alex Gaynor
af76c1f456
Added more serialization test vector tests (#12308) 2025-01-18 12:22:22 -08:00
Alex Gaynor
86b24873c7
Added new test cases for PKCS#8 parsing (#12305) 2025-01-17 20:00:29 -08:00
Anton Hvornum
4c9ef892db
Corrected the documented intent of the HKDFExpand.derive() function so that it clearly states only expand is performed, and not extract and expand. (#12248) 2025-01-07 12:26:29 +00:00
MajorTanya
5f160b90fe
Update recommended PBKDF2HMAC iteration counts (#12243)
This uses the current (as of 2025-01-07) default of 1,000,000
iterations used by Django.
2025-01-07 04:42:29 +00:00
Alex Gaynor
96dbd56065
Bump year for copyright (#12219) 2025-01-01 07:05:07 +01:00
Quentin Retourne
6143683d87
PKCS7: added encryption with AES-256-CBC (#12172)
* feat: added encryption with AES-256-CBC

added & updated tests accordingly

updated documentation

removed useless test vector

* fixing coverage

* last python coverage fix

* restraining the number of classes

changed name to content_encryption_algorithm

simplified the rust code accordingly

tried to simplify the documentation

* python 3.8 artefacts

* passed content encryption algo locally

adapted rust code accordingly
2024-12-29 13:02:20 -05:00
Brian Sipos
f6ee2a5106
Add RFC9174 OIDs (#12143)
* Add BUNDLE_SECURITY EKU

* Adding Other Name Form OIDs

* Adding public access to OtherNameFormOID

* Sorting names for lint

* Sort imports

* Fix format

* Adding OID docs

* Add specific next version
2024-12-13 19:17:50 +00:00
Alex Gaynor
ce4c5dfc23
test on centos stream 10 (#12145)
* test on centos stream 10

* Update ci.yml

* Update installation.rst
2024-12-13 08:19:33 -08:00
David Buchanan
4879672702
Add ec.EllipticCurve group_order constants (#12113)
* add ec.EllipticCurve group_order

* punctuation

* update docs
2024-12-10 08:10:36 +03:00
Alex Gaynor
6525eac13a
Use inline tabs in install docs (#12115) 2024-12-06 06:18:15 -08:00
Alex Gaynor
89422a5679
Adopt sphinx-inline-tabs (#12114)
Use it in one demo place to show how to install us with multiple installers
2024-12-06 05:40:49 -08:00
Paul Kehrer
235f991211
add new invalid EC key (#12103) 2024-12-04 23:36:45 -05:00
Quentin Retourne
ac8c3003cb
PKCS7 Decryption: more content decryption algorithms (#12088)
* pkcs7: added more content encryption algorithms

* removed creation of AES 192 algorithm

* remove AES 192 compat (historical relic)

* minor correction
2024-12-02 14:34:04 +00:00
Quentin Retourne
d6cac753c2
Add support for decrypting S/MIME messages (#11555)
* first python API proposition

first round-trip tests

feat: made asn1 structures readable

refacto: adapted existing functions accordingly

feat/pkcs12: added symmetric_decrypt

feat: deserialize 3 possible encodings

feat: handling AES-128

feat: raise error when no recipient is found

feat/pkcs7: added decanonicalize function

feat/asn1: added decode_der_data

feat/pkcs7: added smime_enveloped_decode

tests are the round-trip (encrypt & decrypt)

more tests for 100% python coverage

test support pkcs7_encrypt with openssl

added algorithm to pkcs7_encrypt signature

refacto: decrypt function is clearer

flow is more natural

refacto: added all rust error tests

refacto: added another CA chain for checking

fix: const handling

Refactor PKCS7Decryptor to pkcs7_decrypt

refacto: removed SMIME_ENVELOPED_DECODE from rust code

refacto: removed decode_der_data

adapted tests accordingly

removed the PEM tag check

added tests for smime_decnonicalize

one more test case

Update src/rust/src/pkcs7.rs

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

took comments into account

pem to der is now outside of decrypt

fix: removed test_support pkcs7_encrypt

added vector for aes_256_cbc encrypted pkcs7

feat: not using test_support decrypt anymore

added new vectors for PKCS7 tests

feat: using pkcs7 vectors

removed previous ones

fix: changed wrong function

feat: added certificate issuer check

test: generating the RSA chain

removed the vectors accordingly

moved symmetric_decrypt to pkcs7.rs

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

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

* fix: removed use of deprecated new_bound for PyBytes

* corrected some error types

* updated tests accordingly

* fix: handling other key encryption algorithms

added vectors & tests accordingly

* first attempts raising error when no header to remove

* one more test to handle text data without header

* fix: went back to the previous implementation

* refacto: removed the return part

* feat: Binary option does not seem useful for decryption

removed decanonicalization function

adapted tests accordingly

* moved logic into rust

only left some checks (for now?)

* removed pyfunction for the inner decrypt one

* added checks in rust now :)

changed name for clarity

* removed unused function

* some checks not needed anymore

* removed a parameter

* took comments into account

* removed unused import

removed excess get_type

* added first unwrap corrections

cleaned tests, added some others

added more vectors

* no more unwrap for parameter checks

* removing headers is Python now

added tests accordingly

will compare with OpenSSL

* final corrections?

* first version of documentation

some minor refactoring

* corrected doctests

* better indentation

* doctest: added RSA private key

* oops

---------

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2024-11-26 08:39:53 -05:00
Quentin Retourne
57401ba194
added vector with different key encryption algo (#11998)
adapted documentation accordingly
2024-11-19 06:44:21 -05:00
Oleg Höfling
74f262155d
chore: replace plaing hyperlinks to rfc sections with rfc roles with section argument (#11985)
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
2024-11-17 08:33:49 -05:00
Oleg Höfling
120583a073
docs(admissions): add documentation for the admissions extension (#11964)
* docs: add intersphinx refs for the admission types

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>

* chore: add types and description for the admissions fields and classes

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>

---------

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
2024-11-16 17:50:12 -05:00
Alex Gaynor
8209d63ae7
fixes #11944 -- don't panic on attributes with no values (#11947) 2024-11-14 14:16:43 -08:00
Paul Kehrer
a7aa8cec96
argon2id support (#11524)
* argon2id support

* make it all rust now

* set a threadpool number

* address comments

* set threadpool to max(available, current)

* review comments

* a few more improvements

* 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>
2024-11-11 14:42:26 +00:00
Alex Gaynor
da437d16a9
fixes #11920 raise a clean Python error on DSA signing failure due to nilpotent (#11921) 2024-11-11 14:37:32 +00:00
Oleg Höfling
fef127093b
feat(admissions): implement parsing of admissions extension (#11903)
* feat: implement parsing of admissions extension

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>

* chore: add tests for admissions extension parsing

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>

* chore: use cryptography result return type

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>

* chore: apply fixes done by cargo fmt and clippy

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>

* add gematik company name and the gmbh abbreviations to known words

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>

* fix: regenerate the synthetic certificate with additional admission covering the case of naming authority with no data

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>

* fix: parse none for profession_oids if profession_oids is none

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>

* chore: apply formatting to changes in rust codebase

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>

* refactor: switch return type of parse_profession_infos from PyObject to Bound<PyAny>

Signed-off-by: Oleg Hoefling <oleg.hoefling@gmail.com>

* refactor: switch return type of parse_naming_authority from PyObject to Bound<PyAny>

Signed-off-by: Oleg Hoefling <oleg.hoefling@gmail.com>

* refactor: switch return type of parse_admissions from PyObject to Bound<PyAny>

Signed-off-by: Oleg Hoefling <oleg.hoefling@gmail.com>

* chore: remove gematik certs from repo

Signed-off-by: Oleg Hoefling <oleg.hoefling@gmail.com>

* chore: remove gematik certs from this pr

Signed-off-by: Oleg Hoefling <oleg.hoefling@gmail.com>

* chore: extend parser tests with an additional synthetic certificate to complete rust coverage

Signed-off-by: Oleg Hoefling <oleg.hoefling@gmail.com>

* chore: add description for the additional certificate without authority

Signed-off-by: Oleg Hoefling <oleg.hoefling@gmail.com>

* use into_bound(py) as shortcut, refrain from using to_object() in all added functions

Signed-off-by: Oleg Hoefling <oleg.hoefling@gmail.com>

* add better description for the admissions synthetic cert

Signed-off-by: Oleg Hoefling <oleg.hoefling@gmail.com>

* adjust description to avoid using misspelled words

Signed-off-by: Oleg Hoefling <oleg.hoefling@gmail.com>

---------

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
Signed-off-by: Oleg Hoefling <oleg.hoefling@gmail.com>
2024-11-10 20:06:01 -05:00
Quentin Retourne
5b425ec416
added new vectors for PKCS7 tests (#11843)
* added new vectors for PKCS7 tests

* some corrections in the documentation

* removed RSA CA, not using it anymore
2024-11-05 22:29:26 +00:00
Alex Gaynor
8b3de53ed8
When failing to parse SANs or IANs, include which it was that failed (#11785) 2024-10-17 20:13:03 -07:00
Jiashuo Li
15e2125fb6
Update serialization.rst (#11746) 2024-10-10 12:52:25 +00:00
Ivan Desiatov
1767ad0a46
X509 custom verification groundwork (#11559)
* Add CustomPolicyBuilder foundation.

* Add EKU getters to ClientVerifier and ServerVerifier.

* Document the implemented part of custom verification.

* Remove `subject` field from VerifiedClient, rename `sans` back to `subjects`.

* Remove EKU-related setters, getters and documentation from this PR.

* Use double backticks in reStructuredText.

* Remove CustomPolicyBuilder in favor of extending PolicyBuilder.

* Code style improvements.

* Resolve coverage issues.
2024-10-08 22:27:15 -04:00
Alex Gaynor
06f3fdbfb3
fixed grammar in getting-started.rst (#11649) 2024-09-24 07:21:01 -07:00
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