def __signBlocks(self, publicKey, privateKey): # we want to be able to mask out fields we disagree with signatures = [] publicKeyString = rsa.keystring(publicKey) for item in self.__data: if item[0] is "block": hash = self.__findNamedItem("hash", item[1]) if hash and hash[1]: signed = rsa.sign(hash, privateKey) signatures.append(("sign", [("key", publicKeyString), ("hash", hash[1])], [signed])) elif not item[0] is "sign": raise SyntaxError("We have a top level item that is not 'sign' and is not 'block'") self.__data.extend(signatures)
x.set("description", "Original test document") x.set( "chunks", properties=[("size", "1024")], value=[ ("chunk", [], ["5435364567457"]), ("chunk", [], ["6547756785678"]), ("chunk", [], ["4346547658565"]), ("chunk", [], ["4578758768675"]), ("chunk", [], ["6677658585756"]), ], ) print x.get("name") print "Generating first key" (publicKey, privateKey) = rsa.gen_pubpriv_keys(128) trust = {rsa.keystring(publicKey): {"good": 3, "bad": 1}} print "signing first data" x.sign(publicKey, privateKey) print x.get("name", trust) x.set("name", "Test.txt") print x.get("name", trust) print "Generating second key" (publicKey2, privateKey2) = rsa.gen_pubpriv_keys(128) trust[rsa.keystring(publicKey2)] = {"good": 1, "bad": 2} print "signing second data" x.sign(publicKey2, privateKey2) print x.get("name", trust) x.sign(publicKey, privateKey) print x.get("name", trust) print x