Changeset 251 for trunk

Show
Ignore:
Timestamp:
03/30/09 15:39:06 (3 years ago)
Author:
ocjhb
Message:

more playing

Location:
trunk/sandbox/jhb/oc2
Files:
48 added
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/sandbox/jhb/oc2/occrypto_rsa.py

    r250 r251  
     1"""This is a playground to develop the api for the pubkey and secret key. 
     2Don't take the crypto seriously""" 
    13from container import Container,Field 
    2 import sha 
     4import hashlib 
    35import rsa 
    46 
     
    1113        self.isPrivate = isPrivate 
    1214 
    13     def getencoded(self,object,allData=False): 
    14         key = getattr(object,self.name,self.default) 
    15         return key.write()  
    16  
    17     def setdecoded(self,object,data): 
    18         if self.isPrivate: 
    19             key = keyfactory.parsePrivateKey(data) 
    20         else: 
    21             key = keyfactory.parseAsPublicKey(data) 
    22         setattr(object,self.name,key) 
    23  
     15    
    2416 
    2517class PubKey(Container): 
     
    7466 
    7567def hash(data): 
    76     return sha.sha(data).digest() 
     68    return hashlib.sha256(data).digest() 
    7769 
    7870def KeyFactory(bitlen): 
  • trunk/sandbox/jhb/oc2/occrypto_tlslite.py

    r250 r251  
    5858        #number =  cryptomath.stringToNumber(data) 
    5959        number = data 
    60         return pow(number,secret,self.key.n) 
     60        return cryptomath.numberToString((number * secret) % self.key.n) 
    6161 
    6262class PrivKey(Container): 
     
    7474        return compat.bytesToString(self.key.sign(dataBytes)) 
    7575 
    76     def signnumber(self,number): 
     76    def signblind(self,number): 
    7777        return pow(number,self.key.d,self.key.n) 
    7878 
  • trunk/sandbox/jhb/oc2/rsa.py

    r250 r251  
    22 
    33!!! This is just a playground, for understanding some bits and pieces, 
    4 this is not at all the production code!!! 
     4this is not at all serious crypto production code!!! 
    55 
    66