Skip to content

Commit

Permalink
Merge pull request #9 from mark-adams/removeSpecialPycrypto
Browse files Browse the repository at this point in the history
Special pycrypto is no longer required if using pycrypto >= 2.5.
  • Loading branch information
brianloveswords committed Feb 8, 2014
2 parents ce7fe72 + 241436d commit 192f08e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 39 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
@@ -1,3 +0,0 @@
[submodule "vendor/pycrypto"]
path = vendor/pycrypto
url = git://github.com/Legrandin/pycrypto.git
9 changes: 2 additions & 7 deletions README.md
Expand Up @@ -20,7 +20,7 @@ The JWS spec reserves several algorithms for cryptographic signing. Out of the 9
* HS512 – HMAC using SHA-512 hash algorithm


**RSA** – requires special version of pycrypto, read below
**RSA** – requires pycrypto >= 2.5: ``pip install pycrypto``

* RS256 – RSA using SHA-256 hash algorithm

Expand All @@ -34,12 +34,7 @@ There is also a mechanism for extending functionality by adding your own
algorithms without cracking open the whole codebase. See the advanced usage
section for an example.

<strong>NOTE:</strong> you must use the version of pycrypto submoduled to
``vendor/pycrypto`` to get RSA256 support. However if you don't ever plan on using
RSA, you don't have to worry about it – all crypto libraries are lazily loaded
so you won't even notice it's not there.

If you want to know why RSA support is limited, read this: https://github.com/brianlovesdata/python-jws/blob/master/jws/algos.py#L42
For RSA and ECDSA, all crypto libraries are lazily loaded so you won't need the dependencies unless you try to use the functionality.

Usage
-----
Expand Down
16 changes: 5 additions & 11 deletions README.txt
Expand Up @@ -4,8 +4,7 @@ A Python implementation of [JSON Web Signatures draft 02](http://self-issued.inf

Installing
----------
$ git://github.com/brianlovesdata/python-jws.git
$ python setup.py install
$ pip install jws



Expand All @@ -21,7 +20,7 @@ The JWS spec reserves several algorithms for cryptographic signing. Out of the 9
* HS512 – HMAC using SHA-512 hash algorithm


**RSA** – requires special version of pycrypto, read below
**RSA** – requires pycrypto >= 2.5: ``pip install pycrypto``

* RS256 – RSA using SHA-256 hash algorithm

Expand All @@ -35,12 +34,7 @@ There is also a mechanism for extending functionality by adding your own
algorithms without cracking open the whole codebase. See the advanced usage
section for an example.

<strong>NOTE:</strong> you must use the version of pycrypto submoduled to
``vendor/pycrypto`` to get RSA256 support. However if you don't ever plan on using
RSA, you don't have to worry about it – all crypto libraries are lazily loaded
so you won't even notice it's not there.

If you want to know why RSA support is limited, read this: https://github.com/brianlovesdata/python-jws/blob/master/jws/algos.py#L42
For RSA and ECDSA, all crypto libraries are lazily loaded so you won't need the dependencies unless you try to use the functionality.

Usage
-----
Expand Down Expand Up @@ -116,11 +110,11 @@ Other Stuff
---------

Check out
https://github.com/brianlovesdata/python-jws/blob/master/examples/minijwt.py
https://github.com/brianloveswords/python-jws/blob/master/examples/minijwt.py
for a 14-line implemention of JWT.

See
https://github.com/brianlovesdata/python-jws/blob/master/examples/ragecrypto.py
https://github.com/brianloveswords/python-jws/blob/master/examples/ragecrypto.py
for a rage-comic inspired cryptography extension.

TODO
Expand Down
18 changes: 1 addition & 17 deletions jws/algos.py
Expand Up @@ -43,24 +43,8 @@ class RSABase(HasherBase):
"""
Support for RSA signing.
The ``Crypto`` package is required. However...
The ``Crypto`` package >= 2.5 is required.
NOTE: THIS ALGORITHM IS CRIPPLED AND INCOMPLETE
Section 7.2 of the specification (found at
http://self-issued.info/docs/draft-jones-json-web-signature.html)
describes the algorithm for creating a JWS with RSA. It is mandatory to
use RSASSA-PKCS1-V1_5-SIGN and either SHA256, 385 or 512.
Problem 1: The Crypto library doesn't currently support PKCS1-V1_5. There
is a fork that does have support:
https://github.com/Legrandin/pycrypto/tree/pkcs1
Problem 2: The PKCS signing method requires a Crypto.Hash class.
Crypto.Hash doesn't yet have support anything above SHA256.
Bottom line, you should probably use ECDSA instead.
"""
supported_bits = (256,384,512,) #:Seems to worka > 256

Expand Down
1 change: 0 additions & 1 deletion vendor/pycrypto
Submodule pycrypto deleted from a2ef0a

0 comments on commit 192f08e

Please sign in to comment.