summaryrefslogtreecommitdiff
path: root/rsa/pkcs1.py
Commit message (Collapse)AuthorAgeFilesLines
* language correction and speed-upHEADmainmyheroyuki2023-04-251-5/+5
|
* rsa/pkcs1.py: Clarify functionality of sign_hash()Moritz Fischer2023-04-231-2/+2
| | | | | | | Clarify functionality that a hash is not computed, rather a precomputed (given) hash is being signed. Signed-off-by: Moritz Fischer <moritzf@google.com>
* Fix #199: Sphinx warnings reference target not foundSybren A. Stüvel2022-07-201-1/+2
| | | | | | | | | | | | | | | Fix the documentation by adding referenced-but-not-included functions and some other small fixes. The only warnings left are: ``` python-rsa/rsa/key.py:docstring of rsa.key.AbstractKey.load_pkcs1:: WARNING: py:class reference target not found: rsa.key.T python-rsa/rsa/key.py:docstring of rsa.key.AbstractKey.load_pkcs1:: WARNING: py:class reference target not found: rsa.key.T ``` These are due to Sphynx not really understanding `typing` type references. Not sure how to fix those.
* Fix typosKian-Meng, Ang2021-11-241-1/+1
|
* Reformatting with BlackSybren A. Stüvel2021-03-291-54/+63
| | | | No functional changes.
* Fix hashlib mypy types for Python 3.xSaif Hakim2021-03-241-1/+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
* Directly raise `DecryptionError` when crypto length is badSybren A. Stüvel2020-11-151-2/+4
| | | | | Crypto length and blocksize are public info, so don't need side-channel free comparison.
* Use `bytes.find()` instead of `bytes.index()`Sybren A. Stüvel2020-11-151-4/+2
| | | | | Use `bytes.find()` instead of `bytes.index()`, as the former doesn't raise an exception when the to-be-found byte doesn't exist.
* Fix #164: Add padding length check as described by PKCS#1 v1.5Sybren A. Stüvel2020-11-151-1/+6
| | | | | 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.
* Fix #165: CVE-2020-25658 - Bleichenbacher-style timing oracleSybren A. Stüvel2020-11-151-4/+8
| | | | | | | | | | | | | Use as many constant-time comparisons as practical in the `rsa.pkcs1.decrypt` function. `cleartext.index(b'\x00', 2)` will still be non-constant-time. The alternative would be to iterate over all the data byte by byte in Python, which is several orders of magnitude slower. Given that a perfect constant-time implementation is very hard or even impossible to do in Python [1], I chose the more performant option here. [1]: https://securitypitfalls.wordpress.com/2018/08/03/constant-time-compare-in-python/
* Limit SHA3 support to Python 3.6+Sybren A. Stüvel2020-06-111-12/+15
| | | | | | | 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).
* Fix CVE-2020-13757: detect cyphertext modifications by prepending zero bytesSybren A. Stüvel2020-06-031-0/+9
| | | | | | | | | | 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
* Add more type hintsAndrey Semakin2020-06-031-1/+1
|
* Drop character encoding markers for Python 2.xAndrey Semakin2020-06-031-2/+0
|
* Added flake8 as development dependency and fixed reported issuesSybren A. Stüvel2019-08-041-4/+3
|
* Add support for SHA3 hashingSybren A. Stüvel2019-08-041-0/+14
| | | | | | | | | | 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 type annotations + some fixes to get them correctSybren A. Stüvel2019-08-041-18/+18
| | | | | | One functional change: `CryptoOperation.read_infile()` now reads bytes from `sys.stdin` instead of text. This is necessary to be consistent with the rest of the code, which all deals with bytes.
* Removed compatibility code for Python 2.7 and 3.4Sybren A. Stüvel2019-08-041-1/+0
|
* speedupyjqiang2018-09-161-1/+1
| | | "if A and B" if mostly A is True then we should judge B at first
* Add support for SHA224 for PKCS1 signaturesJoost Rijneveld2018-02-051-2/+4
|
* PKCS#1 2.0: Implementation of MGF1 (#89)Michael Manganiello2017-06-101-1/+1
| | | | 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-16/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | * 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/+21
| | | | | | 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.
* Drop byte_literal in favour of b''adamantike2016-05-081-18/+18
|
* xrange compatibility optimization for Python 2 (#69)Michael Manganiello2016-05-081-1/+1
|
* Removed deprecated functionality.Sybren A. Stüvel2016-03-171-4/+22
| | | | | | | | | | | The following modules have been removed: - rsa._version133 - rsa._version200 - rsa.bigfile - rsa.varblock The encrypt/decrypt-bigfile CLI commands have also been removed.
* Updated documentation, mostly http -> https changesSybren A. Stüvel2016-02-051-1/+1
| | | | | | Also: - changed http to https in the code - changed header underlines in the documentation to match the header length
* Perform a late import of rsa.varblock to prevent DeprecationWarningsSybren A. Stüvel2016-01-251-1/+4
|
* Another pass at blinding.Sybren A. Stüvel2016-01-221-2/+2
|
* Use random number when blinding, and also blind when verifying signatures.Sybren A. Stüvel2016-01-221-9/+3
|
* Fix #19: Implemented blinding when decrypting.Sybren A. Stüvel2016-01-221-2/+8
| | | | | This prevents side-channel (such as timing) attacks, see: https://en.wikipedia.org/wiki/Blinding_%28cryptography%29
* Updated doctests to Python 3.5 and automatically running with Tox.Sybren A. Stüvel2016-01-221-15/+15
| | | | | I've also removed doctests from the obsolete rsa/_versionXXX.py files, as those files aren't even compatible with Python 3.x anyway.
* Using r""" for some docstringsSybren A. Stüvel2016-01-221-3/+3
|
* Big refactor to become more PEP8 compliant.Sybren A. Stüvel2016-01-221-82/+87
| | | | | Mostly focused on docstrings (''' → """), indentation, empty lines, and superfluous parenthesis.
* Fix BB'06 attack in verify() by switching from parsing to comparisonFilippo Valsorda2015-12-161-38/+20
|
* rsa.pkcs1.verify() should return True when successfulTim Heckman2012-10-171-0/+2
| | | | | | | | | | | | | | | - when verification passes verify() will return True, instead of None. If verification fails the function will still raise a rsa.pkcs1.VerificationError for legacy purposes. - update the docs to note that the verify() function returns True when successful - write unit tests to verify this new behavior This commit passes all build tests: Ran 44 tests in 1.217s OK
* Fixed doctestsSybren A. Stüvel2012-06-181-1/+1
|
* Reverts docstring quoting syntax.Yesudeep Mangalapilly2011-08-241-21/+21
|
* Parellelized testing. Caught a lot of bugs.Yesudeep Mangalapilly2011-08-161-21/+21
|
* Porting to Python 3 complete. All tests except pyasn1 stuff pass.Yesudeep Mangalapilly2011-08-111-17/+18
|
* Tests are now functional (only running without syntax errors) on Python 3 too.Yesudeep Mangalapilly2011-08-111-3/+3
|
* Fixed doctest, python 2.6 on cygwinSybren A. Stüvel2011-08-031-1/+1
|
* more documentationSybren A. Stüvel2011-08-031-2/+30
|
* Made hashing efficient for large filesSybren A. Stüvel2011-07-311-5/+25
|
* More documentationSybren A. Stüvel2011-07-311-34/+37
|
* Using key.X rather than key['X']Sybren A. Stüvel2011-07-301-9/+9
|
* Added Apache 2 license notice to source filesSybren A. Stüvel2011-07-231-0/+16
|
* Renamed rsa.keygen to rsa.keySybren A. Stüvel2011-07-191-4/+4
|
* Fixed file permissionsSybren A. Stüvel2011-07-191-1/+1
|
* Fixed typo on rsa.pkcs1.__all__Sybren A. Stüvel2011-07-121-1/+1
|