Exemplo n.º 1
0
  def decodeDustPacket(self, key, packet):
    self.key=key
    self.packet=packet

    self.ciphertext=self.payload
    self.encrypted=self.ciphertext
    self.payload=decrypt(self.key, self.iv, self.encrypted)

    self.data=self.payload

    self.ciphertext=self.data
Exemplo n.º 2
0
  def decodeDustPacket(self, key, packet):
    self.key=key
    self.packet=packet

    self.mac, self.ciphertext=splitField(self.packet, MAC_SIZE)
    self.iv, self.encrypted=splitField(self.ciphertext, IV_SIZE)
    self.payload=decrypt(self.key, self.iv, self.encrypted)

    self.timestamp, self.dataLength, self.paddingLength, self.data=splitFields(self.payload, [TIMESTAMP_SIZE, DATA_LENGTH_SIZE, PADDING_LENGTH_SIZE])
    self.timestamp=struct.unpack("I", self.timestamp)[0]
    self.dataLength=struct.unpack("H", self.dataLength)[0]
    self.paddingLength=struct.unpack("B", self.paddingLength)[0]

    self.data, extra=splitField(self.data, self.dataLength)

    payloadLength=TIMESTAMP_SIZE+DATA_LENGTH_SIZE+PADDING_LENGTH_SIZE+len(self.data)
    self.payload=self.payload[:payloadLength]

    ciphertextLength=IV_SIZE+payloadLength
    self.ciphertext=self.ciphertext[:ciphertextLength]

    realPacketLength=MAC_SIZE+ciphertextLength+self.paddingLength
    if len(packet)>realPacketLength:
      self.remaining=packet[realPacketLength:]
  def decodeDustPacket(self, key, packet):
    self.key=key
    self.packet=packet

    self.mac, self.ciphertext=splitField(self.packet, MAC_SIZE)
    self.iv, self.encrypted=splitField(self.ciphertext, IV_SIZE)
    self.payload=decrypt(self.key, self.iv, self.encrypted)

    self.timestamp, self.dataLength, self.paddingLength, self.data=splitFields(self.payload, [TIMESTAMP_SIZE, DATA_LENGTH_SIZE, PADDING_LENGTH_SIZE])
    self.timestamp=struct.unpack("I", self.timestamp)[0]
    self.dataLength=struct.unpack("H", self.dataLength)[0]
    self.paddingLength=struct.unpack("B", self.paddingLength)[0]

    self.data, extra=splitField(self.data, self.dataLength)

    payloadLength=TIMESTAMP_SIZE+DATA_LENGTH_SIZE+PADDING_LENGTH_SIZE+len(self.data)
    self.payload=self.payload[:payloadLength]

    ciphertextLength=IV_SIZE+payloadLength
    self.ciphertext=self.ciphertext[:ciphertextLength]

    realPacketLength=MAC_SIZE+ciphertextLength+self.paddingLength
    if len(packet)>realPacketLength:
      self.remaining=packet[realPacketLength:]