def eval_lookup(): import platform import csv import time sample_no = 10000 writer = csv.writer(open("lookup_" + platform.system() +"_"+ platform.node() +"_"+ platform.release()+ "_" + platform.processor() + ".csv","ab")) testAPDB = APdb(Itemsfile="EVALDB.db",SAfile="EVALSADB.db") said1 = testAPDB.addSA(address="00:00:00:00:00:FF", key=sofi_crypt.singleHash("THISISMYKEYKEYKEY"), chained=False, chainIndex=0, name="horst") said2 = testAPDB.addSA(address="00:00:00:00:DE:AD", key=sofi_crypt.singleHash("THISISMYKEYKEYKEY"), chained=False, chainIndex=0, name="dings") item1 = testAPDB.addDataItem(location="/bin/bash", descString="bin bash", serviceId=2, private=True, ACL=[said1,said2]) item2 = testAPDB.addDataItem(location="/bin/false", descString="bin false", serviceId=2, private=False, ACL=[]) SAid1 = testAPDB.getSA(said1) for i in xrange(6): result_list = ["%s" %(10**i)] for _j in xrange(10**i): testAPDB.addDataItem(location=''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(50)), descString=''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(30)), serviceId=2, private=True, ACL=[said1,said2]) for _k in xrange(sample_no): key = sofi_crypt.xorDecode(item1.getSearchHash(),SAid1.getKey()) Address=SAid1.getAddress() start_time = time.time() SA,iteml = testAPDB.getAvailable(key,Address=Address) end_time = time.time() result_list.append(end_time - start_time) writer.writerow(result_list)
def eval_lookup(): import platform import csv import time sample_no = 10000 writer = csv.writer( open( "lookup_" + platform.system() + "_" + platform.node() + "_" + platform.release() + "_" + platform.processor() + ".csv", "ab")) testAPDB = APdb(Itemsfile="EVALDB.db", SAfile="EVALSADB.db") said1 = testAPDB.addSA(address="00:00:00:00:00:FF", key=sofi_crypt.singleHash("THISISMYKEYKEYKEY"), chained=False, chainIndex=0, name="horst") said2 = testAPDB.addSA(address="00:00:00:00:DE:AD", key=sofi_crypt.singleHash("THISISMYKEYKEYKEY"), chained=False, chainIndex=0, name="dings") item1 = testAPDB.addDataItem(location="/bin/bash", descString="bin bash", serviceId=2, private=True, ACL=[said1, said2]) item2 = testAPDB.addDataItem(location="/bin/false", descString="bin false", serviceId=2, private=False, ACL=[]) SAid1 = testAPDB.getSA(said1) for i in xrange(6): result_list = ["%s" % (10**i)] for _j in xrange(10**i): testAPDB.addDataItem(location=''.join( random.choice(string.ascii_uppercase + string.digits) for x in range(50)), descString=''.join( random.choice(string.ascii_uppercase + string.digits) for x in range(30)), serviceId=2, private=True, ACL=[said1, said2]) for _k in xrange(sample_no): key = sofi_crypt.xorDecode(item1.getSearchHash(), SAid1.getKey()) Address = SAid1.getAddress() start_time = time.time() SA, iteml = testAPDB.getAvailable(key, Address=Address) end_time = time.time() result_list.append(end_time - start_time) writer.writerow(result_list)
def test(): myhash = sofi_crypt.singleHash( "hashStringhashString ABCDEFGHIJKLMNOPQRSTUVWXYZ") print "Creating SSID Object from Config with with Hash:" ssid1 = ssid(hashString=myhash, native=True, private=False, request=True, reply=False, service=1, Comid=255) print "SSID: %s" % ssid1.toString() print "Service: %s" % ssid1.getService() print "Hash: %s" % ssid1.getHash() print "ID: %s" % ssid1.getID() print "Creating SSID Object from SSID String:" ssid2 = ssid(SSID=ssid1.toString()) print "SSID: %s" % ssid2.toString() print "Service: %s" % ssid2.getService() print "Hash: %s" % ssid2.getHash() print "ID: %s" % ssid2.getID() if (ssid1.toString() == ssid2.toString() and ssid1.getService() == ssid2.getService() and ssid1.getHash() == ssid2.getHash() and ssid1.getID() == ssid2.getID() and ssid1 != ssid2): print "SSIDs match! Successful conversion!" else: print "SSIDs do not match, or are the same Object! FAILURE!"
def test(): myhash = sofi_crypt.singleHash("hashStringhashString ABCDEFGHIJKLMNOPQRSTUVWXYZ") print "Creating SSID Object from Config with with Hash:" ssid1 = ssid(hashString=myhash, native=True, private=False, request=True, reply=False, service=1, Comid=255) print "SSID: %s" % ssid1.toString() print "Service: %s" % ssid1.getService() print "Hash: %s" % ssid1.getHash() print "ID: %s" % ssid1.getID() print "Creating SSID Object from SSID String:" ssid2 = ssid(SSID=ssid1.toString()) print "SSID: %s" % ssid2.toString() print "Service: %s" % ssid2.getService() print "Hash: %s" % ssid2.getHash() print "ID: %s" % ssid2.getID() if ( ssid1.toString() == ssid2.toString() and ssid1.getService() == ssid2.getService() and ssid1.getHash() == ssid2.getHash() and ssid1.getID() == ssid2.getID() and ssid1 != ssid2 ): print "SSIDs match! Successful conversion!" else: print "SSIDs do not match, or are the same Object! FAILURE!"
def speed_test(num_items): print "Loading Database..." start_time = time.clock() testAPDB = APdb() finish_time = time.clock() - start_time a = finish_time print "Database with %s items loaded in %.09f sec" %(len(testAPDB.getdataItems()),finish_time) said1 = testAPDB.addSA(address="00:00:00:00:00:FF", key=sofi_crypt.singleHash("THISISMYKEYKEYKEY"), chained=False, chainIndex=0, name="horst") said2 = testAPDB.addSA(address="00:00:00:00:DE:AD", key=sofi_crypt.singleHash("THISISMYKEYKEYKEY"), chained=False, chainIndex=0, name="dings") item1 = testAPDB.addDataItem(location="/bin/bash", descString="bin bash", serviceId=2, private=True, ACL=[said1,said2]) item2 = testAPDB.addDataItem(location="/bin/false", descString="bin false", serviceId=2, private=False, ACL=[]) print "Adding %s items..." %num_items start_time = time.clock() for i in range(num_items): testAPDB.addDataItem(location=''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(50)), descString=''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(30)), serviceId=2, private=True, ACL=[said1,said2]) finish_time = time.clock() - start_time b = finish_time print "Finished adding %s items in %0.6f sec" %(num_items,finish_time) SAid1 = testAPDB.getSA(said1) print "Staring search..." start_time = time.clock() SA,iteml = testAPDB.getAvailable(sofi_crypt.xorDecode(item1.getSearchHash(),SAid1.getKey()),Address=SAid1.getAddress()) finish_time = time.clock() - start_time c = finish_time #SA,iteml = testAPDB.getAvailable(item1.getSearchHash(),said1) if(len(iteml)>0): print "Found %s items." %len(iteml) print "Search finished in %.012f sec" %finish_time print "Saving Database..." start_time = time.clock() testAPDB.save() finish_time = time.clock() - start_time d = finish_time print "Finished saving Database with %s entries in %.09f sec." %(len(testAPDB.getdataItems()),finish_time) print "Currently holding %s security associations." %len(testAPDB.getSAs()) return (len(testAPDB.getdataItems()),finish_time),a,b,c,d
def station_test(): stationDB = STAdb() print "Hostslist: %s" % stationDB.getHostList() host1 = stationDB.addHost(myaddress="00:00:DE:AD:BE:EF", remoteaddress="00:00:00:00:AF:FE", key=sofi_crypt.singleHash("THISISMYKEYKEYKEY"), chained=False, chainIndex=0, name="horst") print "Host added: %s" % host1 host = stationDB.getHost(remoteaddress="00:00:00:00:AF:FE") print "Host searched by remoteaddress: %s" % host host = stationDB.getHost(name="horst") print "Host searched by name: %s" % host SAId = host1.getSAId() host = stationDB.getHost(SAId=SAId) print "Host searched by ID: %s" % host print "Hostslist: %s" % stationDB.getHostList() print "SA searched by ID: %s" % stationDB.getSAbyID(SAId) print "SA List: %s" % stationDB.getSAList() stationDB.save() print "Saved Database."
def station_test(): stationDB = STAdb() print "Hostslist: %s" %stationDB.getHostList() host1 = stationDB.addHost(myaddress="00:00:DE:AD:BE:EF", remoteaddress="00:00:00:00:AF:FE", key = sofi_crypt.singleHash("THISISMYKEYKEYKEY"), chained=False, chainIndex=0, name="horst") print "Host added: %s" %host1 host = stationDB.getHost(remoteaddress="00:00:00:00:AF:FE") print "Host searched by remoteaddress: %s" %host host = stationDB.getHost(name="horst") print "Host searched by name: %s" %host SAId = host1.getSAId() host = stationDB.getHost(SAId=SAId) print "Host searched by ID: %s" %host print "Hostslist: %s" %stationDB.getHostList() print "SA searched by ID: %s" %stationDB.getSAbyID(SAId) print "SA List: %s" %stationDB.getSAList() stationDB.save() print "Saved Database."
def _eval_doubleHash(self, hashString): hash1 = sofi_crypt.singleHash(hashString) hash2 = sofi_crypt.singleHash(hash1) self._hashlist = [hash1,hash2]
def _eval_singleHash(self, hashString): self._hashlist = sofi_crypt.singleHash(hashString)
def speed_test(num_items): print "Loading Database..." start_time = time.clock() testAPDB = APdb() finish_time = time.clock() - start_time a = finish_time print "Database with %s items loaded in %.09f sec" % (len( testAPDB.getdataItems()), finish_time) said1 = testAPDB.addSA(address="00:00:00:00:00:FF", key=sofi_crypt.singleHash("THISISMYKEYKEYKEY"), chained=False, chainIndex=0, name="horst") said2 = testAPDB.addSA(address="00:00:00:00:DE:AD", key=sofi_crypt.singleHash("THISISMYKEYKEYKEY"), chained=False, chainIndex=0, name="dings") item1 = testAPDB.addDataItem(location="/bin/bash", descString="bin bash", serviceId=2, private=True, ACL=[said1, said2]) item2 = testAPDB.addDataItem(location="/bin/false", descString="bin false", serviceId=2, private=False, ACL=[]) print "Adding %s items..." % num_items start_time = time.clock() for i in range(num_items): testAPDB.addDataItem(location=''.join( random.choice(string.ascii_uppercase + string.digits) for x in range(50)), descString=''.join( random.choice(string.ascii_uppercase + string.digits) for x in range(30)), serviceId=2, private=True, ACL=[said1, said2]) finish_time = time.clock() - start_time b = finish_time print "Finished adding %s items in %0.6f sec" % (num_items, finish_time) SAid1 = testAPDB.getSA(said1) print "Staring search..." start_time = time.clock() SA, iteml = testAPDB.getAvailable(sofi_crypt.xorDecode( item1.getSearchHash(), SAid1.getKey()), Address=SAid1.getAddress()) finish_time = time.clock() - start_time c = finish_time #SA,iteml = testAPDB.getAvailable(item1.getSearchHash(),said1) if (len(iteml) > 0): print "Found %s items." % len(iteml) print "Search finished in %.012f sec" % finish_time print "Saving Database..." start_time = time.clock() testAPDB.save() finish_time = time.clock() - start_time d = finish_time print "Finished saving Database with %s entries in %.09f sec." % (len( testAPDB.getdataItems()), finish_time) print "Currently holding %s security associations." % len( testAPDB.getSAs()) return (len(testAPDB.getdataItems()), finish_time), a, b, c, d
def _eval_doubleHash(self, hashString): hash1 = sofi_crypt.singleHash(hashString) hash2 = sofi_crypt.singleHash(hash1) self._hashlist = [hash1, hash2]