Commit graph

2383 commits

Author SHA1 Message Date
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
d8f6635a01
nit: remove stray space (#7429) 2022-07-17 09:25:10 -05:00
Alex Gaynor
cab8f94fe5
Update things for 2022 (#7413) 2022-07-10 13:27:18 -05:00
Alex Gaynor
0c88afb12d
Added OCB vectors from openssl (#7401) 2022-07-05 15:30:02 +00:00
Alex Gaynor
0f81490c7f
Added vectors for long form tags (#7396) 2022-07-04 16:56:07 +00:00
Felix Dreissig
2bd0dda700
docs: Fix type returned by get_extension_for_oid() and get_extension_for_class() (#7380)
The previous wording (to me) sounded as if an instance of the specific
`ExtensionType` subclass would be returned.
But the methods actually return an `Extension` instance, from which the
specific `ExtensionType` instance can be accessed through the `value`
property.
2022-06-28 11:26:36 +00: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
Alex Gaynor
ba5701f4ed
Update installation docs (#7310)
RHEL/CentOS 8 should work fine with these instructions
2022-06-05 05:00:30 +08:00
William Woodruff
c1b7307a3e
X.509/Certificate: Add tbs_precertificate_bytes property (#7279)
* Add `tbs_precertificate_bytes` property

* docs/x509: document `tbs_precertificate_bytes`

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

* tests/x509: add two trivial tests

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

* x509/base: fix lint

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

* oid: add CERTIFICATE_TRANSPARENCY (1.3.6.1.4.1.11129.2.4.4)

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

* hazmat/oid: rehome CERTIFICATE_TRANSPARENCY under ExtendedKeyUsageOID

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

* docs/x509: fix link, help the spellchecker

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

* x509: Raise ValueError when we can't filter SCT list extension

* tests: Expect a `ValueError` when accessing `tbs_precertificate_bytes`
in default example

* tests, vectors: Add TBS precert vector for test comparison

* docs/x509: document the `CERTIFICATE_TRANSPARENCY` OID

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

* docs/x509: elaborate `tbs_precertificate_bytes`

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

* rust/x509: remove unused OID

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

* x509/certificate: tweak error

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

* tests/x509: reorganize

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

* Update src/rust/src/x509/certificate.rs

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

* tests/x509: more reorg, rename

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

* docs: document new testvector

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

* docs: coax the spellchecker

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

* tests/x509: use a cert that doesn't require SHA-1

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

* tests/x509: test for no extensions at all

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

Co-authored-by: Alex Cameron <asc@tetsuo.sh>
Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2022-05-31 22:51:32 +00:00
Alex Gaynor
d89cd38afa
Enforce that CRL and CSR versions must be valid. (#7249)
Fixes #7231
2022-05-22 23:31:47 +00:00
Alex Gaynor
1407dd6339
Added vectors for invalid CSR/CRL versions (#7247)
* Added vectors for invalid CSR/CRL versions

* 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>
2022-05-22 22:52:32 +00:00
William Woodruff
e2ef761b4e
CT: extensions -> extension_bytes (#7238)
Signed-off-by: William Woodruff <william@trailofbits.com>
2022-05-19 21:48:41 +00:00
William Woodruff
e087b3e33c
CT: add SignedCertificateTimestamp.extensions (#7237)
Signed-off-by: William Woodruff <william@trailofbits.com>
2022-05-20 04:15:16 +08:00
Alex Gaynor
bf56c57c44
Remove vestiges of doc8 (#7233)
We don't use it since 1eccc52b63
2022-05-18 00:15:36 +00:00
Alex Gaynor
94cc3865df
Update install docs now that we test on Windows 2022 (#7230)
* Update install docs now that we test on Windows 2022

* Update installation.rst

* Update spelling_wordlist.txt

* Update docs/installation.rst

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

Co-authored-by: Paul Kehrer <paul.l.kehrer@gmail.com>
2022-05-17 19:38:31 +00:00
William Woodruff
b9f4ca35b5
x509/CT: expose more SCT internals (#7207)
* WIP

* x509: remove TBS work for now

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

* CT: flake8

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

* CT: remove TODO, add links

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

* CT/SCT: strong enums for HashAlgorithm and SignatureAlgorithm

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

* tests: add SCT hash/signature algorithm tests

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

* tests: fix SignatureAlgorithm test, add signature contents test

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

* rust: unit tests for {Hash,Signature}Algorithm

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

* x509/sct: code coverage shenanigans

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

* asn1, sct: pesky coverage

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

* x509/sct: simplify parsing

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

* docs: document new SCT APIs

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

* docs: add refs to RFC 5246

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

* SCT: forbid nonsense hash and signature algos

No tests, yet.

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

* tests: add invalid hash/sig algo tests

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

* sct: remove ToAttr trait

Inline impl into each struct's impl.

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

* sct: remove invalid hash/sig variants

These should never appear in the context of SCTs.

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

* sct: collapse matches

Handle invalid/unknown variants together.

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

* tests: update SCT tests

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

* sct: add a TODO

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

* sct: return a primitives.hashes object instead of a custom enum

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

Co-authored-by: Alex Cameron <asc@tetsuo.sh>
2022-05-13 20:42:27 +00:00
William Woodruff
6fe0aaf95a
docs, vectors: add two more x509 SCT testvectors (#7215)
Signed-off-by: William Woodruff <william@yossarian.net>
2022-05-12 17:40:47 -04:00
David Benjamin
1cc43f1886
Fix test CRLs and CSRs with invalid versions (#7216)
CRL versions only go up to v2 (numeric value 1) and CSRs only define v1
(numeric value 0). See
https://www.rfc-editor.org/rfc/rfc5280.html#section-5.1 and
https://www.rfc-editor.org/rfc/rfc2986.html#section-4. Some of the
inputs used in tests were misissued.

Unfortunately, the corresponding private keys for these test vectors
weren't provided, so I've just editted the inputs with der-ascii and
left the signatures invalid. The tests in question don't seem to rely on
valid signatures.
2022-05-12 19:50:43 +00:00
Yang Yang
387048108e
Doc: Add parameter nonce for class ChaCha20 (#7202) 2022-05-07 09:59:31 +00:00
Paul Kehrer
895a07abf2
add x509 pss certificate and public key (#7161)
* add x509 pss certificate and public key

the cert is signed using rsa_pss_2048.pem and the public key is the
public components of that private key

* Update docs/development/test-vectors.rst

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

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2022-04-30 21:04:37 +00:00
Alex Gaynor
b2dc8a7228
Fixes #7127 -- added attr_name_overrides on from_rfc4514_string (#7160) 2022-04-30 20:38:47 +00:00
Robert Coup
a2a9109251
Allow Fernet decryption to accept string tokens (#7116)
* tests: better testid generation for fernet vectors

Use the vector filename and array index for the pytest id rather than a
concatenation of the vector content.

eg: `tests/test_fernet.py::TestFernet::test_invalid[invalid.json:2]`

* (Multi)Fernet: allow str tokens for decryption

Remove some developer friction by allowing string tokens to be passed to
Fernet decryption methods. Because a valid token as generated by
`Fernet.encrypt()` is url-safe base64-encoded, a non-ASCII token is
definitely invalid.

The stdlib base64 function already accepts and checks ASCII str values
so delegate to that.

* Kick CI
2022-04-29 22:27:47 +00:00
Alex Gaynor
bc00e8d676
Bump MSRV to 1.48.0 (#7128) 2022-04-27 13:47:46 +00:00
Alex Gaynor
4d58800fb7
Drop manylinux2010 (#6694)
It has very low usage
2022-04-26 19:31:00 +00:00
Robert Coup
2c3404b56b
docs: fix linting tox env name (#7117) 2022-04-26 18:09:12 +00:00
Alex Gaynor
1de0ea922e
Remove trailing white space in docs (#7115)
Apparently none of our linters care
2022-04-26 13:00:13 +00:00
Paul Kehrer
3b9a11b6d2
add RSA PSS test vectors (#7086) 2022-04-17 08:20:32 -05: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
0724c5f1ee
check for invalid keys that RSA_check_key misses (#7080)
* check for invalid keys that RSA_check_key misses

RSA_check_key checks for primality but that fails to catch this case
since 2 is prime. Instead we fetch p and q and verify that they are odd
and if not reject the key as invalid.

* circleci sucks
2022-04-16 13:55:01 +00:00
Alex Gaynor
f3f695b1c1
Implement a parser for RFC4514 strings (#7055)
* Initial tests

* Implement.

Required updating many many tests based on my read of the RFC. Should be reviewed closely.

* Fix for py36

* flake8

* Improve coverage on hypothesis test

* Remove bad assertion in hypothesis test

* Update docs

* fix docs

* Fixed unicode support

* review

* docs review
2022-04-16 10:21:45 +02:00
Alex Gaynor
dc989d563a
Added Ubuntu Jammy to CI (#7047)
* Added Ubuntu Jammy to CI

* try thing
2022-04-07 02:15:09 -05:00
Dustin Ingram
033514708e
Fix indentation in docs/x509/reference.rst (#7044) 2022-04-05 21:11:10 +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
00c61b9537
update pkcs7 test vectors (#7030)
* update pkcs7 test vectors

* this is a word
2022-04-03 09:11:54 -04: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
Paul Kehrer
4a4f4d94ce
OCB3 test vectors for 104, 112, and 120-bit nonces (#7009) 2022-03-29 07:09:07 -04: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
Alex Gaynor
3714686044
Don't reference unsupported version in installation docs (#6946) 2022-03-13 05:21:45 +08:00
sanchayanghosh
9790f943df
Added OID for #6920 (#6925)
* Added OID

* Added to docuemntation for IPSec SAs

* Update docs/x509/reference.rst to correct the version change.

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

Co-authored-by: Paul Kehrer <paul.l.kehrer@gmail.com>
2022-03-03 07:11:46 +00: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
Alex Gaynor
06e57ce62d
refs #6835 -- added oid constants for SHA3 signatures (#6850) 2022-02-07 16:38:07 -10:00
Alex Gaynor
3e0870468c
Test against Alpine on aarch64 (#6846)
* Test against Alpine on aarch64

* Update config.yml

* Update installation.rst

* Update config.yml
2022-02-06 22:32:16 -06:00
Alex Gaynor
7513197fc6
fixes #6804 -- improve error message quality with invalid characters in name attributes (#6843) 2022-02-06 21:42:56 -06:00
Alex Gaynor
05fa9c9833
Switch from centos to rhel in CI (#6844)
* Switch from centos to rhel in CI

* Update installation.rst

* Update installation.rst
2022-02-06 17:51:12 +00:00
Alex Gaynor
c9ac2c86d7
Remove FAQ that's no longer relevant (#6833)
We don't use environment markers anymore, now if you have a really old setuptools you get some different failure mode
2022-01-30 20:22:59 -08:00
Alex Gaynor
8114b3e61d
point to the AEAD version of GCM in the FAQ (#6832) 2022-01-31 01:55:42 +00:00