Beispiel #1
0
 def calcMAC_3d(self, s):
     """ Pad string and calculate MAC according to B.1.2.1 - Full 3DES """
     e = DES3.new(self.ses_ENC, DES.MODE_ECB)
     s = pad80(s, 8)
     q = len(s) / 8
     h = ZERO8
     for i in xrange(q):
         h = e.encrypt(bxor(h, s[8 * i:8 * (i + 1)]))
     return h
Beispiel #2
0
 def calcMAC_3d( self, s ):
     """ Pad string and calculate MAC according to B.1.2.1 - Full 3DES """
     e = DES3.new( self.ses_ENC, DES.MODE_ECB )
     s = pad80( s )
     q = len( s ) / 8
     h = ZERO8
     for i in xrange(q):
         h = e.encrypt( bxor( h, s[8*i:8*(i+1)] ))
     return h
Beispiel #3
0
 def calc(self, s):
     " Pad string and calculate MAC according to B.1.2.2 - " +\
         "Single DES plus final 3DES """
     s = pad80(s, 8)
     q = len(s) / 8
     h = '\0' * 8  # zero ICV
     for i in xrange(q):
         h = self.e.encrypt(bxor(h, s[8 * i:8 * (i + 1)]))
     h = self.d.decrypt(h)
     h = self.e.encrypt(h)
     return h
Beispiel #4
0
 def calcMAC_1d(self, s, zResetICV=False):
     " Pad string and calculate MAC according to B.1.2.2 - " +\
         "Single DES plus final 3DES """
     e = DES.new(self.ses_C_MAC[:8], DES.MODE_ECB)
     d = DES.new(self.ses_C_MAC[8:], DES.MODE_ECB)
     s = pad80(s, 8)
     q = len(s) / 8
     h = zResetICV and ZERO8 or self.icv
     for i in xrange(q):
         h = e.encrypt(bxor(h, s[8 * i:8 * (i + 1)]))
     h = d.decrypt(h)
     h = e.encrypt(h)
     self.icv = (self.i & M_ICV_ENC) and self.k_icv.encrypt(h) or h
     return h
Beispiel #5
0
 def calcMAC_1d( self, s, zResetICV = False ):
     " Pad string and calculate MAC according to B.1.2.2 - " +\
         "Single DES plus final 3DES """
     e = DES.new( self.ses_C_MAC[:8], DES.MODE_ECB )
     d = DES.new( self.ses_C_MAC[8:], DES.MODE_ECB )
     s = pad80( s )
     q = len( s ) / 8
     h = zResetICV and ZERO8 or self.icv
     for i in xrange(q):
         h = e.encrypt( bxor( h, s[8*i:8*(i+1)] ))
     h = d.decrypt( h )
     h = e.encrypt( h )
     self.icv = ( self.i & M_ICV_ENC ) and self.k_icv.encrypt( h ) or h
     return h