Beispiel #1
0
 def send_unencrypted(self, message, wait_for_response=True):
     self.rx_unencrypted = []
     self.rx_unencr_seg = ''
     if ((False == self.connected) or (None == self.ps_gdio_handle)):
         log.debug('BLE adapter error: not connected')
     else:
         message = utils.add_crc(message)
         log.debug('send unencrypted: ' + hexlify(message))
         message = self._format_tx(message)
         self.device.char_write_handle_long(self.ps_gdio_handle, message,
                                            self.chunk_size, True)
Beispiel #2
0
    def _inject_error_encrypted(self,
                                error_id,
                                cmd_id=0xFFFF,
                                auth_id=0xFFFFFFFF):
        error = error_id
        cmd_id = cmd_id
        message = cmd.error_bridge(error, cmd_id)
        decrypted = utils.pack_u32(auth_id) + message
        decrypted = utils.add_crc(decrypted)

        return auth_id, message, decrypted
Beispiel #3
0
def encrypt_tx(auth_id, message, key, nonce=''):
    auth_id = utils.pack_u32(auth_id)
    pdata = auth_id + message
    pdata = utils.add_crc(pdata)
    encrypted = encrypt(pdata, key, nonce)
    nonce = encrypted[:24]
    pdata = encrypted[24:]
    length = len(pdata)
    length = utils.pack_u16(length)
    message = nonce + auth_id + length + pdata
    return message
Beispiel #4
0
    def _inject_error_unencrypted(self, error_id, cmd_id=0xFFFF):
        error = error_id
        message = cmd.error_bridge(error, cmd_id)
        message = utils.add_crc(message)

        return message
Beispiel #5
0
def pdata(cmd_id, message):
    message = cmd_id + message
    message = utils.add_crc(message)
    return message