Commit graph

6770 commits

Author SHA1 Message Date
Paul Kehrer
bd7cd2d43f faq entry for setuptools_ext issues (#3393) 2017-02-13 18:01:06 -08:00
AlexanderWeyman
979458830c Update tutorial.rst (#3394)
eliminated inconsitency of variable name in sample code
2017-02-13 10:00:19 +08:00
Aviv Palivoda
84cdca7aec Add EVP_PKEY_DHX (#3388)
* Add EVP_PKEY_DHX

* Add Cryptography_HAS_EVP_PKEY_DHX to _conditional.py
2017-02-13 08:59:16 +08:00
Paul Kehrer
f99e3f5c38 bump our latest pypy builds to use the latest pypy (#3391) 2017-02-11 12:06:57 -05:00
Alex Gaynor
54be255af5 Bump openssl on travis (#3390) 2017-02-12 00:23:43 +08:00
Alex Gaynor
5a059026a9 Fixed #3306 -- changelog entry for linking against OpenSSL 1.1.0 (#3389) 2017-02-11 23:05:34 +08:00
Paul Kehrer
f19fef1628 support defining which windows libraries to link with an env var (#3356)
* support defining which windows libraries to link with an env var

CRYPTOGRAPHY_WINDOWS_LIBRARIES is your new friend

* add some docs

* change to CRYPTOGRAPHY_WINDOWS_LINK_OPENSSL110

* lib prefixing is not a thing msvc does, right
2017-02-09 00:53:44 -05:00
Paul Kehrer
7a13085afc enforce password must be bytes when loading PEM/DER asymmetric keys (#3383)
* enforce password must be bytes when loading PEM/DER asymmetric keys

Previously we were using an ffi.buffer on the Python string, which was
allowing text implicitly, but our documentation explicitly requires
bytes.

* add changelog entry
2017-02-08 16:55:34 -05:00
Ofek Lev
0e6a129724 replace pyasn1 with asn1crypto (#3361)
* replace pyasn1 with asn1crypto

* allow trailing bytes

* fix x509 test

* update CHANGELOG.rst

* fix assert

* make asn1crypto code more idiomatic

* find tag

* final clean-up

* leave trailing byte logic unchanged

* document dependency change

* spelling

* fix spelling
2017-02-08 13:09:41 +08:00
Aviv Palivoda
1c7bd66eef Dh serialization changelog (#3385)
* Add CHANGELOG entries for DH serialization

* update AUTHORS
2017-02-08 12:38:42 +08:00
Aviv Palivoda
6723a12712 DH serialization (#3297)
* DH keys support serialization

* Add DH serialization documentation

* Add tests for DH keys serialization in DER encoding

* update version to 1.8

* Allow only SubjectPublicKeyInfo serialization

* Remove support in TraditionalOpenSSL format

* Fix pep8

* Refactor dh serialization tests
2017-02-07 21:24:56 +08:00
Mark Williams
523b132b27 Backport DH_check from OpenSSL 1.1.0. (#3375)
* Backport DH_check from OpenSSL 1.1.0.

OpenSSL 1.0.2's DH_check considers the q parameter, allowing it
validate more generators and primes; however, OpenSSL 1.1.0's DH_check
includes code to handle errors in BN functions, so it's preferred.

* Wrap DH_Check when using OpenSSL 1.1.0 or higher.

* Adding DH_CHECK_* values missing from older OpenSSLs

* Defensively guard DH_CHECK_* definitions with ifndef.

This will prevent duplicate definitions when LibreSSL supports a
version of DH_check that can return these.

* Document the OpenSSL of origin for the DH_check code
2017-02-03 17:20:00 +08:00
Paul Kehrer
a840aa2799 make cryptography fallback to /dev/urandom on mac on macOS < 10.12 (#3354) 2017-01-31 14:34:00 -05:00
Paul Kehrer
c7a2e72c6c port 1.7.2 changelog (#3371) 2017-01-28 02:45:57 -06:00
Alex Gaynor
d0c69837d2 Point people to python3-dev if needed (#3359)
* Point people to python3-dev if needed

* oops, syntax fix

* Fedora/RHEL as well
2017-01-21 22:20:54 +08:00
Alex Gaynor
4e87cf4529 Removed dead link from docs (#3360) 2017-01-21 21:50:53 +08:00
Christian Heimes
d078e546e2 Use static callbacks with Python 3.x again (#3350)
* Use static callbacks with Python 3.x again

Static callbacks were disabled for Python 3.5+ to work around an issue
with subinterpreters, locking callbacks and osrandom engine. Locking
callback and osrandom engine were replaced with a C implementations in
version 1.6 and 1.7.

https://github.com/pyca/cryptography/issues/2970

Closes: #3348
Signed-off-by: Christian Heimes <christian@python.org>

* remove unused import
2017-01-18 15:02:38 +08:00
Paul Kehrer
1bab7bcf7b add a SAN to the certificatebuilder example (#3353)
Evidently users copy/paste these examples so adding a SAN here will help
people screw up less. Fixes #3314
2017-01-18 00:44:40 -05:00
Paul Kehrer
5ab97a0694 update comment to be more descriptive (#3349) 2017-01-18 00:44:08 -05:00
Paul Kehrer
66a2372ab3 fix #3308 (#3352) 2017-01-18 00:42:09 -05:00
Dan Sully
aa396c0805 Move pkg_resources import location. (#3347) 2017-01-17 22:54:49 +08:00
Paul Kehrer
d74ba3298d add memory limit check for scrypt (#3328)
* add memory limit check for scrypt

fixes #3323

* test a pass

* move _MEM_LIMIT to the scrypt module
2017-01-05 14:11:17 -05:00
Alex Gaynor
1c2458e0ce It is 2017, in UTC (#3342) 2016-12-31 16:53:11 -08:00
Jan-Philip Gehrcke
1341bb71ee openssl backend: s/unserialize/deserialize/ in exception messages (#3339) 2016-12-28 09:46:34 -08:00
Alex Gaynor
93c1a8c815 Inline a pair of functions that became trivial post-1.0.0 (#3336) 2016-12-25 19:10:03 -08:00
Alex Gaynor
31b5d784e6 Fixed #3334 -- added Python 3.6 support (#3335)
* Fixed #3334 -- added Python 3.6 support

* install py36

* empty commit to retrigger travis

* this is an impressively dumb typo
2016-12-23 11:20:36 -06:00
Paul Kehrer
5685baa212 add openssl_version_number & doc openssl_version_text (#3329)
* add openssl_version_number & doc openssl_version_text

fixes #3315

* more docs + actually assert on the test...

* text
2016-12-21 22:10:03 -05:00
Paul Kehrer
e432562e77 DTLS bindings (#3309)
* add DTLSv1_2 methods

* add binding to DTLSv1_get_timeout() and DTLSv1_handle_timeout()

* fix: PEP8 failed

fix the following error:

./src/_cffi_src/openssl/ssl.py:728:80: E501 line too long (80 > 79 characters)

see https://jenkins.cryptography.io/job/cryptography-pr-pep8/1954/

* Revert "add DTLSv1_2 methods"

This reverts commit e4a9150b12ddb4790159a5835f1d1136cb1b996e.

* replace 'long int' by 'long'

To be more consistent with the naming convention

cf 8dde92aad5 (r90153970)

* wrap with braces

cf 8dde92aad5 (r90154057)

* conditionally bind all DTLS

* rebase error

* rename wrapped function
2016-12-19 18:25:00 -05:00
Alex Gaynor
7a15827ee6 We test the latest version of 1.1.0 (#3327) 2016-12-18 15:49:47 -06:00
Aviv Palivoda
7978393c40 Add d2i_DHparams_bio, i2d_DHparams_bio bindings (#3322) 2016-12-18 11:21:30 -05:00
Paul Kehrer
c8f47ad212 1.7.1 changelog port (#3320)
* 1.7.1 changelog port

* vim stop indenting when I don't want you to
2016-12-14 20:26:06 -05:00
Alex Gaynor
cfd41c2d56 restore this constant, pyopenssl needs it (#3321) 2016-12-14 14:12:12 -06:00
Alex Gaynor
0e8cdf1023 Drop 1.0.0 (#3312)
* delete the 1.0.0 support

* drop the version check

* drop the AES-CTR stuff

* Update the example

* openssl truncates for us now

* delete unused test

* unused imports

* Remove a bunch of conditional bindings for NPN

* no more 1.0.0 builders

* libressl fix

* update the docs

* remove dead branches

* oops

* this is a word, damnit

* spelling

* try removing this

* this test is not needed

* unused import
2016-12-13 20:05:35 -06:00
Paul Kehrer
874445aea9 fix a regression in int_from_bytes (#3316)
* fix a regression in int_from_bytes

* add a new test file
2016-12-13 12:09:35 -05:00
Alex Gaynor
cd77364230 no-ssl3, and some hacks (#3313) 2016-12-12 23:42:41 -06:00
Paul Kehrer
fad63fe138 1.8 begins (#3311) 2016-12-12 17:41:26 -05:00
Paul Kehrer
5df72e82c0 1.7 changelog date and version bump (#3310)
* 1.7 changelog date and version bump

* no wait the 12th
2016-12-12 13:06:09 -05:00
Paul Kehrer
9e5056cee7 document DHBackend is implemented for OpenSSL (#3304) 2016-12-11 10:00:52 -05:00
Nick Badger
acaf89d8cb Scrypt docs code example contradict RFC 7914 (#3302) (#3303)
* Scrypt docs code example contradict RFC 7914 (#3302)

* More secure example difficulty of parameter n in scrypt docs (#3302)

* Change link text to scrypt paper (#3302)

* Change link text to scrypt paper, part deux (#3302)

* Add "logins" to spelling wordlist
2016-12-10 19:41:50 -06:00
Paul Kehrer
a22964a306 add changelog entry for osrandom (#3298) 2016-12-10 10:15:41 -05:00
Paul Kehrer
f2691895a2 older readme_renderer doesn't work with docutils 0.13 (#3300) 2016-12-09 17:31:15 -05:00
Christian Heimes
2e717761c3 New osrandom_engine in C (#3229)
* New osrandom_engine in C

Inspired by Python/random.c and the old implementation.

Signed-off-by: Christian Heimes <christian@python.org>

* osrandom_engine

* Fix naming bug caused by search 'n replace mistake
* Make it easier to override osrandom auto-detection
* Add engine ctrl and backend API to get implementation from ENGINE

Signed-off-by: Christian Heimes <christian@python.org>

* Better test coverage, documentation, LICENSE

Signed-off-by: Christian Heimes <christian@python.org>

* Coverage is hard.

Signed-off-by: Christian Heimes <christian@python.org>

* * enable win32 check
* read() returns size_t

Signed-off-by: Christian Heimes <christian@python.org>

* Add macOS to spelling list. Remove dead code from header file.

Signed-off-by: Christian Heimes <christian@python.org>

* remove CCRandomGenerateBytes path and update getentropy to work on macOS

This change allows us to test all the engines in our CI:
* getentropy (tested by macOS sierra)
* getrandom (tested on several linux builders)
* /dev/urandom (tested on FreeBSD, OS X 10.11 and below, & older linux)
* CryptGenRandom (tested on windows builders)

I also fixed bugs preventing compilation in the getentropy code

* getentropy() returns int and is restricted to 256 bytes on macOS, too.

Signed-off-by: Christian Heimes <christian@python.org>

* add versionadded

* Re-add import of os module

* Fixes related to Alex's recent review.

Signed-off-by: Christian Heimes <christian@python.org>

* Add error reporting and fail for EAGAIN

Add error reporting strings for various error cases. This gives us much
nicer and understandable error messages.

SYS_getrandom() EAGAIN is now an error. Cryptography refuses to
initialize its osrandom engine when the Kernel's CPRNG hasn't been
seeded yet.

Signed-off-by: Christian Heimes <christian@python.org>
2016-12-09 10:02:26 -06:00
Paul Kehrer
0cf3690df9 friendly error if you put a date too far in the future on windows (#3279) 2016-12-05 08:12:43 -05:00
Ofek Lev
56aae48666 clean up int_from_bytes (#3295)
* clean up int_from_bytes

7x speed-up and code is more readable

* remove unused import

* rely on py2 built-in codecs
2016-12-02 23:37:55 -05:00
Alex Gaynor
f7e12193e9 Sierra is a thing (#3294) 2016-12-02 19:34:12 -05:00
Christian Heimes
dbf183506c Add minversion to tox.ini (#3292)
Cryptography uses new features from tox 2.4. Tox 2.3 happily ignores the
new config stanzes and doesn't install dependency. This can lead to strange
test failures.

With minversion=2.4, tox 2.3 fails to run properly:
$ tox
ERROR: tox version is 2.3.1, required is at least 2.4

Signed-off-by: Christian Heimes <christian@python.org>
2016-11-30 07:33:02 -05:00
Richard Plangger
22745ebf3e cffi bindings additions for pypy's _hashlib module (#3291)
* add cffi bindings to objects.py and evp.py (required for pypy's _hashlib implementation)

* ah, that comes from copying it from the man page

* dont use #define ..., delcare it as static cont long <name>
2016-11-30 00:52:59 +08:00
Cory Benfield
3a3cf1e4fd Bind TLSEXT_STATUSTYPE_ocsp (#3290) 2016-11-29 20:38:25 +08:00
Cory Benfield
effbbfdab4 Add OPENSSL_malloc. (#3289) 2016-11-28 10:02:20 -05:00
Aviv Palivoda
495f21a9c6 OpenSSL DH backend implementation [Second attempt] (#2914)
* Start of OpenSSL DH backend implementation

* Supporting DH in MultiBackend

* DHBackend has dh_parameters_supported method

* Removed DHParametersWithNumbers and DHPrivateKeyWithNumbers from documentation

* Removed ExchangeContext. exchange is a method of DHPrivateKeyWithSerialization

* PEP8 fixes

* Fixed TestDH.test_bad_tls_exchange

* Fixed generate_private_key reference in dh documentation

* test DH multibackend support

* testing DH coversion to serialized

* Validating that we receive serialized class in test_generate_dh

* Testing DH exchange symmetric key padding

* struct DH is now opaqued

* PEP8 fixes

* Testing load_dh_private_numbers throws ValueError when DH_check fails

* Using openssl_assert

* Passing keywords arguments in DH key exchange example

* test_dh::test_bad_tls_exchange now uses pre calculated parameters

* TestDH - Add test that the computed secret is equivalent to the definition by comparing with secret computed in pure python

* Add missing generator parameter to DHBackend interface docs.

* Include parameter type in DHBackend abc docs.

* Add docs for dh.generate_parameters function

* Remove the dh Numbers section, and move the DHNumbers class docs to where they are first used.

* Add note of big endian byte packing to DH exchange method.

* DH documentation updates.

Add single sentence overview with wikipedia link.
Add paragraph on assembling using Numbers objects.
Add link to backend interface docs.
First section was all indented, I think by mistake.

* Add exchange method to DHPrivateKey abstract base class.

* Small tweaks to DH documentation - remove Provider.

* Add endian to dictionary

* Use utils.int_from_bytes in test_tls_exchange_algorithm

* Removed duplicate line

* Change dh.rst exchange algorithm from doctest to code-block

The example in the Diffie-Hellman exhange algorithm is using
2048 bits key. Generating the parameters of 2048 takes long
time. This caused the automated tests to fail. In order to
pass the tests we change the example to code-block so it
will not run in the doc tests.

* Fix dh docs

* Document the generator in DHBackend relevant methods

* Fix dh tests

* use DHparams_dup

* Fix key type to unsigned char as expected by DH_compute_key

* Validate that DH generator is 2 or 5

* test dh exchange using botan vectors

* group all numbers classes

* Simplify _DHPrivateKey

* Rename test with serialized to numbers

* Move bad exchange params to external vector file

* update exchange versionadded to 1.7

* Make key_size bit accurate

* Change botan link

* Added CHANGELOG entry
2016-11-26 00:51:28 +08:00