Ejemplo n.º 1
0
    def hash(self, sa, da, priority, msduData ):
        """ The TKIP MIC appends sa, da and priority to msduData
            and uses the result in the Michael keyed hash
            to create an 8 octet MIC value
        """
        assert( 0 <= priority <= 15 ), 'Priority must be 4 bit value'
        assert( (len(sa)==6) and (len(da)==6) ), 'Addresses must be 6 octets'

        if self.version == 'D3':
            micData = da + sa + chr(priority) + 3*chr(0) + msduData
        elif self.version == 'D2':
            micData = da + sa + msduData
        else:
            raise 'bad version'

        return Michael.hash(self, micData)
Ejemplo n.º 2
0
    def hash(self, sa, da, priority, msduData ):
        """ The TKIP MIC appends sa, da and priority to msduData
            and uses the result in the Michael keyed hash
            to create an 8 octet MIC value
        """
        assert( 0 <= priority <= 15 ), 'Priority must be 4 bit value'
        assert( (len(sa)==6) and (len(da)==6) ), 'Addresses must be 6 octets'

        if self.version == 'D3':
            micData = da + sa + chr(priority) + 3*chr(0) + msduData
        elif self.version == 'D2':
            micData = da + sa + msduData
        else:
            raise 'bad version'

        return Michael.hash(self, micData)
Ejemplo n.º 3
0
        def runSingleTest(key, data, micResult):
            print "============================="
            key = a2b_hex(key)
            knownMICResult = a2b_hex(micResult)
            print "key:      ", b2a_hex(key)
            print "data:     ", b2a_hex(data)
            print "knownMIC: ", b2a_hex(knownMICResult)
            micAlg = Michael(key)
            calculatedMIC = micAlg.hash(data)
            print "CalcMIC:  ", b2a_hex(calculatedMIC)
            self.assertEqual(calculatedMIC, knownMICResult)

            # alternate calling sequence
            micAlg = Michael()
            micAlg.setKey(key)
            calculatedMIC = micAlg.hash(data)
            self.assertEqual(calculatedMIC, knownMICResult)

            # yet another way to use algorithm
            calculatedMIC = micAlg(data)
            self.assertEqual(calculatedMIC, knownMICResult)
Ejemplo n.º 4
0
        def runSingleTest(key,data,micResult):
            print "============================="
            key = a2b_hex(key)
            knownMICResult = a2b_hex(micResult)
            print "key:      ",b2a_hex(key)
            print "data:     ",b2a_hex(data)
            print "knownMIC: ", b2a_hex(knownMICResult)
            micAlg = Michael(key)
            calculatedMIC = micAlg.hash(data)
            print "CalcMIC:  ", b2a_hex(calculatedMIC)
            self.assertEqual( calculatedMIC, knownMICResult )

            # alternate calling sequence
            micAlg = Michael()
            micAlg.setKey(key)
            calculatedMIC = micAlg.hash(data)
            self.assertEqual( calculatedMIC, knownMICResult )

            # yet another way to use algorithm
            calculatedMIC = micAlg(data)
            self.assertEqual( calculatedMIC, knownMICResult )
Ejemplo n.º 5
0
 def __init__(self, key=None, version='D3'):
     """ """
     self.version = version
     Michael.__init__(self, key)
Ejemplo n.º 6
0
 def __init__(self, key=None, version='D3'):
     """ """
     self.version = version
     Michael.__init__(self,key)