def _regen_b3b4(self): """Regenerate b3 and b4. This is the encrypted form of L. """ tw = MCRYPT('twofish', 'ecb') tw.init(self.pprime) self.b3b4 = tw.encrypt(self.hshkey) log.debug("B3/B4 set to %s" % repr(self.b3b4))
def _regen_b1b2(self): """Regenerate b1 and b2. This is the encrypted form of K. """ tw = MCRYPT('twofish', 'ecb') tw.init(self.pprime) self.b1b2 = tw.encrypt(self.enckey) log.debug("B1/B2 set to %s" % repr(self.b1b2))
def encryptXtea(key, iv, str): m = MCRYPT('xtea', 'ecb') key = key.ljust(m.get_key_size(), "\0") iv = iv.ljust(m.get_iv_size(), "\0") m.init(key, iv) return m.encrypt(str)
def encrypt_data(self): """Encrypted fulldata to cryptdata""" tw = MCRYPT('twofish', 'cbc') tw.init(self.enckey, self.iv) self.cryptdata = tw.encrypt(self.fulldata)