scyther/gui/Scyther/Attack.py

72 lines
2.3 KiB
Python
Raw Normal View History

2007-06-11 13:09:24 +01:00
"""
Scyther : An automatic verifier for security protocols.
2013-10-05 23:56:12 +01:00
Copyright (C) 2007-2013 Cas Cremers
2007-06-11 13:09:24 +01:00
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""
2006-08-02 13:59:57 +01:00
#
# Attack
#
2020-10-27 21:09:03 +00:00
from . import Trace
from . import Term
2006-08-02 13:59:57 +01:00
#import Classification
2020-10-27 21:09:03 +00:00
from .Misc import *
2006-08-02 13:59:57 +01:00
class Attack(object):
def __init__(self):
self.broken = []
self.match = None
self.initialKnowledge = []
self.inverseKeys = []
self.protocol = None
self.semiTrace = Trace.SemiTrace()
self.variables = []
self.protocoldescr = {}
self.id = None
self.knowledge = None
self.untrusted = []
self.typeflaws = False
self.commandline = ''
self.scytherDot = None
self.claim = None # refers to parent claim
def getInvolvedAgents(self):
result = []
for run in self.semiTrace.runs:
2020-10-27 21:09:03 +00:00
for agent in list(run.roleAgents.values()):
2006-08-02 13:59:57 +01:00
result.append(agent)
return uniq(result)
def buildKnowledge(self):
if not self.knowledge:
self.knowledge = Term.Knowledge(self)
self.knowledge.buildKnowledge()
def getPrecedingLabelSet(self,event):
return self.protocoldescr[str(event.label[0])].getPrecedingLabelSet(event.label)
def getPrecedingRoleSet(self,event):
return self.protocoldescr[str(event.label[0])].getPrecedingRoleSet(event.label)
#def classify(self):
# classification = Classification.Classification(self)
# classification.classifyClaims()
# classification.classifyInitiations()
# classification.classifyComplexity()
# classification.classifyTypeflaws()
# return classification