Commits

hideki nara committed ff469d2

simple RS256 sign/verigy seem to work

  • Participants
  • Parent commits dbec39b

Comments (0)

Files changed (2)

File src/jose/jws/__init__.py

 # -*- coding: utf-8 -*-
 # use python-jws
 import jws
-from jose import loads_base64url, dumps_base64url,args_from_string
+from jose import encode, decode,args_from_string
 
 #
 class SignedToken(object):
         return from_string(*args)
 
     def update(self,private_key):
-        self.signing_input , self.signature= jws._signing_input(self.header,self.message,key=private_key)
+        self.signing_input , self.signature= jws.sign(self.header,self.message,key=private_key)
         self.token = self.signing_input +"." + self.signature
     
 def from_token(token,dheader,payload,signature):

File src/jose/jwt/tests.py

         with self.assertRaises(ValueError):
             args = args_from_string(token3)
             obj = from_token(*args)
+
+import Crypto.PublicKey.RSA as rsa
+
+class TestSignedJWT(unittest.TestCase):
+    def test_simple(self):
+        from datetime import date
+        message = {'subjet':'Hello', "body": "Today is " + str(date.today()) }
+        private = rsa.generate(1024)
+        header = {'alg': 'RS256'}
+
+        from jose.jws import SignedToken
+        obj = SignedToken(header=header,message=message )
+        obj.update(private)
+        print obj.token
+
+        public = private.publickey()
+        print obj.verify(public)
+