from samson.ace.consequence import Consequence
from samson.ace.utility import Readable

class DynamicExploit(Readable):
    def __init__(self, attack, consequence, requirements):
        self.attack = attack
        self.consequence  = consequence
        self.requirements = requirements


class KeyPossession(Readable):
    def __init__(self):
        self.consequence  = Consequence.PLAINTEXT_MANIPULATION
        self.requirements = [Consequence.KEY_RECOVERY]


class IdentityExploit(Readable):
    def __init__(self, consequence):
        self.consequence  = consequence
        self.requirements = []


class PlaintextPossession(IdentityExploit):
    def __init__(self):
        self.consequence  = Consequence.PLAINTEXT_RECOVERY
        self.requirements = []


def register_knowns():
    from samson.utilities.runtime import RUNTIME
    RUNTIME.exploits[KeyPossession] = KeyPossession()
    RUNTIME.exploits[PlaintextPossession] = PlaintextPossession()
