コード例 #1
0
ファイル: invite_packet.py プロジェクト: blanu/Dust
  def decodeInvitePacket(self, password, packet):
    #print('decodeInvitePacket('+password+', '+encode(packet)+')')
    self.salt, packet=splitField(packet, SALT_LENGTH)
    #print('salt('+encode(self.salt)+', '+encode(packet)+')')
    sk=pbkdf(password, self.salt)
    #print('sk: '+encode(sk))

    self.decodeDustPacket(sk, packet)
    self.invite=InviteMessage()
    self.invite.decodeInviteMessage(self.data)
    return self.invite
コード例 #2
0
ファイル: skeinUtil.py プロジェクト: blanu/Dust
 def getBytes(self, n):
   self.count=self.count+n
   while len(self.entropy)<n:
     if self.pers:
       result=skein512(self.iv, mac=self.key, pers=self.pers, digest_bits=(BLOCK_SIZE)*8)
     else:
       result=skein512(self.iv, mac=self.key, digest_bits=(BLOCK_SIZE)*8)
     self.entropy=self.entropy+result
     self.iv=result
   b, self.entropy=splitField(self.entropy, n)
   return b
コード例 #3
0
    def decodeInvitePacket(self, password, packet):
        #print('decodeInvitePacket('+password+', '+encode(packet)+')')
        self.salt, packet = splitField(packet, SALT_LENGTH)
        #print('salt('+encode(self.salt)+', '+encode(packet)+')')
        sk = pbkdf(password, self.salt)
        #print('sk: '+encode(sk))

        self.decodeDustPacket(sk, packet)
        self.invite = InviteMessage()
        self.invite.decodeInviteMessage(self.data)
        return self.invite
コード例 #4
0
ファイル: dust_packet.py プロジェクト: pombredanne/Dust
  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:]
コード例 #6
0
 def getBytes(self, n):
     self.count = self.count + n
     while len(self.entropy) < n:
         if self.pers:
             result = skein512(self.iv,
                               mac=self.key,
                               pers=self.pers,
                               digest_bits=(BLOCK_SIZE) * 8)
         else:
             result = skein512(self.iv,
                               mac=self.key,
                               digest_bits=(BLOCK_SIZE) * 8)
         self.entropy = self.entropy + result
         self.iv = result
     b, self.entropy = splitField(self.entropy, n)
     return b
 def decodeDustmailInvitePacket(self, password, packet):
   self.salt, packet=splitField(packet, SALT_LENGTH)
   sk=pbkdf(password, self.salt)
   self.decodeDustPacket(sk, packet)
   self.pubkey, self.invite=splitField(self.data, PUBKEY_LENGTH)