2005-03-08 14:07:36 +00:00
|
|
|
#!/usr/bin/python
|
2005-03-02 16:28:09 +00:00
|
|
|
#
|
2006-02-22 15:49:32 +00:00
|
|
|
# protocol list
|
2005-03-02 16:28:09 +00:00
|
|
|
#
|
2005-03-03 11:47:53 +00:00
|
|
|
#
|
2006-02-22 15:49:32 +00:00
|
|
|
import os;
|
|
|
|
|
2006-02-23 10:49:38 +00:00
|
|
|
def basedir():
|
|
|
|
return os.path.expanduser("~/svn/ecss/protocols/spdl/")
|
|
|
|
|
|
|
|
def spdldir():
|
|
|
|
return basedir() + "SPORE/"
|
|
|
|
|
|
|
|
def index(directory):
|
|
|
|
# like os.listdir, but traverses directory trees
|
|
|
|
stack = [directory]
|
|
|
|
files = []
|
|
|
|
while stack:
|
|
|
|
directory = stack.pop()
|
|
|
|
for file in os.listdir(directory):
|
|
|
|
fullname = os.path.join(directory, file)
|
|
|
|
files.append(fullname)
|
|
|
|
if os.path.isdir(fullname) and not os.path.islink(fullname):
|
|
|
|
stack.append(fullname)
|
|
|
|
return files
|
|
|
|
|
2006-03-16 13:58:45 +00:00
|
|
|
def known_problems():
|
|
|
|
return ['needham-schroeder-lowe.spdl', 'kaochow-v2.spdl', 'needham-schroeder-sk.spdl', 'ccitt509-3.spdl', 'denning-sacco-lowe.spdl', 'kaochow-v3.spdl', 'ksl.spdl', 'ksl-lowe.spdl', 'denning-sacco.spdl', 'needham-schroeder-sk-amend.spdl', 'needham-schroeder-sk.spdl', 'andrew-ban-concrete.spdl', 'wmf.spdl', 'yahalom.spdl', 'wmf-lowe.spdl', 'needham-schroeder.spdl']
|
|
|
|
|
2006-02-23 10:49:38 +00:00
|
|
|
def known_good_ones():
|
2006-02-22 15:49:32 +00:00
|
|
|
list = [ \
|
|
|
|
"ccitt509-1c.spdl",
|
|
|
|
"ccitt509-1.spdl",
|
|
|
|
"ccitt509-3.spdl",
|
|
|
|
"ccitt509-ban3.spdl",
|
|
|
|
"denning-sacco-lowe.spdl",
|
|
|
|
"denning-sacco.spdl",
|
|
|
|
"kaochow.spdl",
|
|
|
|
"kaochow-v2.spdl",
|
|
|
|
"kaochow-v3.spdl",
|
|
|
|
"ksl-lowe.spdl",
|
|
|
|
"ksl.spdl",
|
|
|
|
"needham-schroeder-lowe.spdl",
|
|
|
|
"needham-schroeder-sk-amend.spdl",
|
|
|
|
"needham-schroeder-sk.spdl",
|
|
|
|
"neumannstub-hwang.spdl",
|
|
|
|
"neumannstub.spdl",
|
|
|
|
"otwayrees.spdl",
|
|
|
|
"smartright.spdl",
|
|
|
|
"splice-as-cj.spdl",
|
|
|
|
"splice-as-hc.spdl",
|
|
|
|
"splice-as.spdl",
|
|
|
|
"woo-lam-pi-f.spdl",
|
|
|
|
"woo-lam-pi.spdl",
|
|
|
|
"woo-lam.spdl",
|
|
|
|
"yahalom-lowe.spdl",
|
|
|
|
"yahalom-paulson.spdl" ]
|
|
|
|
|
2006-02-23 10:49:38 +00:00
|
|
|
return [ "/" + i for i in list ]
|
|
|
|
|
|
|
|
def spdlextension (fn):
|
|
|
|
return fn.endswith(".spdl")
|
|
|
|
|
|
|
|
def make_lists():
|
|
|
|
"""
|
|
|
|
Returns (from_good_lit, from_bad_lit, others)
|
|
|
|
|
|
|
|
Note that from_good_lit and from_bad_lit together form the spdl directory
|
|
|
|
"""
|
|
|
|
|
|
|
|
good = []
|
|
|
|
bad = []
|
|
|
|
others = []
|
|
|
|
|
|
|
|
# Precompute good names
|
|
|
|
knowngood = known_good_ones()
|
|
|
|
|
|
|
|
l = index(basedir())
|
|
|
|
for file in l:
|
|
|
|
if spdlextension(file):
|
|
|
|
# its a protocol!
|
|
|
|
if file.startswith(spdldir()):
|
|
|
|
# SPORE type
|
|
|
|
goodflag = False
|
|
|
|
for goody in knowngood:
|
|
|
|
if file.endswith(goody):
|
|
|
|
goodflag = True
|
|
|
|
if goodflag:
|
|
|
|
good += [file]
|
|
|
|
else:
|
|
|
|
bad += [file]
|
|
|
|
else:
|
|
|
|
# not SPORE
|
|
|
|
others += [file]
|
|
|
|
|
|
|
|
return (good, bad, others)
|
2005-03-02 16:28:09 +00:00
|
|
|
|
2006-02-23 10:49:38 +00:00
|
|
|
def from_others():
|
|
|
|
(good, bad, others) = make_lists()
|
|
|
|
return others
|
2006-02-22 15:49:32 +00:00
|
|
|
|
2006-02-23 10:49:38 +00:00
|
|
|
def from_good_literature():
|
|
|
|
(good, bad, others) = make_lists()
|
|
|
|
return good
|
2005-03-14 09:58:44 +00:00
|
|
|
|
2006-02-23 10:49:38 +00:00
|
|
|
def from_bad_literature():
|
|
|
|
(good, bad, others) = make_lists()
|
|
|
|
return bad
|
2005-03-03 11:47:53 +00:00
|
|
|
|
2006-02-23 10:49:38 +00:00
|
|
|
def from_literature():
|
|
|
|
(good, bad, others) = make_lists()
|
|
|
|
return good + bad
|
2005-03-02 16:28:09 +00:00
|
|
|
|
2005-03-03 15:25:59 +00:00
|
|
|
def from_all():
|
2006-02-23 10:49:38 +00:00
|
|
|
(good, bad, others) = make_lists()
|
|
|
|
return good + bad + others
|
2005-03-03 15:25:59 +00:00
|
|
|
|
2006-03-16 13:58:45 +00:00
|
|
|
def from_literature_no_problems():
|
|
|
|
bl = from_literature()
|
|
|
|
pl = known_problems()
|
|
|
|
dl = []
|
|
|
|
for p in bl:
|
|
|
|
test = True
|
|
|
|
for pbad in pl:
|
|
|
|
if p.endswith(pbad):
|
|
|
|
test = False
|
|
|
|
if test:
|
|
|
|
dl += [p]
|
|
|
|
return dl
|
|
|
|
|
2005-03-02 16:28:09 +00:00
|
|
|
def select(type):
|
2006-02-23 10:49:38 +00:00
|
|
|
|
|
|
|
(good, bad, others) = make_lists()
|
|
|
|
|
2006-02-22 15:49:32 +00:00
|
|
|
n = int(type)
|
|
|
|
if n == 0:
|
|
|
|
# 0 means all protocols
|
|
|
|
return from_all()
|
|
|
|
elif n == 1:
|
|
|
|
# 1 means from literature
|
|
|
|
return from_literature()
|
|
|
|
elif n == 2:
|
|
|
|
# 2 means from literature, no known attacks
|
|
|
|
return from_good_literature()
|
2006-03-16 13:58:45 +00:00
|
|
|
elif n == 3:
|
|
|
|
# 3 means from litature, without the problem cases
|
|
|
|
return from_good_literature_no_problems()
|
2006-02-22 15:49:32 +00:00
|
|
|
else:
|
|
|
|
# Otherwise empty list
|
|
|
|
return []
|
2005-03-08 14:07:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2006-07-01 10:34:37 +01:00
|
|
|
l = from_all()
|
|
|
|
for f in l:
|
|
|
|
print f
|
2006-02-23 10:49:38 +00:00
|
|
|
|
2005-03-08 14:07:36 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2006-02-22 15:49:32 +00:00
|
|
|
main()
|