Skip to content
Browse files

Moved/renamed some classes in algos.py

  • Loading branch information...
1 parent 7764977 commit 314895fdddaa3bb661448d0ec7181e4fe012c0eb @brianloveswords committed Jun 2, 2011
Showing with 13 additions and 4 deletions.
  1. +2 −1 README.md
  2. +11 −3 jws/algos.py
View
3 README.md
@@ -27,6 +27,7 @@ Let's check out some examples.
jws.exceptions.SignatureError: Could not validate signature
Now with a real key!
+
>>> import ecdsa
>>> sk256 = ecdsa.SigningKey.generate(curve=ecdsa.NIST256p)
>>> vk = sk256.get_verifying_key()
@@ -37,7 +38,7 @@ Now with a real key!
Advanced Usage
--------------
-::todo::
+
Algorithms
----------
View
14 jws/algos.py
@@ -1,8 +1,16 @@
import re
from exceptions import SignatureError, RouteMissingError, RouteEndpointError
+
class AlgorithmBase(object):
"""Base for algorithm support classes."""
+ pass
+
+class HasherBase(AlgorithmBase):
+ """
+ Base for algos which need a hash function. The ``bits`` param can be
+ passed in from the capturing group of the routing regexp
+ """
supported_bits = (256, 384, 512)
def __init__(self, bits):
"""
@@ -17,7 +25,7 @@ def __init__(self, bits):
import hashlib
self.hasher = getattr(hashlib, 'sha%d' % self.bits)
-class HMAC(AlgorithmBase):
+class HMAC(HasherBase):
"""
Support for HMAC signing.
"""
@@ -31,7 +39,7 @@ def verify(self, msg, crypto, key):
raise SignatureError("Could not validate signature")
return True
-class RSA(AlgorithmBase):
+class RSA(HasherBase):
"""
Support for RSA signing.
@@ -90,7 +98,7 @@ def verify(self, msg, crypto, key):
raise SignatureError("Could not validate signature")
return True
-class ECDSA(AlgorithmBase):
+class ECDSA(HasherBase):
"""
Support for ECDSA signing. This is the preferred algorithm for private/public key
verification.

0 comments on commit 314895f

Please sign in to comment.
Something went wrong with that request. Please try again.