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
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
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
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
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
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))
def getUser(self, username): """ Get public key of user Returns publickey """ key = Isis.getUserKey(username) if key: return key else: return False
def poll(self, username): """ Get file list of user Returns filelist (encrypted) if success, False otherwise """ return Isis.getKey("files/%s" % username)
def getKey(self, username): """ Get the (encrypted) private key of the user Returns privatekey """ return Isis.getKey("keys/%s" % username)
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),))