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
|
|
|
|
|
|
|
|
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
|
|
|
|
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()
|
|
|
|
else:
|
|
|
|
# Otherwise empty list
|
|
|
|
return []
|
2005-03-08 14:07:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2006-02-23 10:49:38 +00:00
|
|
|
(good, bad, others) = make_lists()
|
|
|
|
|
|
|
|
def show (tag, list):
|
|
|
|
print tag + " (%i)" % len(list)
|
2006-02-22 15:49:32 +00:00
|
|
|
print
|
2006-02-23 10:49:38 +00:00
|
|
|
for l in list:
|
|
|
|
print l
|
|
|
|
|
|
|
|
show ("Good", good)
|
|
|
|
show ("Bad", bad)
|
|
|
|
show ("Others", others)
|
|
|
|
|
2005-03-08 14:07:36 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2006-02-22 15:49:32 +00:00
|
|
|
main()
|