Ejemplo n.º 1
0
 def DeserializeBody(self, stream):
     # Read values.
     try:
         self.Salt = BinaryStructs.DeserializeBinary(stream, maxlen=16)
         self.Challenge = BinaryStructs.DeserializeBinary(stream, maxlen=32)
     except BinaryStructs.EndOfFile:
         raise IncompletePacket
Ejemplo n.º 2
0
 def DeserializeBody(self, stream):
     # Read data.
     try:
         self.RequestSerial = BinaryStructs.DeserializeUint32(stream)
         self.Username = BinaryStructs.DeserializeUTF8(stream, maxlen=32)
         self.Salt = BinaryStructs.DeserializeBinary(stream, maxlen=16)
         self.PasswordHash = BinaryStructs.DeserializeBinary(stream, 64)
         self.Email = BinaryStructs.DeserializeUTF8(stream, maxlen=64)
     except BinaryStructs.EndOfFile:
         raise IncompletePacket
Ejemplo n.º 3
0
    def Decompress(self, stream):
        '''
        Attempts to decompress a chunk of data.
        
        @raise IncompletePacket: Raised if there is not enough data.
        @raise CorruptPacket: Raised if the data is corrupt.
        
        @return: Decompressed chunk of data.
        '''

        # Try to deserialize the data from the stream.
        try:
            data = BinaryStructs.DeserializeBinary(stream,
                                                   maxlen=MaxCompressedSize)
        except BinaryStructs.EndOfFile:
            raise IncompletePacket

        # Attempt to decompress the data
        try:
            decompressed = zlib.decompress(data)
        except:
            # bad data
            raise CorruptPacket

        # Return the data.
        return decompressed
Ejemplo n.º 4
0
 def DeserializeBody(self, stream):
     # Read data.
     try:
         self.RequestSerial = BinaryStructs.DeserializeUint32(stream)
         self.ChallengeSolution = BinaryStructs.DeserializeBinary(stream,
                                                                  maxlen=32)
     except BinaryStructs.EndOfFile:
         raise IncompletePacket