def _decrypt(self, password): encKey, authKey = self._deriveKeys(password, self.salt, self.iter_count) macData = self.ciphertext + self.public_key.getRawKey() calcMac = Digest.HMAC_SHA256(authKey, macData) if not Util.constTimeCompare(calcMac, self.mac): raise InvalidPasswordException("Bad password") return AES.create(encKey, bytearray(16)).decrypt(self.ciphertext)
def writeText(self): s =\ """key_sha256 = 0x%s notAfter = %s """ % (\ Util.writeBytes(self.key_sha256), Time.posixTimeToStr(self.notAfter, True)) if self.tackExt: s += "\n" + str(self.tackExt) return s
def __str__(self): s =\ """key_sha256 = %s notAfter = %s """ % (\ Util.writeBytes(self.key_sha256), Time.posixTimeToStr(self.notAfter, True)) if self.tackExt: s += "\n" + str(self.tackExt) return s
def __str__(self): """Return a readable string describing this TACK. Used by the "TACK view" command to display TACK objects.""" s =\ """key fingerprint = %s min_generation = %d generation = %d expiration = %s target_hash = %s\n""" %\ (self.getTackId(), self.min_generation, self.generation, Time.posixTimeToStr(self.expiration*60), Util.writeBytes(self.target_hash)) return s
def __str__(self): """Return a readable string describing this TACK. Used by the "TACK view" command to display TACK objects.""" s =\ """TACK ID = %s min_generation = %d generation = %d expiration = %s target_hash = %s\n""" %\ (self.getTackId(), self.min_generation, self.generation, Time.posixTimeToStr(self.expiration*60), Util.writeBytes(self.target_hash)) return s