summaryrefslogtreecommitdiff
path: root/tests/test_crypto.py
Commit message (Collapse)AuthorAgeFilesLines
...
* Convert the remaining tests in test_crypto.py to be pytest-style (#593)Alex Chan2017-01-301-617/+461
|
* Convert more classes in test_crypto.py to pytest-style (#591)Alex Chan2017-01-251-216/+193
|
* Prevent _PassphraseHelper.raise_if_problem() from eating exceptions (#581)Greg Bowser2017-01-251-2/+4
| | | | | | | | | | | | | | | | | | | | | | | * Modify tests to detect empty crypto.Errors from load_privatekey This reproduces #119 and #456. * Prevent _PassphraseHelper.raise_if_problem() from eating exceptions. This resolves #119, resolves #456. `_PassphraseHelper.raise_if_problem()` always flushes the OpenSSL exception queue, but does not always raise an exception. In some cases, other code attempts to raise an error from OpenSSL after `raise_if_problem()` has flushed the queue, thus causing an empty exception to be raised (i.e. `raise Error([])`). This commit modifies `_PassphraseHelper.raise_if_problem` to flush the OpenSSL error queue only if it has en exception to raise. Subsequent code that detects an error should now be able to raise an non-empty exception. * Add CHANGELOG entry for #581.
* Convert another couple of test classes to pytest-style (#586)Alex Chan2017-01-241-174/+120
|
* Convert a few more small test classes to be pytest-style (#585)Alex Chan2016-12-191-62/+31
| | | | | | | | * Rewrite test_tsafe to be pytest-style * Rewrite TestRevoked to be pytest-style * Convert TestConnection to be pytest-style
* Convert the elliptic curve tests to be pytest-style (#576)Alex Chan2016-12-191-58/+35
|
* Add the ability to set a custom verification time on X509Store (#567)Thomas Sileo2016-11-221-0/+21
|
* Convert X509ExtTests to use pytest-style tests (#564)Alex Chan2016-11-181-156/+144
|
* Fixed #529 -- use the native bytes syntax (#536)Alex Gaynor2016-09-111-177/+177
|
* Pass an explicit nameopt to be resillient to OpenSSL default changes (#533)Alex Gaynor2016-09-101-2/+4
| | | | | | * fix two tests for OpenSSL 1.1.0's new defaults * flake8
* Remove some pointless branches (#511)Alex Gaynor2016-07-311-4/+0
| | | | | | | | * Remove some pointless branches * this nonsense too * this is unused
* Clean out some cruft (#509)Alex Gaynor2016-07-311-5/+0
|
* Convert between pyOpenSSL and cryptography objects (#439)Paul Kehrer2016-07-291-0/+75
| | | | | | | | | | * convert pkey to cryptography keys and vice versa * pep8 and such * Add documentation and changelog * add a type check and verify that it rejects ECDSA keys from cryptography
* Write a few more tests (#503)Alex Gaynor2016-07-041-8/+39
| | | | | | * Write a few more tests * pytestify this whole jam
* Write a few more tests for coverage (#501)Alex Gaynor2016-07-041-1/+18
|
* Simplify a few more branches to improve coverage (#500)Alex Gaynor2016-07-031-0/+3
|
* Replace several untested paths with _openssl_assert (#498)Alex Gaynor2016-07-031-0/+8
| | | | | | | | | | | | | | * Replace several untested paths with _openssl_assert * fix, these require a bool * oop, fixed * finish porting crypto.py * typo * yessssssss
* Enable use of CRL (and more) in verify context. (#483)Dan Sully2016-06-041-1/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Enable use of CRL (and more) in verify context. * flake8 fixes. * Comments from Hynek & Paul. * More updates from Paul & Hynek. * Fix closing backtick. * Remove commented out constants. * More doc updates. Changelog update. * Getting closer? * Sphinx fix. * Indent docstring. * More Sphinx updates. * Type updates for docstrings. * Remove Enum subclassing. * Docstring update. * Docstrings updates. * Round and round it goes. Where it ends, nobody knows. * Remove TODO comment. Need @sholsapp to follow up. * Time for lots of alcohol.
* Refactor tests for crypto.load_publickey (#482)Hynek Schlawack2016-06-031-30/+34
|
* fix a small bug with load_publickey (#481)Paul Kehrer2016-06-031-0/+14
| | | | | | | | * fix a small bug with load_publickey * update docstring, rename test method * make hynek happy
* move to separate pytest class + add one more test casePaul Kehrer2016-03-111-12/+26
|
* what's a bytesPaul Kehrer2016-03-111-1/+1
|
* first revoked cert in the CRL has NID_crl_reason first in listPaul Kehrer2016-03-111-2/+2
| | | | | so we'll use the second revoked because to cover this branch we need to see a NID that's not NID_crl_reason
* add a test to confirm crl.get_reason ignores unsupported extensionsPaul Kehrer2016-03-111-0/+50
|
* bytesPaul Kehrer2016-03-101-1/+1
|
* fix test and a missing X509_REVOKED_dup callPaul Kehrer2016-03-091-0/+2
|
* Fix signature buffer size for RSA keysColleen Murphy2016-03-011-0/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using the pyOpenSSL crypto module to sign data using a large key, e.g. 8192 bit, a memory allocation error occurs. A test case to show this, which comes from OpenStack Glance, is: ``` $ openssl genrsa -out server.key 8192 $ ... $ cat test.py from OpenSSL import crypto import uuid key_file = 'server.key' with open(key_file, 'r') as keyfile: key_str = keyfile.read() key = crypto.load_privatekey(crypto.FILETYPE_PEM, key_str) data = str(uuid.uuid4()) digest = 'sha256' crypto.sign(key, data, digest) $ python test.py *** Error in `python': free(): invalid next size (normal): 0x0000000002879050 *** Aborted ``` Other errors that may appear to the user are: ``` Segmentation Fault ``` ``` *** Error in `python': double free or corruption (!prev): 0x0000000001245300 *** Aborted ``` ``` *** Error in `python': munmap_chunk(): invalid pointer: 0x0000000001fde540 *** Aborted ``` The reason this happens is that the sign function of the crypto module hard-codes the size of the signature buffer to 512 bytes (4096 bits). An RSA key generates a signature that can be up to the size of the private key modulus, so for an 8192 bit key, a buffer for a 4096 bit signature is too short and causes a memory allocation error. Technically the maximum size key this code should be able to handle is 4096 bits, but due to memory allocation alignment the problem only becomes apparent for keys of at least 4161 bits. This patch does two things. First, it determines the correct size of the signature buffer, in bytes, based on the real size of the private key, and passes that the buffer allocation instead of the static number 512. Second, it no longer passes in a signature length. This is because the OpenSSL EVP_SignFinal function uses this argument as an output and completely ignores it as an input[1], so there is no need for us to set it. This is only a problem for RSA keys, and this patch only affects RSA keys. For DSA keys, the key size is restricted to 1024 bits (128 bytes), and the signature a DSA key will generate will be about 46 bytes, so this buffer will still be big enough for DSA signatures. [1] https://github.com/openssl/openssl/blob/349807608f31b20af01a342d0072bb92e0b036e2/crypto/evp/p_sign.c#L74
* Correction for coding convention.Anthony Alba2015-12-041-2/+0
|
* Enable tests to pass when MD5 verification disabled in OpenSSL.Anthony Alba2015-12-041-1/+3
|
* Further testing for load/dump_publickeyCory Benfield2015-10-271-0/+32
|
* Switch to py.test assertions.Cory Benfield2015-10-271-2/+2
|
* Cleanup docstrings.Cory Benfield2015-10-271-2/+2
|
* Support for serializing/deserializing public keysCory Benfield2015-10-271-0/+31
|
* factor out function to dump crlDominic Chen2015-10-211-1/+9
|
* Move package into srcHynek Schlawack2015-10-171-0/+3557
Prevents accidental imports when running tests.