def __init__(self, data=None, password=None): if data is None: return TlsStructure.__init__(self, data) if len(data) != TackKeyFile.LENGTH: raise SyntaxError( "Key File is the wrong size. Is %s and should be %s." % (len(data), TackKeyFile.LENGTH)) self.version = self.getInt(1) if self.version != 1: raise SyntaxError("Bad version in Key File") self.iter_count = self.getInt(4) self.salt = self.getBytes(16) self.ciphertext = self.getBytes(32) self.public_key = ECPublicKey.create(self.getBytes(64)) self.mac = self.getBytes(32) if password is not None: rawPrivateKey = self._decrypt(password) self.private_key = ECPrivateKey.create(rawPrivateKey, self.public_key.getRawKey())
def __init__(self, data=None): if data is None: return TlsStructure.__init__(self, data) if len(data) != TackBreakSig.LENGTH: raise SyntaxError("Break signature is the wrong size. Is %s and should be %s." % (len(data), TackBreakSig.LENGTH)) self.public_key = ECPublicKey.create(self.getBytes(64)) self.signature = self.getBytes(64) if not self.verifySignature(): raise SyntaxError("TACK_Break_Sig has bad signature")
def __init__(self, data=None): if data is None: return TlsStructure.__init__(self, data) if len(data) != Tack.LENGTH: raise SyntaxError("Tack is the wrong size. Is %s and should be %s" % (len(data), Tack.LENGTH)) self.public_key = ECPublicKey.create(self.getBytes(64)) self.min_generation = self.getInt(1) self.generation = self.getInt(1) self.expiration = self.getInt(4) self.target_hash = self.getBytes(32) self.signature = self.getBytes(64) if self.generation < self.min_generation: raise SyntaxError("Generation less than min_generation") if not self.verifySignature(): raise SyntaxError("Tack has bad signature")
def __init__(self, data=None): if data is None: return TlsStructure.__init__(self, data) if len(data) != Tack.LENGTH: raise SyntaxError( "Tack is the wrong size. Is %s and should be %s" % (len(data), Tack.LENGTH)) self.public_key = ECPublicKey.create(self.getBytes(64)) self.min_generation = self.getInt(1) self.generation = self.getInt(1) self.expiration = self.getInt(4) self.target_hash = self.getBytes(32) self.signature = self.getBytes(64) if self.generation < self.min_generation: raise SyntaxError("Generation less than min_generation") if not self.verifySignature(): raise SyntaxError("Tack has bad signature")
def __init__(self, data=None, password=None): if data is None: return TlsStructure.__init__(self, data) if len(data) != TackKeyFile.LENGTH: raise SyntaxError("Key File is the wrong size. Is %s and should be %s." % (len(data), TackKeyFile.LENGTH)) self.version = self.getInt(1) if self.version != 1: raise SyntaxError("Bad version in Key File") self.iter_count = self.getInt(4) self.salt = self.getBytes(16) self.ciphertext = self.getBytes(32) self.public_key = ECPublicKey.create(self.getBytes(64)) self.mac = self.getBytes(32) if password is not None: rawPrivateKey = self._decrypt(password) self.private_key = ECPrivateKey.create(rawPrivateKey, self.public_key.getRawKey())