Пример #1
0
def lock_action(auth_id, lock_action, bridge_id, flags, nonce_k):
    cmd_id      = 0x000D
    cmd_id      = utils.pack_u16(cmd_id)
    lock_action = utils.pack_u8(lock_action)
    bridge_id   = utils.pack_u32(bridge_id)
    flags       = utils.pack_u8(flags)
    message     = cmd_id + lock_action + bridge_id + flags + nonce_k
    return message
Пример #2
0
def error_bridge(error_code, command):
    cmd_id     = 0x8012
    cmd_id     = utils.pack_u16(cmd_id)
    error_code = utils.pack_u8(error_code)
    command    = utils.pack_u16(command)
    message    = cmd_id + error_code + command
    return message
Пример #3
0
def authorization_data(id_type, bridge_id, name, nonce_abf, nonce_k, key):
    cmd_id    = 0x0006
    cmd_id    = utils.pack_u16(cmd_id)        
    id_type   = utils.pack_u8(id_type)
    bridge_id = utils.pack_u32(bridge_id)
    z_fill    = a2b_hex('0000000000000000000000000000000000000000000000000000000000000000')
    name      = a2b_hex(hexlify(name))[:15] + z_fill
    name      = name[:32]
    message   = id_type + bridge_id + name + nonce_abf + nonce_k
    auth_h    = nacl.bindings.crypto_auth_hmacsha256(message, key)
    message   = cmd_id + auth_h + id_type + bridge_id + name + nonce_abf
    return message