- Some improvements.
This commit is contained in:
parent
53e7a7c55d
commit
b7f82212c0
@ -6,12 +6,12 @@
|
|||||||
#
|
#
|
||||||
# variant uses some bits:
|
# variant uses some bits:
|
||||||
# bit mask meaning if set to '1'
|
# bit mask meaning if set to '1'
|
||||||
# message type 1
|
# (message type 1)
|
||||||
# 0 1 agents in reverse
|
# 0 1 nonces in reverse
|
||||||
# 1 2 nonces after agents
|
# 1 2 nonces after agents
|
||||||
# 2 4 nonces in reverse
|
# 2 4 agents in reverse
|
||||||
# 3 8 interleaved variant
|
# 3 8 interleaved variant
|
||||||
# message type 2
|
# (message type 2)
|
||||||
# 4 16 nonces in reverse in message 2
|
# 4 16 nonces in reverse in message 2
|
||||||
#
|
#
|
||||||
import sys
|
import sys
|
||||||
|
@ -1,31 +1,56 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
# Idea:
|
||||||
|
#
|
||||||
|
# We test all variants [0..31] until we are sure they work. Thus,
|
||||||
|
# we slowly refine the tests.
|
||||||
|
#
|
||||||
import commands
|
import commands
|
||||||
|
|
||||||
def testvariant(variant):
|
def testvariant(variant,P,runs):
|
||||||
s = "./multinsl-generator.py"
|
s = "./multinsl-generator.py"
|
||||||
s += " 4 %s" % (variant)
|
s += " %i %s" % (P,variant)
|
||||||
s += " | scyther -a -r5 -m2 --summary"
|
s += " | scyther -a -r%i -m2 --summary" % runs
|
||||||
print s
|
#s += " | scyther -a -r%i --summary" % runs
|
||||||
|
#print s
|
||||||
s += " | grep \"failed:\""
|
s += " | grep \"failed:\""
|
||||||
out = commands.getoutput(s)
|
out = commands.getoutput(s)
|
||||||
if out == "":
|
if out == "":
|
||||||
print "Okay"
|
#print "Okay"
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
print out
|
#print out
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def removeattacks (testlist, P, runs):
|
||||||
|
okaylist = []
|
||||||
|
for v in testlist:
|
||||||
|
if testvariant (v, P, runs):
|
||||||
|
okaylist.append(v)
|
||||||
|
return okaylist
|
||||||
|
|
||||||
|
def scan(testlist, P, runs):
|
||||||
|
print "Testing using P %i and %i runs." % (P,runs)
|
||||||
|
results = removeattacks (testlist, P, runs)
|
||||||
|
if len(results) < len(testlist):
|
||||||
|
attacked = []
|
||||||
|
for i in range(0,len(testlist)):
|
||||||
|
if testlist[i] not in results:
|
||||||
|
attacked.append(testlist[i])
|
||||||
|
print "Using P %i and %i runs, we find attacks on %s" % (P,runs, str(attacked))
|
||||||
|
print "Therefore, we are left with %i candidates: " % (len(testlist)), results
|
||||||
|
|
||||||
|
return results
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
good = []
|
candidates = range(0,32)
|
||||||
for i in range (0,32):
|
for P in range(2,7):
|
||||||
print i
|
for runs in range(P-1,P+2):
|
||||||
if testvariant (i):
|
candidates = scan(candidates,P,runs)
|
||||||
good.append(i)
|
|
||||||
print
|
print
|
||||||
print "Good variants:"
|
print "Good variants:"
|
||||||
print good
|
print candidates
|
||||||
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user