Exemplo n.º 1
0
class MAC_Checker(BasicIntegrity):

    def __init__(self, key, encryption="AES", mode="ECB", hash="SHA"):

        super(MAC_Checker, self).__init__(hash)
        self.decryptobj = BasicEncryption(key, encryption, mode)
        
    def main(self):

        while 1:
            try:
                if self.dataReady("inbox"):

                    (data, mac) = self.recv("inbox")
                    checksum = self.decryptobj.decrypt(mac)
                    if checksum == self.calcHash(data):

                        self.send(data, "outbox")
                    else:                      # we have a hash failure
                        raise IntegrityError  # This mechanism needs improvement
            except IntegrityError:

                print "Integrity Error"
                
            yield 1
Exemplo n.º 2
0
class MAC_Stamper(BasicIntegrity):
    """ Provides message authentication only, message is still sent in plain text
    """
       
    def __init__(self, key,  encryption="AES", mode="ECB", hash="SHA"):

        super(MAC_Stamper,self).__init__(hash)
        self.encryptobj = BasicEncryption(key, encryption, mode)
        
    def main(self):

        while 1:

            if self.dataReady("inbox"):
                data = self.recv("inbox")

                mac = self.encryptobj.encrypt(self.calcHash(data))
                self.send((data, mac), "outbox")
            yield 1
Exemplo n.º 3
0
    def __init__(self, key, encryption="AES", mode="ECB", hash="SHA"):

        super(MAC_Checker, self).__init__(hash)
        self.decryptobj = BasicEncryption(key, encryption, mode)