Esempio n. 1
0
File: reader.py Progetto: blanu/Dust
  def __init__(self, router, endpoint):
    self.router=router
    self.endpoint=endpoint

    self.keys=router.keys
    self.maildir='spool/'+encode(endpoint.public.bytes)
    self.addressBook=YamlMap('config/dustmail-addressbook.yaml')
    self.done=Event()
    self.commandDone=Event()

    self.book=YamlMap('config/dustmail-addressbook.yaml')

    dustmailConfig=YamlMap('config/dustmail-config.yaml')

    try:
      destAddress=dustmailConfig['tracker']
    except:
      entry=self.addInvite()
      destAddress=entry['tracker']
      dustmailConfig['tracker']=destAddress

    dest, outport, v6=decodeAddress(destAddress)

    print('Registering with tracker...')
    self.tracker=TrackerClient(self.router, addr=(dest, outport))

    host=getPublicIP(v6)
    inport=dustmailConfig['port']
    self.tracker.putPeerForEndpoint(encode(self.endpoint.public.bytes), [encode(self.endpoint.public.bytes), encodeAddress((host,inport))])

    invite=self.keys.generateInvite(inport, v6=v6)
    self.tracker.putInviteForPeer(encodeAddress((host, inport)), encode(invite.message))

    self.trackback=self.router.getService('trackback')
Esempio n. 2
0
 def __init__(self, tracker, trackback, dustmail, keypair, endkey, msg):
   self.dustmail=dustmail
   self.keypair=keypair
   self.endkey=endkey
   self.msg=msg
   trackback.setPutPeerForEndpointCallback(encode(endkey.bytes), self.foundPeer)
   tracker.getPeerForEndpoint(encode(endkey.bytes))
Esempio n. 3
0
  def sendMessage(self, message):
    print('sendMessage '+str(message))

    onion=OnionPacket()
    onion.decodeOnionPacket(self.router.keys.getKeypair(), decode(message))
    frm=encode(onion.sender)
    to=encode(onion.receiver)

    print('frm: '+str(frm))
    print('to: '+str(to))

    if not os.path.exists(self.maildir+'/'+to):
      os.mkdir(self.maildir+'/'+to)

    filename=None
    while not filename or os.path.exists(filename):
      filename=self.makeName(frm, to)
    f=open(filename, 'w')
    f.write(message)
    f.close()

    notifyPrefs=YamlMap('config/dustmail-notify.yaml')
    try:
      mailAddr=notifyPrefs[to]

      addressBook=YamlMap('config/dustmail-addressbook.yaml')
      frmName=self.nameForPubkey(addressBook, frm)
      if not frmName:
        frmName=frm

      notifier=Notifier('*****@*****.**')
      notifier.notify(mailAddr, 'New DustMail Message', "You have a DustMail message from "+frmName+".")
    except KeyError:
      print('No notification set')
Esempio n. 4
0
  def saveKeypair(self, filename):
    pubkey=encode(self.keypair.public.bytes)
    privkey=encode(self.keypair.secret.bytes)
    pair=[pubkey, privkey]

    f=open(filename, 'w')
    f.write(yaml.dump(pair))
    f.close()
Esempio n. 5
0
  def saveKeypair(self, filename):
    pubkey=encode(self.keypair.public.bytes)
    privkey=encode(self.keypair.secret.bytes)
    pair=[pubkey, privkey]

    f=open(filename, 'w')
    f.write(yaml.dump(pair))
    f.close()
 def __init__(self, keys, router, tracker, trackback, keypair, endkey, msg):
   self.keys=keys
   self.router=router
   self.keypair=keypair
   self.endkey=endkey
   self.msg=msg
   trackback.setPutPeerForEndpointCallback(encode(endkey), self.foundPeer)
   tracker.getPeerForEndpoint(encode(endkey))
Esempio n. 7
0
 def __init__(self, tracker, trackback, dustmail, keypair, endkey, msg):
     self.dustmail = dustmail
     self.keypair = keypair
     self.endkey = endkey
     self.msg = msg
     trackback.setPutPeerForEndpointCallback(encode(endkey.bytes),
                                             self.foundPeer)
     tracker.getPeerForEndpoint(encode(endkey.bytes))
Esempio n. 8
0
 def foundPeer(self, endkey, peer):
   print('foundPeer!!! '+str(endkey)+' '+str(peer))
   destkey=decode(peer[0])
   addr=peer[1]
   data=self.msg.encode('ascii')
   sessionKey=keypair.createSession(Key(destkey, False))
   print('session '+str(sessionKey.bytes))
   packet=DataPacket()
   packet.createDataPacket(sessionKey.bytes, data, keys.entropy)
   self.dustmail.sendMessage(encode(self.keypair.public.bytes), encode(destkey), encode(packet.packet))
Esempio n. 9
0
 def __str__(self):
     s = "[\n"
     s = s + '  pubkey: ' + encode(self.pubkey.bytes) + "\n"
     s = s + '  v6:     ' + str(self.v6) + "\n"
     s = s + '  tcp:    ' + str(self.tcp) + "\n"
     s = s + '  ip:     ' + self.ip + "\n"
     s = s + '  port:   ' + str(self.port) + "\n"
     s = s + '  id:     ' + encode(self.id) + "\n"
     s = s + '  secret: ' + encode(self.secret) + "\n"
     s = s + "]\n"
     return s
Esempio n. 10
0
 def __str__(self):
   s="[\n"
   s=s+'  pubkey: '+encode(self.pubkey.bytes)+"\n"
   s=s+'  v6:     '+str(self.v6)+"\n"
   s=s+'  tcp:    '+str(self.tcp)+"\n"
   s=s+'  ip:     '+self.ip+"\n"
   s=s+'  port:   '+str(self.port)+"\n"
   s=s+'  id:     '+encode(self.id)+"\n"
   s=s+'  secret: '+encode(self.secret)+"\n"
   s=s+"]\n"
   return s
Esempio n. 11
0
 def foundPeer(self, endkey, peer):
     print('foundPeer!!! ' + str(endkey) + ' ' + str(peer))
     destkey = decode(peer[0])
     addr = peer[1]
     data = self.msg.encode('ascii')
     sessionKey = keypair.createSession(Key(destkey, False))
     print('session ' + str(sessionKey.bytes))
     packet = DataPacket()
     packet.createDataPacket(sessionKey.bytes, data, keys.entropy)
     self.dustmail.sendMessage(encode(self.keypair.public.bytes),
                               encode(destkey), encode(packet.packet))
Esempio n. 12
0
 def decodeOnionPacket(self, keypair, packet):
     self.sender, self.receiver, packet = splitFields(
         packet, [SENDER_LENGTH, RECEIVER_LENGTH])
     if keypair.public.bytes != self.receiver:
         print(
             'Error! Onion packet meant for a different receiver. Keypair does not match: '
             + encode(self.sender) + ' ' + encode(self.receiver) + ' ' +
             encode(keypair.public.bytes))
         return
     else:
         skb = keypair.createSessionBytes(self.sender)
         self.decodeDataPacket(skb, packet)
  def __str__(self):
    s="[\n"

    if self.key:
      s=s+"  key: "+encode(self.key)+"\n"
    else:
      s=s+"  key: None\n"

    if self.checkMac():
      s=s+'  MAC: '+encode(self.mac)+" OK\n"
    else:
      s=s+'  MAC: '+encode(self.mac)+" Failed\n"

    s=s+'  IV: '+encode(self.iv)+"\n"

    s=s+"  payload: "+encode(self.payload)+"\n"

    if self.checkTimestamp():
      s=s+'  timestamp: '+str(self.timestamp)+" OK\n"
    else:
      s=s+'  timestamp: '+str(self.timestamp)+" Failed\n"

    s=s+'  dataLength: '+str(self.dataLength)+"\n"
    s=s+'  paddingLength: '+str(self.paddingLength)+"\n"
    s=s+'  data: '+str(encode(self.data))+"\n"
    if self.padding:
      s=s+'  padding: '+encode(self.padding)+"\n"
    else:
      s=s+"  padding: None\n"
    if self.remaining:
      s=s+'  remaining: '+encode(self.remaining)+"\n"
    else:
      s=s+"  remaining: None\n"
    s=s+"]\n"
    return s
Esempio n. 14
0
 def decodeOnionPacket(self, keypair, packet):
     self.sender, self.receiver, packet = splitFields(packet, [SENDER_LENGTH, RECEIVER_LENGTH])
     if keypair.public.bytes != self.receiver:
         print(
             "Error! Onion packet meant for a different receiver. Keypair does not match: "
             + encode(self.sender)
             + " "
             + encode(self.receiver)
             + " "
             + encode(keypair.public.bytes)
         )
         return
     else:
         skb = keypair.createSessionBytes(self.sender)
         self.decodeDataPacket(skb, packet)
    def __init__(self, router, endpoint):
        self.router = router
        self.endpoint = endpoint

        self.keys = router.keys
        self.maildir = 'spool/' + encode(endpoint.public.bytes)
        self.addressBook = YamlMap('config/dustmail-addressbook.yaml')
        self.done = Event()
        self.commandDone = Event()

        self.book = YamlMap('config/dustmail-addressbook.yaml')

        dustmailConfig = YamlMap('config/dustmail-config.yaml')

        try:
            destAddress = dustmailConfig['tracker']
        except:
            entry = self.addInvite()
            destAddress = entry['tracker']
            dustmailConfig['tracker'] = destAddress

        dest, outport, v6 = decodeAddress(destAddress)

        host = getPublicIP(v6)
        inport = dustmailConfig['port']

        invite = self.keys.generateInvite(inport, v6=v6)
    def addInvite(self):
        pf = input("Load invite from Paste or File [P/f]? ")
        if pf == 'f':
            filename = input("Load invite from filename: ").strip()
            f = open(filename, 'rb')
            data = f.read()
            f.close()
        else:
            data = decode(input("Past invite: "))

        passwd = input("Decrypt invite with password: "******"Name for this endpoint: ")
        try:
            entry = self.book[name]
        except:
            entry = {}
        entry['pubkey'] = encode(packet.pubkey)
        entry['tracker'] = encodeAddress((invite.ip, invite.port))
        self.book[name] = entry

        self.commandDone.set()

        return entry
 def sendMessage(self, addr):
   print('sending message to '+str(addr))
   data=self.msg.encode('ascii')
   onion=OnionPacket()
   onion.createOnionPacket(self.keypair, self.endkey, data, self.keys.entropy)
   dustmail=DustmailClient(self.router, addr)
   dustmail.sendMessage(encode(onion.packet))
Esempio n. 18
0
File: reader.py Progetto: blanu/Dust
  def addInvite(self):
    pf=input("Load invite from Paste or File [P/f]? ")
    if pf=='f':
      filename=input("Load invite from filename: ").strip()
      f=open(filename, 'rb')
      data=f.read()
      f.close()
    else:
      data=decode(input("Past invite: "))

    passwd=input("Decrypt invite with password: "******"Name for this endpoint: ")
    try:
      entry=self.book[name]
    except:
      entry={}
    entry['pubkey']=encode(packet.pubkey)
    entry['tracker']=encodeAddress((invite.ip, invite.port))
    self.book[name]=entry

    self.commandDone.set()

    return entry
Esempio n. 19
0
File: reader.py Progetto: blanu/Dust
  def sendMessage(self, addr):
    data=self.msg.encode('ascii')
    onion=OnionPacket()
    onion.createOnionPacket(self.reader.keys.getEndpoint(), self.endkey, data, self.reader.keys.entropy)
    dustmail=DustmailClient(self.reader.router, addr)
    dustmail.sendMessage(encode(onion.packet))

    self.reader.commandDone.set()
    def sendMessage(self, addr):
        data = self.msg.encode('ascii')
        onion = OnionPacket()
        onion.createOnionPacket(self.reader.keys.getEndpoint(), self.endkey,
                                data, self.reader.keys.entropy)
        dustmail = DustmailClient(self.reader.router, addr)
        dustmail.sendMessage(encode(onion.packet))

        self.reader.commandDone.set()
Esempio n. 21
0
 def __str__(self):
   s="ProxyMessage\n"
   s=s+"[\n"
   s=s+"  reqid: "+str(encode(self.reqid))
   s=s+"  seq: "+str(self.seq)
   s=s+"  flags: "+str(self.flags)
   s=s+"  fin: "+str(self.fin)
   s=s+"  data: "+str(self.data)
   s=s+"]\n\n"
   return s
def readHandshake(input):
  version=yield input.read(1)
  print('version: '+encode(str(version)))
  nauth=yield input.read(1)
  nauth=unpack('B', nauth)[0]
  auths=[]
  for x in range(nauth):
    auth=yield input.read(1)
    auth=unpack('B', auth)[0]
    auths.append(auth)
Esempio n. 23
0
def handshake(conn):
  ekeypair=createEphemeralKeypair()

  epub=yield conn.read(KEY_SIZE)
  esession=makeEphemeralSession(ekeypair, epub).bytes
  print('esssion: '+encode(esession))
  coder=lite_socket(esession.bytes)
  yield conn.write(ekeypair.public.bytes)

  yield Return(coder)
Esempio n. 24
0
 def __str__(self):
     s = "ProxyMessage\n"
     s = s + "[\n"
     s = s + "  reqid: " + str(encode(self.reqid))
     s = s + "  seq: " + str(self.seq)
     s = s + "  flags: " + str(self.flags)
     s = s + "  fin: " + str(self.fin)
     s = s + "  data: " + str(self.data)
     s = s + "]\n\n"
     return s
Esempio n. 25
0
def handshake(conn):
    ekeypair = createEphemeralKeypair()

    epub = yield conn.read(KEY_SIZE)
    esession = makeEphemeralSession(ekeypair, epub).bytes
    print('esssion: ' + encode(esession))
    coder = lite_socket(esession.bytes)
    yield conn.write(ekeypair.public.bytes)

    yield Return(coder)
Esempio n. 26
0
  def __str__(self):
    s="[\n"

    if self.key:
      s=s+"  key: "+encode(self.key)+"\n"
    else:
      s=s+"  key: None\n"

    s=s+'  IV: '+encode(self.iv)+"\n"

    s=s+"  payload: "+encode(self.payload)+"\n"

    s=s+'  dataLength: '+str(self.dataLength)+"\n"
    s=s+'  data: '+str(encode(self.data))+"\n"
    if self.remaining:
      s=s+'  remaining: '+encode(self.remaining)+"\n"
    else:
      s=s+"  remaining: None\n"
    s=s+"]\n"
    return s
    def save(self, filename, password, entropy):
        f = open(filename, 'w')

        for invite in self.invites:
            packet = InvitePacket()
            packet.createInvitePacket(password, invite, entropy)
            data = encode(packet.packet)
            f.write(data)
            f.write("\n")

        f.close()
Esempio n. 28
0
File: invite.py Progetto: blanu/Dust
  def save(self, filename, password, entropy):
    f=open(filename, 'w')

    for invite in self.invites:
      packet=InvitePacket()
      packet.createInvitePacket(password, invite, entropy)
      data=encode(packet.packet)
      f.write(data)
      f.write("\n")

    f.close()
Esempio n. 29
0
  def saveKnownHosts(self, filename=None):
    if not filename and self.knownHostsFile:
      filename=self.knownHostsFile
    if filename:
      hosts={}

      for address, pubkey in self.knownHosts.items():
        hosts[address]=encode(pubkey.bytes)

      f=open(filename, 'w')
      f.write(yaml.dump(hosts))
      f.close()
Esempio n. 30
0
  def saveKnownHosts(self, filename=None):
    if not filename and self.knownHostsFile:
      filename=self.knownHostsFile
    if filename:
      hosts={}

      for address, pubkey in self.knownHosts.items():
        hosts[address]=encode(pubkey.bytes)

      f=open(filename, 'w')
      f.write(yaml.dump(hosts))
      f.close()
Esempio n. 31
0
 def decodeIntroPacket(self, invites, packet):
   self.identifier=packet[:ID_LENGTH]
   packet=packet[ID_LENGTH:]
   invite=invites.getInviteWithId(self.identifier)
   if not invite:
     print('Unknown invite id', encode(self.identifier))
     print(invites)
     return
   sk=invite.secret
   
   self.decodeDustPacket(sk, packet)
   self.intro=IntroMessage()
   self.intro.decodeIntroMessage(self.data)
    def gotInvite(self, invite):
        time.sleep(1)
        print()
        ps = input("Print, Save, or Email [P/s/e]? ")
        passwd = input("Encrypt invite with password: "******"Save invite to filename: ").strip()
            if filename != '':
                f = open(filename, 'wb')
                f.write(packet.packet)
                f.close()
        elif ps == 'e':
            frm = input("Your email: ")
            to = input("Recipient email: ")
            name = input("Your name on DustMail: ")

            body = """
      You have been invited to communicate with %s via DustMail.
      Use the following invite code: %s
      """ % (name, encode(packet.packet))

            emailConfig = YamlMap('config/emailServer.yaml')
            try:
                smtpHost = emailConfig['smtpHost']
            except:
                smtpHost = input("SMTP Host: ")
                emailConfig['smtpHost'] = smtpHost

            notifier = Notifier(frm)
            notifier.notify(to, 'DustMail Invite', body)
        else:
            print()
            print(encode(packet.packet))
            print()

        self.commandDone.set()
    def decodeIntroPacket(self, invites, packet):
        self.identifier = packet[:ID_LENGTH]
        packet = packet[ID_LENGTH:]
        invite = invites.getInviteWithId(self.identifier)
        if not invite:
            print('Unknown invite id', encode(self.identifier))
            print(invites)
            return
        sk = invite.secret

        self.decodeDustPacket(sk, packet)
        self.intro = IntroMessage()
        self.intro.decodeIntroMessage(self.data)
    def __init__(self, router, endpoint):
        self.router = router
        self.endpoint = endpoint

        self.keys = router.keys
        self.maildir = 'spool/' + encode(endpoint.public.bytes)
        self.addressBook = YamlMap('config/dustmail-addressbook.yaml')
        self.done = Event()
        self.commandDone = Event()

        self.book = YamlMap('config/dustmail-addressbook.yaml')

        dustmailConfig = YamlMap('config/dustmail-config.yaml')

        try:
            destAddress = dustmailConfig['tracker']
        except:
            entry = self.addInvite()
            destAddress = entry['tracker']
            dustmailConfig['tracker'] = destAddress

        dest, outport, v6 = decodeAddress(destAddress)

        print('Registering with tracker...')
        self.tracker = TrackerClient(self.router, addr=(dest, outport))

        host = getPublicIP(v6)
        inport = dustmailConfig['port']
        self.tracker.putPeerForEndpoint(encode(self.endpoint.public.bytes), [
            encode(self.endpoint.public.bytes),
            encodeAddress((host, inport))
        ])

        invite = self.keys.generateInvite(inport, v6=v6)
        self.tracker.putInviteForPeer(encodeAddress((host, inport)),
                                      encode(invite.message))

        self.trackback = self.router.getService('trackback')
Esempio n. 35
0
File: reader.py Progetto: blanu/Dust
  def gotInvite(self, invite):
    time.sleep(1)
    print()
    ps=input("Print, Save, or Email [P/s/e]? ")
    passwd=input("Encrypt invite with password: "******"Save invite to filename: ").strip()
      if filename!='':
        f=open(filename, 'wb')
        f.write(packet.packet)
        f.close()
    elif ps=='e':
      frm=input("Your email: ")
      to=input("Recipient email: ")
      name=input("Your name on DustMail: ")

      body="""
      You have been invited to communicate with %s via DustMail.
      Use the following invite code: %s
      """ % (name, encode(packet.packet))

      emailConfig=YamlMap('config/emailServer.yaml')
      try:
        smtpHost=emailConfig['smtpHost']
      except:
        smtpHost=input("SMTP Host: ")
        emailConfig['smtpHost']=smtpHost

      notifier=Notifier(frm)
      notifier.notify(to, 'DustMail Invite', body)
    else:
      print()
      print(encode(packet.packet))
      print()

    self.commandDone.set()
    def sendMessage(self, message):
        print('sendMessage ' + str(message))

        onion = OnionPacket()
        onion.decodeOnionPacket(self.router.keys.getKeypair(), decode(message))
        frm = encode(onion.sender)
        to = encode(onion.receiver)

        print('frm: ' + str(frm))
        print('to: ' + str(to))

        if not os.path.exists(self.maildir + '/' + to):
            os.mkdir(self.maildir + '/' + to)

        filename = None
        while not filename or os.path.exists(filename):
            filename = self.makeName(frm, to)
        f = open(filename, 'w')
        f.write(message)
        f.close()

        notifyPrefs = YamlMap('config/dustmail-notify.yaml')
        try:
            mailAddr = notifyPrefs[to]

            addressBook = YamlMap('config/dustmail-addressbook.yaml')
            frmName = self.nameForPubkey(addressBook, frm)
            if not frmName:
                frmName = frm

            notifier = Notifier('*****@*****.**')
            notifier.notify(
                mailAddr, 'New DustMail Message',
                "You have a DustMail message from " + frmName + ".")
        except KeyError:
            print('No notification set')
Esempio n. 37
0
File: invite.py Progetto: blanu/Dust
def gotInvite(invite):
  ps=input("Print or Save [P/s]?")
  passwd=input("Encrypt invite with password: "******"Save invite to filename: ").strip()
    if filename!='':
      f=open(filename, 'wb')
      f.write(packet.packet)
      f.close()
  else:
    print()
    print(encode(packet.packet))
    print()

  done.set()
Esempio n. 38
0
def gotInvite(invite):
    ps = input("Print or Save [P/s]?")
    passwd = input("Encrypt invite with password: "******"Save invite to filename: ").strip()
        if filename != '':
            f = open(filename, 'wb')
            f.write(packet.packet)
            f.close()
    else:
        print()
        print(encode(packet.packet))
        print()

    done.set()
Esempio n. 39
0
from dust.crypto.keys import KeyManager
from dust.core.data_packet import DataPacket
from dust.core.util import encode, decode

keys=KeyManager()
#psk=keys.entropy.getBytes(32)

psk=decode("5475e69147a1463ef65116ccd8b3d732ead5ce8b5c9b0e61eb4c218fe6165013")

packet=DataPacket()
packet.createDataPacket(psk, b"test #3", keys.entropy)
print('packet:', packet)
print('packetData:', encode(packet.packet))

print('------------------------')

p2=DataPacket()
p2.decodeDataPacket(psk, packet.packet)
print(p2)
print('checkMac:', p2.checkMac())
print('checkTimestamp:', p2.checkTimestamp())
Esempio n. 40
0
  def handle(self, msock, msg, addr):
#    data=msg.decode('ascii')
#    data=bz2.decompress(msg).decode('ascii')
#    print('HTTP Proxyback message from '+encodeAddress(addr)+': ')
#    print(msg)

    packet=ProxybackMessage()
    packet.decodeProxybackMessage(msg)
#    print(packet)

    print('reqid: '+encode(packet.reqid))
    print('current: '+str(packet.seq))

    if not encode(packet.reqid) in self.stats:
      print('Unknown reqid '+encode(packet.reqid))
      print('Dropping packet with seq '+str(packet.seq))
      return

    q=self.qs[encode(packet.reqid)]
    progress, last, chunks=self.stats[encode(packet.reqid)]
    if not packet.seq in chunks: # Store new chunks by seq number
      chunks[packet.seq]=packet.data
    if progress==None and packet.seq==0: # First packet arrived
      progress=0
    if packet.fin: # If fin flag set, this is the last packet in the sequence
      last=packet.seq
    done=False

    print('reqid: '+encode(packet.reqid))
    print('progress: '+str(progress))
    print('last: '+str(last))
    print('current: '+str(packet.seq))

    if progress!=None:
      if last!=None:
        done=True
        for x in range(progress, last+1): # Send all sequential packets from last sent to new packet
          try:
            chunk=chunks[x]
            print('putting chunk '+encode(packet.reqid)+':'+str(x)+'/'+str(last))
            q.put(chunk)
            progress=x+1
          except:
            done=False
            break
      else:
        for x in range(progress, packet.seq+1): # Send all sequential packets from last sent to new packet
          try:
            chunk=chunks[x]
            print('putting chunk '+encode(packet.reqid)+':'+str(x)+'/?')
            q.put(chunk)
            progress=x+1
          except:
            break

    if done:
      q.put(None)
      del self.qs[encode(packet.reqid)]
      del self.stats[encode(packet.reqid)]
    else:
      self.stats[encode(packet.reqid)]=[progress, last, chunks]
    print(q.qsize())
Esempio n. 41
0
 def setQueue(self, reqid, q):
   self.qs[encode(reqid)]=q
   self.stats[encode(reqid)]=[None, None, {}]
Esempio n. 42
0
 def __str__(self):
     return 'DustCipher(' + encode(self.key) + ',' + encode(
         self.iv) + ',' + str(self.count) + ')'
Esempio n. 43
0
#r=DustPRNG()
#iv=r.getBytes(16)
#key=r.getBytes(32)
key=decode("5475e69147a1463ef65116ccd8b3d732ead5ce8b5c9b0e61eb4c218fe6165013")
iv=decode("5475e69147a1463ef65116ccd8b3d732ead5ce8b5c9b0e61eb4c218fe6165013")

text=b'test data'

def purehash(data, pers=None):
  if pers:
    return pure(data, pers=pers)
  else:
    return pure(data)

def chash(data, pers=None):
  if pers:
    return skein512(data, pers=pers).digest()
  else:
    return skein512(data).digest()

print("hash: "+encode(purehash(text)))
print("hash pers: "+encode(purehash(text, pers=b"a")))
print("hash: "+encode(chash(text)))
print("hash pers: "+encode(chash(text, pers=b"a")))

#data=encrypt(key, iv, text)
#print(text)
#print(encode(data))
#print(decrypt(key, iv, data))
Esempio n. 44
0
key = decode(
    "5475e69147a1463ef65116ccd8b3d732ead5ce8b5c9b0e61eb4c218fe6165013")
iv = decode("5475e69147a1463ef65116ccd8b3d732ead5ce8b5c9b0e61eb4c218fe6165013")

text = b'test data'


def purehash(data, pers=None):
    if pers:
        return pure(data, pers=pers)
    else:
        return pure(data)


def chash(data, pers=None):
    if pers:
        return skein512(data, pers=pers).digest()
    else:
        return skein512(data).digest()


print("hash: " + encode(purehash(text)))
print("hash pers: " + encode(purehash(text, pers=b"a")))
print("hash: " + encode(chash(text)))
print("hash pers: " + encode(chash(text, pers=b"a")))

#data=encrypt(key, iv, text)
#print(text)
#print(encode(data))
#print(decrypt(key, iv, data))
Esempio n. 45
0
    v6 = False

host = getPublicIP(v6)
print('Host: ' + str(host))

keys = KeyManager()
keys.setInvitePassword(passwd)
keys.loadKnownHosts('config/knownhosts.yaml')
keys.loadKeypair('config/id.yaml')
keys.loadIncomingInvites('config/incoming_invites.ip')
keys.loadOutgoingInvites('config/outgoing_invites.ip')

keypair = keys.getKeypair()
pubkey = keypair.public
destpubkey = pubkey
pubkeyhex = encode(pubkey.bytes)
destpubkeyhex = pubkeyhex

router = PacketRouter(v6, inport, keys, passwd)
router.connect(dest, outport)

dustmail = DustmailClient(router)

tracker = TrackerClient(router)
trackback = router.getService('trackback')

router.start()


class PendingMessage:
    def __init__(self, tracker, trackback, dustmail, keypair, endkey, msg):
Esempio n. 46
0
import sys
from skein import skein512
from dust.core.util import encode

v3=(sys.version[0]=='3')

### Print hash of MSG if called directly ###
if __name__ == "__main__":
  if v3:
    MSG = bytes("Nobody inspects the spammish repetition", 'ascii')
  else:
    MSG = "Nobody inspects the spammish repetition"

  hash = skein512(MSG, digest_bits=256).digest()
  print(encode(hash))

  hash = skein512(MSG, digest_bits=512).digest()
  print(encode(hash))
Esempio n. 47
0
 def getTrackerInvite(self):
   invite=self.router.generateInvite()
   trackback=TrackbackClient(self.router, self.addr)
   trackback.putTrackerInvite(encode(invite.message))
import sys
from dust.crypto.pyskein import skein512
from dust.core.util import encode

v3 = (sys.version[0] == '3')

### Print hash of MSG if called directly ###
if __name__ == "__main__":
    if v3:
        MSG = bytes("Nobody inspects the spammish repetition", 'ascii')
    else:
        MSG = "Nobody inspects the spammish repetition"

    hash = skein512(msg=MSG, digest_bits=256)
    print(encode(hash))

    hash = skein512(msg=MSG, digest_bits=512)
    print(encode(hash))
Esempio n. 49
0
from dust.crypto.curve import Keypair, Key
from dust.core.util import encode, decode

keypair=Keypair(Key(decode('48ef7b8c0c6343b332a02862335c11e0cd2b38f0d7d6a3647a7f8f2661d1c946'), False), Key(decode('43aafb64bc96460f3928f6068b2a01aa87bac16da6dc034b4525d1837e9cb85e'), False))
session=keypair.createSessionBytes(decode('77516be967ad1a68632a3c8b08c9e032d23ff5b764a7fe49461b9c12b2da0c32'))
print(encode(session))

Esempio n. 50
0
 def __str__(self):
   return 'DustCipher('+encode(self.key)+','+encode(self.iv)+','+str(self.count)+')'
    keys.loadKeypair('config/id.yaml')
except:
    print('Generating server keypair...')
    keys.createKeypair()
    keys.saveKeypair('config/id.yaml')

keys.loadKnownHosts('config/knownhosts.yaml')
keys.loadIncomingInvites('config/incoming_invites.ip')
keys.loadOutgoingInvites('config/outgoing_invites.ip')

router = PacketRouter(v6, inport, keys, passwd)
router.connect(trackerAddr[0], trackerAddr[1])

tracker = TrackerClient(router)

router.start()

keypair = keys.getKeypair()
pubkey = keypair.public

invite = keys.generateInvite(inport, v6=v6)
tracker.putInviteForPeer(encodeAddress((host, inport)), encode(invite.message))

endpoints = YamlMap('config/endpoints.yaml')
for key in endpoints.values():
    tracker.putPeerForEndpoint(
        key, [encode(pubkey.bytes),
              encodeAddress((host, inport))])

wait()
Esempio n. 52
0
  v6=False

  host=getPublicIP(v6)
  print('Host: '+str(host))

  keys=KeyManager()
  keys.setInvitePassword(passwd)
  keys.loadKnownHosts('config/knownhosts.yaml')
  keys.loadKeypair('config/id.yaml')
  keys.loadIncomingInvites('config/incoming_invites.ip')
  keys.loadOutgoingInvites('config/outgoing_invites.ip')

  keypair=keys.getKeypair()
  pubkey=keypair.public
  destpubkey=pubkey
  pubkeyhex=encode(pubkey.bytes)
  destpubkeyhex=pubkeyhex

  router=PacketRouter(v6, inport, keys, passwd)
#  router.connect(dest, outport)

  router.start()
  server=SocksDustServer(router, proxyAddr)
#  server.start()

  while True:
    try:
      time.sleep(1)
    except:
      sys.exit(0)