summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* modified: Fixed a bug in rsa/core.py where the message should not be ↵Shengkai Sun2023-04-231-0/+28
| | | | | | equals to the modulus modified: Added test cases in tests/test_integers.py
* Drop support for Python 3.6Daniel Ziegenberg2022-12-061-1/+0
| | | | Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
* Fix incorrect ordering of public and private keys in test casemyheroyuki2022-07-201-3/+3
|
* Cleanup: remove trailing space from docstringSybren A. Stüvel2022-03-131-1/+1
|
* Fix #133: Remove rsa/_compat.pySybren A. Stüvel2022-03-133-91/+1
| | | | | There were very few functions in there, and none of them were actually used by the RSA library (just by the test code).
* Reformatting with BlackSybren A. Stüvel2021-03-2911-242/+286
| | | | No functional changes.
* Fix hashlib mypy types for Python 3.xSaif Hakim2021-03-241-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As captured in https://github.com/python/typeshed/pull/1663, the types for SHA-1 and SHA-2 family of functions are callables that return a Hash instance, whilst the SHA-3 family of functions are Hash `type`s (at least in Python 3.6). Mixing the two kinds of functions together in a dictionary confuses mypy's type inference as noted in #153, so we instead add an annotation as a hint. Also, update test_my.py to match the python version set by tox.ini in CI instead of always targeting Python 3.7 (as configured in setup.cfg) to validate the types in all supported Python 3.x versions. This fix also avoids the issue with the older mypy releases for Python 3.6 / Python 3.7 found in distro repos... ... for Ubuntu: ``` docker run \ -v $(pwd):/tmp/rsa \ -w /tmp/rsa ubuntu:18.04 \ /bin/bash -c 'apt-get update -qqy \ && apt-get install -qqy python3-pyasn1 python3-setuptools python3-mypy \ && python3 setup.py test' ``` ... and for Fedora: ``` docker run \ -v $(pwd):/tmp/rsa \ -w /tmp/rsa docker.io/fedora \ /bin/bash -c 'dnf -y install wget python3-devel python3-pyasn1 python3-setuptools python3-mypy \ && python3 setup.py test' ``` Fixes #153
* Clean up stdout when using unittest test runnerSaif Hakim2021-02-244-9/+9
| | | | | | | | While pytest is the preferred test runner via tox, it looks like some folks are still running tests via `python3 setup.py test` which uses unittest and does not have good support for capturing stdout. To make using unittest slightly more friendly, we further swallow stdout / stderr for cli tests, and ensure print statements start on a newline.
* Fix #173: unpickling doesn't restore full objectBu Sun Kim2021-02-241-0/+5
| | | | | When a `PrivateKey` or `PublicKey` is unpickled `AbstractKey.__init__()` should be called so `self.mutex` and `self.blindfac` are created.
* Fix threading issue introduced in 4.7Sybren A. Stüvel2021-02-151-8/+7
| | | | | | | | | Computing the blinding factor and its inverse was done in a thread-unsafe manner. Locking the computation & update of the blinding factors, and passing these around in frame- and stack-bound data, solves this. This fixes part of the issues reported in sybrenstuvel/python-rsa#173, but there is more going on in that particular report.
* Fix #162: Blinding uses slow algorithmSybren A. Stüvel2020-11-151-4/+13
| | | | | | | | | Store blinding factor + its inverse, so that they can be reused & updated on every blinding operation. This avoids expensive computations. The reuse of the previous blinding factor is done via squaring (mod n), as per section 9 of 'A Timing Attack against RSA with the Chinese Remainder Theorem' by Werner Schindler, https://tls.mbed.org/public/WSchindler-RSA_Timing_Attack.pdf
* Fix #164: Add padding length check as described by PKCS#1 v1.5Sybren A. Stüvel2020-11-151-0/+33
| | | | | According to PKCS#1 v1.5, the padding should be at least 8 bytes long. See https://tools.ietf.org/html/rfc8017#section-7.2.2 step 3 for more info.
* Limit SHA3 support to Python 3.6+Sybren A. Stüvel2020-06-111-0/+7
| | | | | | | The third-party library that adds support for this to Python 3.5 is a binary package, and thus breaks the pure-Python nature of Python-RSA. This should fix [#147](https://github.com/sybrenstuvel/python-rsa/issues/147).
* Compatibility with newer MyPy versionsSybren A. Stüvel2020-06-111-1/+1
| | | | The newer versions always have a message, even on success.
* Fix CVE-2020-13757: detect cyphertext modifications by prepending zero bytesSybren A. Stüvel2020-06-031-0/+44
| | | | | | | | | | Reject cyphertexts that have been modified by prepending zero bytes, by checking the cyphertext length against the expected size (given the decryption key). This resolves CVE-2020-13757. The same approach is used when verifying a signature. Thanks Carnil for pointing this out on https://github.com/sybrenstuvel/python-rsa/issues/146
* Drop character encoding markers for Python 2.xAndrey Semakin2020-06-0310-20/+0
|
* Add support for SHA3 hashingSybren A. Stüvel2019-08-041-1/+3
| | | | | | | | | | This is based on https://github.com/sybrenstuvel/python-rsa/pull/96, with a few improvements: - The minimum of one use of SHA3 in a unit test, to at least touch it at some point. - Documented the support of SHA3. - Only install the third-party library required by Python 3.5 when we're running on Python 3.5. Newer Python versions support SHA3 natively.
* Added mypy for static type checkingSybren A. Stüvel2019-08-042-22/+45
|
* Removed compatibility code for Python 2.7 and 3.4Sybren A. Stüvel2019-08-047-47/+17
|
* Fix BytesWarning in testsJon Dufresne2018-10-231-3/+3
| | | | | | | | | | | | | | | Shouldn't try to coerce bytes to a string. Instead, print the repr value (e.g. b'mybytestring'). When running tests with the Python `-b` option, fixes warnings of the form: .../python-rsa/tests/test_strings.py:34: BytesWarning: str() on a bytes instance print("\tMessage: %s" % message) .../python-rsa/tests/test_strings.py:37: BytesWarning: str() on a bytes instance print("\tEncrypted: %s" % encrypted) .../python-rsa/tests/test_strings.py:40: BytesWarning: str() on a bytes instance print("\tDecrypted: %s" % decrypted)
* Changed unittest to cover the new SHA-224 hash methodSybren A. Stüvel2018-02-051-2/+2
|
* PKCS#1 2.0: Implementation of MGF1 (#89)Michael Manganiello2017-06-101-0/+83
| | | | Implementation of the Mask Generation Function `MGF1` used in the OAEP encoding step. For more information, the MGF1 specification is at https://tools.ietf.org/html/rfc2437#section-10.2.1
* Support signing a pre-calculated hash (#87)Justin Simon2017-05-071-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | * Split the hashing out of the sign method This code change adds support to split the hashing of a message and the actual signing of the message. * Updating unit test and documentation This commit updates the unit test and usage docs. In addition, This change removes a redundant error check inside rsa.sign(). * Refactore unit tests and code comments Removed the print statements from the unit test and refactored a few code comments to improve readability. * Rename hash function The new hash function had the same name as a function in the standard library. This commit changes the name to avoid conflicts. * Rename hash function to compute_hash() This commit renames the hash function to compute_hash().
* Feature request #78: Expose function to find the hash method of a signatureSybren A. Stüvel2017-04-101-1/+9
| | | | | | I've not used the name "find_method_hash" suggested in #78, as it's a bit vague. It's ok-ish for a private function `_find_method_hash`, but I thought `find_signature_hash` would be more descriptive.
* Don't print in unit testsSybren A. Stüvel2017-04-101-3/+0
|
* Implementation of bitwise XOR function for bytes object (#72)Michael Manganiello2017-01-161-1/+46
|
* Create PY2 constant to simplify compatibility decisions (#82)Michael Manganiello2017-01-152-15/+12
| | | It's about time to get this merged, thanks again!
* Remove custom PrivateKey exponents/coefficient (#71)Michael Manganiello2017-01-052-1/+47
| | | Thanks for the improvements!
* Drop byte_literal in favour of b''adamantike2016-05-087-46/+42
|
* xrange compatibility optimization for Python 2 (#69)Michael Manganiello2016-05-082-1/+2
|
* Use 'assertEqual' instead of deprecated alias (#73)Michael Manganiello2016-05-081-10/+10
|
* Fix edge case for byte() call at pkcs1 test (#64)Michael Manganiello2016-04-231-1/+2
| | | Nice catch :)
* Unit test for Mersenne primesadamantike2016-04-231-0/+19
|
* Trivial fix on primality testingadamantike2016-04-161-3/+3
|
* Set Miller-Rabin rounds based on bitsizeadamantike2016-04-151-0/+14
|
* Implemented __hash__ function for key objects.Sybren A. Stüvel2016-03-291-0/+11
| | | | | | Overriding __eq__ blocks inheritance of __hash__ in Python 3. Fixes issue #55
* No longer require string operations to find bit lengths.Sybren A. Stüvel2016-03-291-7/+16
| | | | | Now that we no longer support Python 2.6, we can use int.bit_length() instead. Co-authored by @adamantike.
* More tests with hard-coded 'random' values.Sybren A. Stüvel2016-03-292-1/+35
| | | | This reduces noise in the code coverage measurements.
* Added unittest for rsa.key.gen_keysSybren A. Stüvel2016-03-291-0/+17
| | | | | This unittest tests both execution branches of the function (keys relatively prime or not), reducing randomness of code coverage.
* Added unittest for rsa.common.inverseSybren A. Stüvel2016-03-291-1/+11
| | | | | This unittest tests both execution branches of the function, reducing randomness of code coverage.
* Removed monkey-patch of unittestSybren A. Stüvel2016-03-291-13/+0
| | | | This was required for Python 2.6, which we no longer support.
* Added unit test for rsa.util.private_to_public()Sybren A. Stüvel2016-03-171-0/+19
|
* More CLI tests & clearer bytes stuffSybren A. Stüvel2016-03-175-12/+178
| | | | | Ensuring that bytes are written correctly on all supported Python versions, including when writing to stdout.
* Attempt at unit-testing CLI commandsSybren A. Stüvel2016-03-171-0/+149
|
* Ensuring that PEM output is always in bytes.Sybren A. Stüvel2016-03-171-1/+15
| | | | | This may break some applications. However, it does make the RSA library easier to use on different Python versions.
* Removed deprecated functionality.Sybren A. Stüvel2016-03-172-161/+0
| | | | | | | | | | | The following modules have been removed: - rsa._version133 - rsa._version200 - rsa.bigfile - rsa.varblock The encrypt/decrypt-bigfile CLI commands have also been removed.
* Allow loading PEM from strings (not just bytes), closes issue #49Sybren A. Stüvel2016-03-171-2/+49
|
* Reintroduced test for rsa.prime.is_primeSybren A. Stüvel2016-03-171-0/+23
|
* Remove Solovay-Strassen implementationadamantike2016-03-171-193/+0
|
* Add Jacobi test for table of valuesadamantike2016-02-051-0/+214
|