Commit graph

6737 commits

Author SHA1 Message Date
Paul Kehrer
86b8b865b6 1.7.2 changelog and version bump (#3370) 2017-01-27 09:05:39 -06:00
Paul Kehrer
605b918a9d changelog and version bump for 1.7.1 (#3318) 2016-12-13 16:04:55 -05:00
Paul Kehrer
486127a229 Backport fix regression (#3317)
* fix a regression in int_from_bytes

* add a new test file
2016-12-13 12:13:51 -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
Erik Daguerre
53412d4faa updated authors.rst (#3277) 2016-11-22 22:26:37 +08:00
Alex Gaynor
29b2ebc480 Error out on OpenSSL 1.0.0 by default (#3276)
* Error out on OpenSSL 1.0.0 by default

* what the heck
2016-11-22 22:25:17 +08:00
Paul Kehrer
085859172d let's get rolling on 1.7! (#3274) 2016-11-22 07:04:40 -05:00
Paul Kehrer
4a2f36bc11 bump version and set changelog date for 1.6 release (#3271) 2016-11-21 21:50:28 -05:00
Paul Kehrer
191e6e90bf error if private_value is <= 0 in ec.derive_private_key (#3273) 2016-11-21 21:49:42 -05:00
Richard Plangger
ca4f79ede7 PyPy's ssl module, the last missing macro and three macro functions (#3270)
* missing macro and three macro functions

* removed space before function name (style issue)

* remove macro which always will not be set by cryptography
2016-11-21 20:21:06 +08:00
Paul Kehrer
ec7fc46151 update docs and changelog for prehashed support (#3268) 2016-11-20 18:55:18 -05:00
Paul Kehrer
80ec631601 add support for prehashing in ECDSA sign/verify (#3267)
* add support for prehashing in ECDSA sign/verify

* move signature_algorithm check to its own function
2016-11-20 11:20:52 -05:00
Paul Kehrer
6012ccff0d support prehashed sign/verify in DSA (#3266) 2016-11-20 10:45:06 -05:00
Paul Kehrer
f555c74d54 support RSA verify with prehashing (#3265)
* support RSA verify with prehashing

* review feedback

* more dedupe

* refactor and move to a separate module
2016-11-20 09:48:10 -05:00
Paul Kehrer
033bd7167d support prehashing in RSA sign (#3238)
* support prehashing in RSA sign

* check to make sure digest size matches prehashed data provided

* move doctest for prehashed
2016-11-20 08:13:23 -05:00
Paul Kehrer
d3fd692441 refactor RSA signature verification to prep for prehash support (#3261) 2016-11-20 08:11:48 -05:00
Paul Kehrer
6f32974b06 refactor ecdsa sign/verify for prehash (#3263) 2016-11-19 23:02:43 -05:00
Paul Kehrer
756255103c refactor dsa sign/verify as prep for prehash (#3262) 2016-11-19 23:00:33 -05:00
Paul Kehrer
ae2fb63f6f bind a few things pypy ssl stdlib needs in x509v3 (#3255) 2016-11-19 13:27:45 -05:00
Paul Kehrer
9d73635256 refactor RSA signing to prep for prehash support (#3240) 2016-11-19 13:23:12 -05:00
Paul Kehrer
500850b155 Additions to the changelog for 1.6 (#3258)
* Additions to the changelog for 1.6

* explain why
2016-11-19 11:40:16 -05:00
Aviv Palivoda
9cf1ed57f2 Add DHparams_dup to DH bindings (#3260) 2016-11-19 11:08:13 -05:00
Paul Kehrer
36d5cd6a14 add a few more OIDs (#3259)
pulled from #3244
2016-11-19 09:05:26 -05:00
Paul Kehrer
df203db3ab bind GENERAL_NAME_free and move GENERAL_NAME_new to macros... (#3257)
where it belongs!
2016-11-19 09:02:19 -05:00
Paul Kehrer
e07ac94c7d add error codes and ERR_get_state for pypy stdlib ssl (#3256) 2016-11-19 09:01:30 -05:00
Paul Kehrer
e3352d2fa5 add some x509_object handling for pypy stdlib (#3254) 2016-11-19 01:27:30 -05:00
Paul Kehrer
10a602f622 add two error codes for pypy ssl stdlib (#3253) 2016-11-19 01:25:25 -05:00
Paul Kehrer
47d3fcade3 add OPENSSL_NPN_NEGOTIATED (#3252) 2016-11-19 01:24:44 -05:00
Paul Kehrer
7db611785f add some NIDs (#3251) 2016-11-18 23:02:19 -05:00
Paul Kehrer
e09754c74d add SSL_CTX_set_ecdh_auto where supported (#3250)
In 1.1.0 this is a noop and occurs by default, and this wasn't supported
< 1.0.2
2016-11-18 22:30:25 -05:00
Paul Kehrer
84e4e3111d add some BIO functions for pypy's ssl stdlib (#3249)
refs #3248
2016-11-18 22:07:28 -05:00
Paul Kehrer
533a3c909d change derive_elliptic_curve_public_point to return EllipticCurvePubl… (#3243)
* change derive_elliptic_curve_public_point to return EllipticCurvePublicKey

* also rename the backend interface method

* review feedback

* Rename to derive_elliptic_curve_private_key
* Returns EllipticCurvePrivateKey
* Reuses the EC_POINT in the openssl impl
* Rename "secret" arg to "private_value" which is consistent with our
  naming for the value in ECPrivateNumbers.
2016-11-18 20:49:10 -05:00
Paul Kehrer
e929c3c613 update travis to use xcode8.1 image so we have sierra coverage (#3246)
* update travis to use xcode8.1 image so we have sierra coverage

* docs too
2016-11-18 20:46:03 -05:00
Alex Gaynor
7ff4c8fe24 Random flake8 cleanups for the latest release (#3242) 2016-11-15 12:27:31 +08:00
Terry Chia
e9b87d5de4 Raise padding block_size limit to what is allowed by the specs. (#3108)
* Raize padding block_size limit to what is allowed by the specs.

* Add tests for raising padding limits.

* Amend C code for padding check to use uint16_t instead of uint8_t.

* Fix test to work in Python 3.

* Fix typo.

* Fix another typo.

* Fix return type of the padding checks.

* Change hypothesis test on padding.

* Update comment.
2016-11-15 09:56:02 +08:00
Paul Kehrer
9977786b56 workaround for application bundling tools (#3235)
* cx_freeze support for default_backend

* updated tabing to spaces

* corrected spacing

* moved finding backend to backends __init__

* update to check to see if sys is frozen

* corrected pep8 issues

* update based on comments

* changes to simplify, support testing, and improve comments

* add changelog entry

* right, coverage. I remember now. Time for some contortions.

* updated with review feedback
2016-11-14 18:34:55 -05:00
Paul Kehrer
3a15b03e92 Add a bytes method to get the DER ASN.1 encoding of an X509 name. (#3236)
* Add a bytes method to get the DER ASN.1 encoding of an X509 name.

This is useful for creating an OpenSSL style subject_name_hash (#3011)

* add to backend interface and update multibackend

* bytes -> public_bytes
2016-11-13 17:30:11 -05:00