btstack/test/mesh/provisioning.h

104 lines
3.5 KiB
C

/*
* Copyright (C) 2017 BlueKitchen GmbH
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holders nor the names of
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* 4. Any redistribution, use, or modification is done solely for
* personal benefit and not for any commercial purpose or for
* monetary gain.
*
* THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
* RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Please inquire about commercial licensing options at
* contact@bluekitchen-gmbh.com
*
*/
/*
* provisioning.h
*/
#ifndef __PROVISIONING_H
#define __PROVISIONING_H
#include <stdint.h>
#include "btstack_defines.h"
#include "btstack_crypto.h"
#ifdef __cplusplus
extern "C"
{
#endif
#define PROVISIONING_PROTOCOL_TIMEOUT_MS 60000
// Provisioning Bearer Control
#define MESH_PROV_INVITE 0x00
#define MESH_PROV_CAPABILITIES 0x01
#define MESH_PROV_START 0x02
#define MESH_PROV_PUB_KEY 0x03
#define MESH_PROV_INPUT_COMPLETE 0x04
#define MESH_PROV_CONFIRM 0x05
#define MESH_PROV_RANDOM 0x06
#define MESH_PROV_DATA 0x07
#define MESH_PROV_COMPLETE 0x08
#define MESH_PROV_FAILED 0x09
// Provisioning Output OOB Actions
#define MESH_OUTPUT_OOB_BLINK 0x01
#define MESH_OUTPUT_OOB_BEEP 0x02
#define MESH_OUTPUT_OOB_VIBRATE 0x04
#define MESH_OUTPUT_OOB_NUMBER 0x08
#define MESH_OUTPUT_OOB_STRING 0x10
// Provisioning Input OOB Actions
#define MESH_INPUT_OOB_PUSH 0x01
#define MESH_INPUT_OOB_TWIST 0x02
#define MESH_INPUT_OOB_NUMBER 0x04
#define MESH_INPUT_OOB_STRING 0x08
typedef struct {
uint8_t network_id[8];
uint8_t beacon_key[16];
uint32_t iv_index;
} mesh_provisioning_data;
/**
* Calculate mesh k1 function
*/
void mesh_k1(btstack_crypto_aes128_cmac_t * request, const uint8_t * n, uint16_t n_len, const uint8_t * salt,
const uint8_t * p, const uint16_t p_len, uint8_t * result, void (* callback)(void * arg), void * callback_arg);
/**
* Calculate mesh k3 function
*/
void mesh_k3(btstack_crypto_aes128_cmac_t * request, const uint8_t * n, uint8_t * result, void (* callback)(void * arg), void * callback_arg);
#ifdef __cplusplus
} /* end of extern "C" */
#endif
#endif