示例#1
0
 def removeData(self, username, signature, key):
     """ Remove a block of data from user
     Requires signature of key
     Returns True if success, False otherwise
     """
     if not checkSignature(username, signature, key):
         return False
     Isis.removeKey("data/%s/%s" % (username, key))
     return True
示例#2
0
 def registerKey(self, username, signature, privatekey):
     """ Register a private key with a user
     Requires signature of privatekey
     Returns True if success, False otherwise
     """
     if not checkSignature(username, signature, privatekey):
         print "invalid signature"
         return False
     Isis.putKey(("keys/%s" % username), privatekey)
     return True
示例#3
0
 def updateFile(self, username, signature, data):
     """ Update file list of user
     Requires signature of data
     Data should be encrypted
     Returns True if success, False otherwise
     """
     if not checkSignature(username, signature, data):
         return False
     Isis.putKey(("files/%s" % username), data)
     return True
示例#4
0
 def addData(self, username, signature, key, data):
     """ Add a block of data to a user
     Requires signature of key
     Key should be unique reference for block (sha1 hash)
     Data should be encrypted
     Returns True if success, False otherwise
     """
     if not checkSignature(username, signature, key):
         return False
     Isis.putKey(("data/%s/%s" % (username, key)), data)
     return True
示例#5
0
 def registerUser(self, username, publickey):
     """ Register a username and publickey.
     Returns True if success, False otherwise
     """
     if username and publickey:
         return Isis.registerUser(username, publickey)
     else:
         return False
示例#6
0
 def getData(self, username, signature, key):
     """ Get a block of data from user
     Requires signature of key
     Returns data if success, False otherwise
     """
     if not checkSignature(username, signature, key):
         return False
     return Isis.getKey("data/%s/%s" % (username, key))
示例#7
0
 def getUser(self, username):
     """ Get public key of user
     Returns publickey
     """
     key = Isis.getUserKey(username)
     if key:
         return key
     else:
         return False
示例#8
0
 def poll(self, username):
     """ Get file list of user
     Returns filelist (encrypted) if success, False otherwise
     """
     return Isis.getKey("files/%s" % username)
示例#9
0
 def getKey(self, username):
     """ Get the (encrypted) private key of the user
     Returns privatekey
     """
     return Isis.getKey("keys/%s" % username)
示例#10
0
def checkSignature(username, signature, data):
    publickey = Isis.getUserKey(username)
    instance = RSA.importKey(publickey)
    hash = SHA.new(data).digest()
    return instance.verify(hash, (bytes_to_long(signature),))