Esempio n. 1
0
async def rekey(request, sysid):
    """
    Handle a client rekey request.
    """
    payload = unprocess_payload(sysid, request.body)

    new_key = payload['key']
    if not new_key:
        new_key = gen_random_key(int(payload['length']))
    return_payload = process_payload(sysid, {'key': new_key})

    # set new key globally for server
    set_key(sysid, new_key)

    return response.text(return_payload)
Esempio n. 2
0
async def rekey(request, ws, sysid):
    """
    Handle a client rekey request.
    """
    data = await ws.recv()
    payload = unprocess_payload(sysid, data)

    new_key = payload['key']
    if not new_key:
        new_key = gen_random_key(int(payload['length']))
    return_payload = process_payload(sysid, {'key': new_key})

    # set new key globally for server
    set_key(sysid, new_key)

    await ws.send(return_payload)
Esempio n. 3
0
    def rekey(self, key='', length=16):
        payload = {'endpoint': 'rekey', 'key': key, 'length': str(length)}
        self.subscribe('rekey')
        self.send(payload)

        # ensure rekey success
        attempts = 5
        response = None
        while attempts and not response:
            try:
                response = self.recv('rekey')[0]
            except IndexError:
                time.sleep(1)
                attempts -= 1
                
        # set new key
        new_key = response['key']
        set_key(SYSID, new_key)
Esempio n. 4
0
 def rekey(self, key='', length=16):
     payload = {'endpoint': 'rekey', 'key': key, 'length': str(length)}
     response = self.send(payload)
     new_key = response['key']
     set_key(SYSID, new_key)