def __init__(self,
              loop: asyncio.AbstractEventLoop,
              password: bytearray,
              listenAddr: net.Address):
     super().__init__(
         loop=loop,
         cipher=Cipher.NewCipher(encodePassword=password),
         listenAddr=listenAddr)
Exemple #2
0
 def __init__(self,
              loop: asyncio.AbstractEventLoop,
              password: bytearray,
              listenAddr: net.Address,
              remoteAddr: net.Address) -> None:
     super().__init__(loop=loop, cipher=Cipher.NewCipher(password))
     self.listenAddr = listenAddr
     self.remoteAddr = remoteAddr
 def setUp(self):
     self.ls_local, self.ls_server = socket.socketpair()
     password = randomPassword()
     self.loop = asyncio.new_event_loop()
     self.cipher = Cipher.NewCipher(password)
     self.securesocket = SecureSocket(loop=self.loop, cipher=self.cipher)
     self.msg = bytearray(b'hello world')
     self.encripted_msg = self.msg.copy()
     self.cipher.encode(self.encripted_msg)
Exemple #4
0
    def setUp(self):
        self.listenAddr = net.Address('127.0.0.1', getValidAddr()[1])

        password = randomPassword()
        self.cipher = Cipher.NewCipher(password)
        self.loop = asyncio.new_event_loop()
        self.server = LsServer(loop=self.loop,
                               password=password,
                               listenAddr=self.listenAddr)
    def test_encryption(self):
        password = randomPassword()

        original_data = bytearray()
        for _ in range(0xffff):
            original_data.append(random.randint(0, 255))

        cipher = Cipher.NewCipher(password)
        data = original_data.copy()

        cipher.encode(data)
        self.assertNotEqual(data, original_data)
        cipher.decode(data)
        self.assertEqual(data, original_data)
Exemple #6
0
    def setUp(self):
        self.listenAddr = net.Address('127.0.0.1',
                                      random.randint(10000, 20000))

        self.dstServer = socket.socket()
        self.dstServer.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self.dstServer.bind(('127.0.0.1', 44444))
        self.dstServer.listen(1)

        password = randomPassword()
        self.cipher = Cipher.NewCipher(password)
        self.loop = asyncio.new_event_loop()
        self.server = LsServer(loop=self.loop,
                               password=password,
                               listenAddr=self.listenAddr)
Exemple #7
0
    def setUp(self):
        self.listenAddr = net.Address('127.0.0.1', 11111)
        self.remoteAddr = net.Address('127.0.0.1', 22222)
        self.remoteServer = socket.socket()
        self.remoteServer.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self.remoteServer.bind(self.remoteAddr)
        self.remoteServer.listen(1)

        password = randomPassword()
        self.cipher = Cipher.NewCipher(password)
        self.loop = asyncio.new_event_loop()
        self.local = LsLocal(loop=self.loop,
                             password=password,
                             listenAddr=self.listenAddr,
                             remoteAddr=self.remoteAddr)

        self.msg = bytearray(b'hello world')
        self.encrypted_msg = self.msg.copy()
        self.cipher.encode(self.encrypted_msg)