summaryrefslogtreecommitdiffstats
path: root/stack/smp
diff options
context:
space:
mode:
Diffstat (limited to 'stack/smp')
-rw-r--r--stack/smp/aes.c40
-rw-r--r--stack/smp/smp_act.c66
-rw-r--r--stack/smp/smp_api.c30
-rw-r--r--stack/smp/smp_cmac.c42
-rw-r--r--stack/smp/smp_int.h24
-rw-r--r--stack/smp/smp_keys.c128
-rw-r--r--stack/smp/smp_l2c.c20
-rw-r--r--stack/smp/smp_main.c78
-rw-r--r--stack/smp/smp_utils.c4
9 files changed, 216 insertions, 216 deletions
diff --git a/stack/smp/aes.c b/stack/smp/aes.c
index 1028d5b..5b3fefa 100644
--- a/stack/smp/aes.c
+++ b/stack/smp/aes.c
@@ -231,7 +231,7 @@ static uint_8t hibit(const uint_8t x)
static uint_8t gf_inv(const uint_8t x)
{ uint_8t p1 = x, p2 = BPOLY, n1 = hibit(x), n2 = 0x80, v1 = 1, v2 = 0;
- if(x < 2)
+ if(x < 2)
return x;
for( ; ; )
@@ -239,20 +239,20 @@ static uint_8t gf_inv(const uint_8t x)
if(n1)
while(n2 >= n1) /* divide polynomial p2 by p1 */
{
- n2 /= n1; /* shift smaller polynomial left */
+ n2 /= n1; /* shift smaller polynomial left */
p2 ^= (p1 * n2) & 0xff; /* and remove from larger one */
- v2 ^= (v1 * n2); /* shift accumulated value and */
+ v2 ^= (v1 * n2); /* shift accumulated value and */
n2 = hibit(p2); /* add into result */
}
else
return v1;
- if(n2) /* repeat with values swapped */
+ if(n2) /* repeat with values swapped */
while(n1 >= n2)
{
- n1 /= n2;
- p1 ^= p2 * n1;
- v1 ^= v2 * n1;
+ n1 /= n2;
+ p1 ^= p2 * n1;
+ v1 ^= v2 * n1;
n1 = hibit(p1);
}
else
@@ -262,13 +262,13 @@ static uint_8t gf_inv(const uint_8t x)
/* The forward and inverse affine transformations used in the S-box */
uint_8t fwd_affine(const uint_8t x)
-{
+{
#if defined( HAVE_UINT_32T )
uint_32t w = x;
w ^= (w << 1) ^ (w << 2) ^ (w << 3) ^ (w << 4);
return 0x63 ^ ((w ^ (w >> 8)) & 0xff);
#else
- return 0x63 ^ x ^ (x << 1) ^ (x << 2) ^ (x << 3) ^ (x << 4)
+ return 0x63 ^ x ^ (x << 1) ^ (x << 2) ^ (x << 3) ^ (x << 4)
^ (x >> 7) ^ (x >> 6) ^ (x >> 5) ^ (x >> 4);
#endif
}
@@ -280,7 +280,7 @@ uint_8t inv_affine(const uint_8t x)
w = (w << 1) ^ (w << 3) ^ (w << 6);
return 0x05 ^ ((w ^ (w >> 8)) & 0xff);
#else
- return 0x05 ^ (x << 1) ^ (x << 3) ^ (x << 6)
+ return 0x05 ^ (x << 1) ^ (x << 3) ^ (x << 6)
^ (x >> 7) ^ (x >> 5) ^ (x >> 2);
#endif
}
@@ -502,19 +502,19 @@ return_type aes_set_key( const unsigned char key[], length_type keylen, aes_cont
switch( keylen )
{
case 16:
- case 128:
- keylen = 16;
+ case 128:
+ keylen = 16;
break;
case 24:
- case 192:
- keylen = 24;
+ case 192:
+ keylen = 24;
break;
case 32:
- case 256:
- keylen = 32;
+ case 256:
+ keylen = 32;
break;
- default:
- ctx->rnd = 0;
+ default:
+ ctx->rnd = 0;
return (return_type)-1;
}
block_copy_nn(ctx->ksch, key, keylen);
@@ -640,10 +640,10 @@ return_type aes_decrypt( const unsigned char in[N_BLOCK], unsigned char out[N_BL
return_type aes_cbc_decrypt( const unsigned char *in, unsigned char *out,
int n_block, unsigned char iv[N_BLOCK], const aes_context ctx[1] )
-{
+{
while(n_block--)
{ uint_8t tmp[N_BLOCK];
-
+
memcpy(tmp, in, N_BLOCK);
if(aes_decrypt(in, out, ctx) != EXIT_SUCCESS)
return EXIT_FAILURE;
diff --git a/stack/smp/smp_act.c b/stack/smp/smp_act.c
index 0948153..af4bd2e 100644
--- a/stack/smp/smp_act.c
+++ b/stack/smp/smp_act.c
@@ -36,7 +36,7 @@ const UINT8 smp_association_table[2][SMP_IO_CAP_MAX][SMP_IO_CAP_MAX] =
/* display only */ /*SMP_CAP_IO = 1 */ /* keyboard only */ /* No InputOutput */ /* keyboard display */
};
-const tSMP_ACT smp_distribute_act [] =
+const tSMP_ACT smp_distribute_act [] =
{
smp_generate_ltk,
smp_send_id_info,
@@ -84,7 +84,7 @@ void smp_send_app_cback(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
cb_data.io_req.auth_req = p_cb->peer_auth_req;
cb_data.io_req.oob_data = SMP_OOB_NONE;
cb_data.io_req.io_cap = SMP_DEFAULT_IO_CAPS;
- cb_data.io_req.max_key_size = SMP_MAX_ENC_KEY_SIZE;
+ cb_data.io_req.max_key_size = SMP_MAX_ENC_KEY_SIZE;
cb_data.io_req.init_keys = p_cb->loc_i_key ;
cb_data.io_req.resp_keys = p_cb->loc_r_key ;
@@ -118,7 +118,7 @@ void smp_send_app_cback(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
}
/*******************************************************************************
** Function smp_send_pair_fail
-** Description pairing failure to peer device if needed.
+** Description pairing failure to peer device if needed.
*******************************************************************************/
void smp_send_pair_fail(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
{
@@ -145,7 +145,7 @@ void smp_send_pair_req(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
/* erase all keys when master sends pairing req*/
if (p_dev_rec)
btm_sec_clear_ble_keys(p_dev_rec);
- /* do not manipulate the key, let app decide,
+ /* do not manipulate the key, let app decide,
leave out to BTM to mandate key distribution for bonding case */
smp_send_cmd(SMP_OPCODE_PAIRING_REQ, p_cb);
}
@@ -191,7 +191,7 @@ void smp_send_init(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
}
#endif
- smp_send_cmd(SMP_OPCODE_INIT, p_cb);
+ smp_send_cmd(SMP_OPCODE_INIT, p_cb);
}
/*******************************************************************************
** Function smp_send_enc_info
@@ -204,8 +204,8 @@ void smp_send_enc_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
SMP_TRACE_DEBUG1 ("smp_send_enc_info p_cb->loc_enc_size = %d", p_cb->loc_enc_size);
smp_update_key_mask (p_cb, SMP_SEC_KEY_TYPE_ENC, FALSE);
- smp_send_cmd(SMP_OPCODE_ENCRYPT_INFO, p_cb);
- smp_send_cmd(SMP_OPCODE_MASTER_ID, p_cb);
+ smp_send_cmd(SMP_OPCODE_ENCRYPT_INFO, p_cb);
+ smp_send_cmd(SMP_OPCODE_MASTER_ID, p_cb);
/* save the DIV and key size information when acting as slave device */
le_key.div = p_cb->div;
@@ -226,8 +226,8 @@ void smp_send_id_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
SMP_TRACE_DEBUG0 ("smp_send_id_info ");
smp_update_key_mask (p_cb, SMP_SEC_KEY_TYPE_ID, FALSE);
- smp_send_cmd(SMP_OPCODE_IDENTITY_INFO, p_cb);
- smp_send_cmd(SMP_OPCODE_ID_ADDR, p_cb);
+ smp_send_cmd(SMP_OPCODE_IDENTITY_INFO, p_cb);
+ smp_send_cmd(SMP_OPCODE_ID_ADDR, p_cb);
SMP_TRACE_WARNING0( "smp_send_id_info");
@@ -377,7 +377,7 @@ void smp_proc_pair_cmd(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
if (p_cb->peer_enc_size < SMP_MIN_ENC_KEY_SIZE)
{
smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &reason);
- }
+ }
else if (p_cb->role == HCI_ROLE_SLAVE)
{
if (!(p_cb->flags & SMP_PAIR_FLAGS_WE_STARTED_DD))
@@ -410,7 +410,7 @@ void smp_proc_confirm(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
}
p_cb->flags |= SMP_PAIR_FLAGS_CMD_CONFIRM;
-}
+}
/*******************************************************************************
** Function smp_proc_init
@@ -536,14 +536,14 @@ void smp_proc_compare(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
p_cb->loc_i_key = p_cb->peer_i_key;
p_cb->loc_r_key = p_cb->peer_r_key;
- smp_sm_event(p_cb, SMP_ENC_REQ_EVT, NULL);
+ smp_sm_event(p_cb, SMP_ENC_REQ_EVT, NULL);
}
}
else
{
reason = p_cb->failure = SMP_CONFIRM_VALUE_ERR;
- smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &reason);
+ smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &reason);
}
}
/*******************************************************************************
@@ -581,7 +581,7 @@ void smp_start_enc(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
if (p_data != NULL)
cmd = btm_ble_start_encrypt(p_cb->pairing_bda, TRUE, p_data->key.p_data);
else
- cmd = btm_ble_start_encrypt(p_cb->pairing_bda, FALSE, NULL);
+ cmd = btm_ble_start_encrypt(p_cb->pairing_bda, FALSE, NULL);
if (!cmd)
smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &reason);
@@ -644,7 +644,7 @@ void smp_check_auth_req(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
UINT8 enc_enable = *(UINT8 *)p_data;
UINT8 reason = enc_enable ? SMP_SUCCESS : SMP_ENC_FAIL;
- SMP_TRACE_DEBUG3 ("smp_check_auth_req enc_enable=%d i_keys=0x%x r_keys=0x%x (i-initiator r-responder)",
+ SMP_TRACE_DEBUG3 ("smp_check_auth_req enc_enable=%d i_keys=0x%x r_keys=0x%x (i-initiator r-responder)",
enc_enable, p_cb->loc_i_key, p_cb->loc_r_key);
if (enc_enable == 1)
{
@@ -701,7 +701,7 @@ void smp_key_pick_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
void smp_key_distribution(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
{
UINT8 reason = SMP_SUCCESS;
- SMP_TRACE_DEBUG3 ("smp_key_distribution role=%d (0-master) r_keys=0x%x i_keys=0x%x",
+ SMP_TRACE_DEBUG3 ("smp_key_distribution role=%d (0-master) r_keys=0x%x i_keys=0x%x",
p_cb->role, p_cb->loc_r_key, p_cb->loc_i_key);
if (p_cb->role == HCI_ROLE_SLAVE||
@@ -720,7 +720,7 @@ void smp_key_distribution(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
/*******************************************************************************
** Function smp_decide_asso_model
** Description This function is called to compare both sides' io capability
-** oob data flag and authentication request, and decide the
+** oob data flag and authentication request, and decide the
** association model to use for the authentication.
*******************************************************************************/
void smp_decide_asso_model(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
@@ -728,11 +728,11 @@ void smp_decide_asso_model(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
UINT8 failure = SMP_UNKNOWN_IO_CAP;
tSMP_ASSO_MODEL model = SMP_MODEL_MAX;
UINT8 int_evt = 0;
- tSMP_KEY key;
- tSMP_INT_DATA *p;
+ tSMP_KEY key;
+ tSMP_INT_DATA *p;
SMP_TRACE_DEBUG3 ("smp_decide_asso_model p_cb->peer_io_caps = %d p_cb->loc_io_caps = %d \
- p_cb->peer_auth_req = %02x",
+ p_cb->peer_auth_req = %02x",
p_cb->peer_io_caps, p_cb->loc_io_caps, p_cb->peer_auth_req);
/* OOB data present on both devices, use OOB association model */
@@ -741,7 +741,7 @@ void smp_decide_asso_model(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
model = SMP_MODEL_OOB;
}
/* no MITM required, ignore IO cap, use encryption only */
- else if (SMP_NO_MITM_REQUIRED (p_cb->peer_auth_req) &&
+ else if (SMP_NO_MITM_REQUIRED (p_cb->peer_auth_req) &&
SMP_NO_MITM_REQUIRED(p_cb->loc_auth_req))
{
model = SMP_MODEL_ENC_ONLY;
@@ -787,7 +787,7 @@ void smp_decide_asso_model(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
else if (model == SMP_MODEL_ENC_ONLY) /* TK = 0, go calculate Confirm */
{
if (p_cb->role == HCI_ROLE_MASTER &&
- ((p_cb->peer_auth_req & SMP_AUTH_YN_BIT) != 0) &&
+ ((p_cb->peer_auth_req & SMP_AUTH_YN_BIT) != 0) &&
((p_cb->loc_auth_req & SMP_AUTH_YN_BIT) == 0))
{
SMP_TRACE_ERROR0("IO capability does not meet authentication requirement");
@@ -804,7 +804,7 @@ void smp_decide_asso_model(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
key.p_data = p_cb->tk;
p = (tSMP_INT_DATA *)&key;
- memset(p_cb->tk, 0, BT_OCTET16_LEN);
+ memset(p_cb->tk, 0, BT_OCTET16_LEN);
/* TK, ready */
int_evt = SMP_KEY_READY_EVT;
}
@@ -840,7 +840,7 @@ void smp_proc_io_rsp(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
}
/*******************************************************************************
** Function smp_pairing_cmpl
-** Description This function is called to send the pairing complete callback
+** Description This function is called to send the pairing complete callback
** and remove the connection if needed.
*******************************************************************************/
void smp_pairing_cmpl(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
@@ -848,7 +848,7 @@ void smp_pairing_cmpl(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
SMP_TRACE_DEBUG0 ("smp_pairing_cmpl ");
- if ((p_cb->status == SMP_SUCCESS) ||
+ if ((p_cb->status == SMP_SUCCESS) ||
(p_cb->status <= SMP_REPEATED_ATTEMPTS && p_cb->status != SMP_SUCCESS))
{
smp_sm_event(p_cb, SMP_RELEASE_DELAY_EVT, p_data);
@@ -862,7 +862,7 @@ void smp_pairing_cmpl(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
}
/*******************************************************************************
** Function smp_pair_terminate
-** Description This function is called to send the pairing complete callback
+** Description This function is called to send the pairing complete callback
** and remove the connection if needed.
*******************************************************************************/
void smp_pair_terminate(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
@@ -892,8 +892,8 @@ void smp_idle_terminate(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
** Description This function is called when link is encrypted and notified to
** slave device. Proceed to to send LTK, DIV and ER to master if
** bonding the devices.
-**
-**
+**
+**
** Returns void
**
*******************************************************************************/
@@ -913,26 +913,26 @@ void smp_link_encrypted(BD_ADDR bda, UINT8 encr_enable)
btm_ble_update_sec_key_size(bda, p_cb->loc_enc_size);
}
- smp_sm_event(&smp_cb, SMP_ENCRYPTED_EVT, &encr_enable);
+ smp_sm_event(&smp_cb, SMP_ENCRYPTED_EVT, &encr_enable);
}
}
/*******************************************************************************
**
** Function smp_proc_ltk_request
**
-** Description This function is called when LTK request is received from
+** Description This function is called when LTK request is received from
** controller.
-**
+**
** Returns void
**
*******************************************************************************/
BOOLEAN smp_proc_ltk_request(BD_ADDR bda)
{
SMP_TRACE_DEBUG1 ("smp_proc_ltk_request state = %d", smp_cb.state);
- if ( smp_cb.state == SMP_ST_ENC_PENDING &&
+ if ( smp_cb.state == SMP_ST_ENC_PENDING &&
!memcmp(bda, smp_cb.pairing_bda, BD_ADDR_LEN))
{
- smp_sm_event(&smp_cb, SMP_ENC_REQ_EVT, NULL);
+ smp_sm_event(&smp_cb, SMP_ENC_REQ_EVT, NULL);
return TRUE;
}
diff --git a/stack/smp/smp_api.c b/stack/smp/smp_api.c
index 753e65e..e0c37e0 100644
--- a/stack/smp/smp_api.c
+++ b/stack/smp/smp_api.c
@@ -44,7 +44,7 @@ void SMP_Init(void)
smp_cb.trace_level = BT_TRACE_LEVEL_NONE; /* No traces */
#endif
- smp_l2cap_if_init();
+ smp_l2cap_if_init();
}
@@ -104,7 +104,7 @@ BOOLEAN SMP_Register (tSMP_CALLBACK *p_cback)
**
** Function SMP_Pair
**
-** Description This function call to perform a SMP pairing with peer device.
+** Description This function call to perform a SMP pairing with peer device.
** Device support one SMP pairing at one time.
**
** Parameters bd_addr - peer device bd address.
@@ -127,7 +127,7 @@ tSMP_STATUS SMP_Pair (BD_ADDR bd_addr)
{
p_cb->flags = SMP_PAIR_FLAGS_WE_STARTED_DD;
- memcpy (p_cb->pairing_bda, bd_addr, BD_ADDR_LEN);
+ memcpy (p_cb->pairing_bda, bd_addr, BD_ADDR_LEN);
if (!L2CA_ConnectFixedChnl (L2CAP_SMP_CID, bd_addr))
{
@@ -145,7 +145,7 @@ tSMP_STATUS SMP_Pair (BD_ADDR bd_addr)
**
** Function SMP_PairCancel
**
-** Description This function call to cancel a SMP pairing with peer device.
+** Description This function call to cancel a SMP pairing with peer device.
**
** Parameters bd_addr - peer device bd address.
**
@@ -159,7 +159,7 @@ BOOLEAN SMP_PairCancel (BD_ADDR bd_addr)
BOOLEAN status = FALSE;
BTM_TRACE_EVENT2 ("SMP_CancelPair state=%d flag=0x%x ", p_cb->state, p_cb->flags);
- if ( (p_cb->state != SMP_ST_IDLE) &&
+ if ( (p_cb->state != SMP_ST_IDLE) &&
(!memcmp (p_cb->pairing_bda, bd_addr, BD_ADDR_LEN)) )
{
p_cb->is_pair_cancel = TRUE;
@@ -177,8 +177,8 @@ BOOLEAN SMP_PairCancel (BD_ADDR bd_addr)
** Description This function is called to grant security process.
**
** Parameters bd_addr - peer device bd address.
-** res - result of the operation SMP_SUCCESS if success.
-** Otherwise, SMP_REPEATED_ATTEMPTS is too many attempts.
+** res - result of the operation SMP_SUCCESS if success.
+** Otherwise, SMP_REPEATED_ATTEMPTS is too many attempts.
**
** Returns None
**
@@ -191,7 +191,7 @@ void SMP_SecurityGrant(BD_ADDR bd_addr, UINT8 res)
memcmp (smp_cb.pairing_bda, bd_addr, BD_ADDR_LEN))
return;
- smp_sm_event(&smp_cb, SMP_API_SEC_GRANT_EVT, &res);
+ smp_sm_event(&smp_cb, SMP_API_SEC_GRANT_EVT, &res);
}
/*******************************************************************************
@@ -202,7 +202,7 @@ void SMP_SecurityGrant(BD_ADDR bd_addr, UINT8 res)
** passkey request to the application.
**
** Parameters: bd_addr - Address of the device for which passkey was requested
-** res - result of the operation SMP_SUCCESS if success
+** res - result of the operation SMP_SUCCESS if success
** passkey - numeric value in the range of
** BTM_MIN_PASSKEY_VAL(0) - BTM_MAX_PASSKEY_VAL(999999(0xF423F)).
**
@@ -259,7 +259,7 @@ void SMP_PasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 passkey)
** SMP in response to SMP_OOB_REQ_EVT
**
** Parameters: bd_addr - Address of the peer device
-** res - result of the operation SMP_SUCCESS if success
+** res - result of the operation SMP_SUCCESS if success
** p_data - simple pairing Randomizer C.
**
*******************************************************************************/
@@ -300,18 +300,18 @@ void SMP_OobDataReply(BD_ADDR bd_addr, tSMP_STATUS res, UINT8 len, UINT8 *p_data
**
** Description This function is called to encrypt the data with the specified
** key
-**
+**
** Parameters: key - Pointer to key key[0] conatins the MSB
** key_len - key length
** plain_text - Pointer to data to be encrypted
** plain_text[0] conatins the MSB
** pt_len - plain text length
** p_out - output of the encrypted texts
-**
-** Returns Boolean - request is successful
+**
+** Returns Boolean - request is successful
*******************************************************************************/
-BOOLEAN SMP_Encrypt (UINT8 *key, UINT8 key_len,
- UINT8 *plain_text, UINT8 pt_len,
+BOOLEAN SMP_Encrypt (UINT8 *key, UINT8 key_len,
+ UINT8 *plain_text, UINT8 pt_len,
tSMP_ENC *p_out)
{
diff --git a/stack/smp/smp_cmac.c b/stack/smp/smp_cmac.c
index d31930b..d72c3b5 100644
--- a/stack/smp/smp_cmac.c
+++ b/stack/smp/smp_cmac.c
@@ -26,7 +26,7 @@ typedef struct
UINT16 len;
UINT16 round;
}tCMAC_CB;
-
+
tCMAC_CB cmac_cb;
/* Rb for AES-128 as block cipher, LSB as [0] */
@@ -45,8 +45,8 @@ void print128(BT_OCTET16 x, const UINT8 *key_name)
for (i = 0; i < 4; i ++)
{
- SMP_TRACE_WARNING4("%02x %02x %02x %02x",
- p[BT_OCTET16_LEN - i*4 -1], p[BT_OCTET16_LEN - i*4 -2],
+ SMP_TRACE_WARNING4("%02x %02x %02x %02x",
+ p[BT_OCTET16_LEN - i*4 -1], p[BT_OCTET16_LEN - i*4 -2],
p[BT_OCTET16_LEN - i*4 -3], p[BT_OCTET16_LEN - i*4 -4]);
}
#endif
@@ -56,11 +56,11 @@ void print128(BT_OCTET16 x, const UINT8 *key_name)
**
** Function padding
**
-** Description utility function to padding the given text to be a 128 bits
+** Description utility function to padding the given text to be a 128 bits
** data. The parameter dest is input and output parameter, it
** must point to a BT_OCTET16_LEN memory space; where include
** length bytes valid data.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -76,7 +76,7 @@ static void padding ( BT_OCTET16 dest, UINT8 length )
** Function leftshift_onebit
**
** Description utility function to left shift one bit for a 128 bits value.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -98,12 +98,12 @@ static void leftshift_onebit(UINT8 *input, UINT8 *output)
** Function cmac_aes_cleanup
**
** Description clean up function for AES_CMAC algorithm.
-**
+**
** Returns void
**
*******************************************************************************/
static void cmac_aes_cleanup(void)
-{
+{
if (cmac_cb.text != NULL)
{
GKI_freebuf(cmac_cb.text);
@@ -116,7 +116,7 @@ static void cmac_aes_cleanup(void)
** Function cmac_aes_k_calculate
**
** Description This function is the calculation of block cipher using AES-128.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -138,7 +138,7 @@ static BOOLEAN cmac_aes_k_calculate(BT_OCTET16 key, UINT8 *p_signature, UINT16 t
err = 1;
break;
}
-
+
memcpy(x, output.param_buf, BT_OCTET16_LEN);
i ++;
}
@@ -149,9 +149,9 @@ static BOOLEAN cmac_aes_k_calculate(BT_OCTET16 key, UINT8 *p_signature, UINT16 t
memcpy(p_signature, p_mac, tlen);
SMP_TRACE_DEBUG2("tlen = %d p_mac = %d", tlen, p_mac);
- SMP_TRACE_DEBUG4("p_mac[0] = 0x%02x p_mac[1] = 0x%02x p_mac[2] = 0x%02x p_mac[3] = 0x%02x",
+ SMP_TRACE_DEBUG4("p_mac[0] = 0x%02x p_mac[1] = 0x%02x p_mac[2] = 0x%02x p_mac[3] = 0x%02x",
*p_mac, *(p_mac + 1), *(p_mac + 2), *(p_mac + 3));
- SMP_TRACE_DEBUG4("p_mac[4] = 0x%02x p_mac[5] = 0x%02x p_mac[6] = 0x%02x p_mac[7] = 0x%02x",
+ SMP_TRACE_DEBUG4("p_mac[4] = 0x%02x p_mac[5] = 0x%02x p_mac[6] = 0x%02x p_mac[7] = 0x%02x",
*(p_mac + 4), *(p_mac + 5), *(p_mac + 6), *(p_mac + 7));
return TRUE;
@@ -166,7 +166,7 @@ static BOOLEAN cmac_aes_k_calculate(BT_OCTET16 key, UINT8 *p_signature, UINT16 t
**
** Description This function proceeed to prepare the last block of message
** Mn depending on the size of the message.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -197,7 +197,7 @@ static void cmac_prepare_last_block (BT_OCTET16 k1, BT_OCTET16 k2)
** Function cmac_subkey_cont
**
** Description This is the callback function when CIPHk(0[128]) is completed.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -242,9 +242,9 @@ static void cmac_subkey_cont(tSMP_ENC *p)
** Function cmac_generate_subkey
**
** Description This is the function to generate the two subkeys.
-**
+**
** Parameters key - CMAC key, expect SRK when used by SMP.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -269,13 +269,13 @@ static BOOLEAN cmac_generate_subkey(BT_OCTET16 key)
** Function AES_CMAC
**
** Description This is the AES-CMAC Generation Function with tlen implemented.
-**
+**
** Parameters key - CMAC key in little endian order, expect SRK when used by SMP.
** input - text to be signed in little endian byte order.
** length - length of the input in byte.
** tlen - lenth of mac desired
** p_signature - data pointer to where signed data to be stored, tlen long.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -288,7 +288,7 @@ BOOLEAN AES_CMAC ( BT_OCTET16 key, UINT8 *input, UINT16 length,
SMP_TRACE_EVENT0 ("AES_CMAC ");
- if (n == 0) n = 1;
+ if (n == 0) n = 1;
len = n * BT_OCTET16_LEN;
SMP_TRACE_WARNING1("AES128_CMAC started, allocate buffer size = %d", len);
@@ -314,7 +314,7 @@ BOOLEAN AES_CMAC ( BT_OCTET16 key, UINT8 *input, UINT16 length,
/* start calculation */
ret = cmac_aes_k_calculate(key, p_signature, tlen);
}
- /* clean up */
+ /* clean up */
cmac_aes_cleanup();
}
else
@@ -322,7 +322,7 @@ BOOLEAN AES_CMAC ( BT_OCTET16 key, UINT8 *input, UINT16 length,
ret = FALSE;
SMP_TRACE_ERROR0("No resources");
}
-
+
return ret;
}
diff --git a/stack/smp/smp_int.h b/stack/smp/smp_int.h
index d9042d2..4ca9563 100644
--- a/stack/smp/smp_int.h
+++ b/stack/smp/smp_int.h
@@ -55,7 +55,7 @@ typedef UINT8 tSMP_ASSO_MODEL;
#define SMP_SIGN_INFO_EVT SMP_OPCODE_SIGN_INFO
#define SMP_SECURITY_REQ_EVT SMP_OPCODE_SEC_REQ
-#define SMP_SELF_DEF_EVT SMP_SECURITY_REQ_EVT
+#define SMP_SELF_DEF_EVT SMP_SECURITY_REQ_EVT
#define SMP_KEY_READY_EVT (SMP_SELF_DEF_EVT + 1)
#define SMP_ENCRYPTED_EVT (SMP_SELF_DEF_EVT + 2)
#define SMP_L2CAP_CONN_EVT (SMP_SELF_DEF_EVT + 3)
@@ -81,7 +81,7 @@ enum
SMP_ST_IDLE,
SMP_ST_WAIT_APP_RSP,
SMP_ST_SEC_REQ_PENDING,
- SMP_ST_PAIR_REQ_RSP,
+ SMP_ST_PAIR_REQ_RSP,
SMP_ST_WAIT_CONFIRM,
SMP_ST_CONFIRM,
SMP_ST_RAND,
@@ -128,8 +128,8 @@ typedef union
}tSMP_INT_DATA;
/* internal status mask */
-#define SMP_PAIR_FLAGS_WE_STARTED_DD (1)
-#define SMP_PAIR_FLAGS_PEER_STARTED_DD (1 << 1)
+#define SMP_PAIR_FLAGS_WE_STARTED_DD (1)
+#define SMP_PAIR_FLAGS_PEER_STARTED_DD (1 << 1)
#define SMP_PAIR_FLAGS_CMD_CONFIRM (1 << SMP_OPCODE_CONFIRM) /* 1 << 3 */
#define SMP_PAIR_FLAG_ENC_AFTER_PAIR (1 << 4)
@@ -215,7 +215,7 @@ extern "C"
#define smp_cb (*smp_cb_ptr)
#endif
-#ifdef __cplusplus
+#ifdef __cplusplus
}
#endif
@@ -224,15 +224,15 @@ SMP_API extern void smp_init (void);
#if SMP_CONFORMANCE_TESTING == TRUE
/* Used only for conformance testing */
-SMP_API extern void smp_set_test_confirm_value (BOOLEAN enable, UINT8 *p_c_value);
-SMP_API extern void smp_set_test_rand_value (BOOLEAN enable, UINT8 *p_c_value);
-SMP_API extern void smp_set_test_pair_fail_status (BOOLEAN enable, UINT8 status);
-SMP_API extern void smp_remove_fixed_channel_disable (BOOLEAN disable);
+SMP_API extern void smp_set_test_confirm_value (BOOLEAN enable, UINT8 *p_c_value);
+SMP_API extern void smp_set_test_rand_value (BOOLEAN enable, UINT8 *p_c_value);
+SMP_API extern void smp_set_test_pair_fail_status (BOOLEAN enable, UINT8 status);
+SMP_API extern void smp_remove_fixed_channel_disable (BOOLEAN disable);
#endif
/* smp main */
extern void smp_sm_event(tSMP_CB *p_cb, tSMP_EVENT event, void *p_data);
-extern void smp_proc_sec_request(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
+extern void smp_proc_sec_request(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
extern void smp_send_pair_req(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
extern void smp_send_confirm(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
extern void smp_send_pair_fail(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
@@ -282,8 +282,8 @@ extern void smp_convert_string_to_tk(BT_OCTET16 tk, UINT32 passkey);
extern void smp_mask_enc_key(UINT8 loc_enc_size, UINT8 * p_data);
extern void smp_rsp_timeout(TIMER_LIST_ENT *p_tle);
extern void smp_xor_128(BT_OCTET16 a, BT_OCTET16 b);
-extern BOOLEAN smp_encrypt_data (UINT8 *key, UINT8 key_len,
- UINT8 *plain_text, UINT8 pt_len,
+extern BOOLEAN smp_encrypt_data (UINT8 *key, UINT8 key_len,
+ UINT8 *plain_text, UINT8 pt_len,
tSMP_ENC *p_out);
/* smp key */
extern void smp_generate_confirm (tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
diff --git a/stack/smp/smp_keys.c b/stack/smp/smp_keys.c
index 9139c9c..a7c8496 100644
--- a/stack/smp/smp_keys.c
+++ b/stack/smp/smp_keys.c
@@ -26,7 +26,7 @@
#include "aes.h"
#ifndef SMP_MAX_ENC_REPEAT
#define SMP_MAX_ENC_REPEAT 3
- #endif
+ #endif
static void smp_rand_back(tBTM_RAND_ENC *p);
static void smp_genenrate_confirm(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
@@ -46,7 +46,7 @@ static const tSMP_ACT smp_encrypt_action[] =
smp_generate_stk, /* SMP_GEN_STK*/
smp_genenrate_ltk_cont, /* SMP_GEN_LTK */
smp_generate_ltk, /* SMP_GEN_DIV_LTK */
- smp_generate_rand_vector, /* SMP_GEN_RAND_V */
+ smp_generate_rand_vector, /* SMP_GEN_RAND_V */
smp_generate_y, /* SMP_GEN_EDIV */
smp_generate_passkey, /* SMP_GEN_TK */
smp_generate_confirm, /* SMP_GEN_SRAND_MRAND */
@@ -78,19 +78,19 @@ static void smp_debug_print_nbyte_little_endian (UINT8 *p, const UINT8 *key_name
** Function smp_encrypt_data
**
** Description This function is called to generate passkey.
-**
+**
** Returns void
**
*******************************************************************************/
-BOOLEAN smp_encrypt_data (UINT8 *key, UINT8 key_len,
- UINT8 *plain_text, UINT8 pt_len,
+BOOLEAN smp_encrypt_data (UINT8 *key, UINT8 key_len,
+ UINT8 *plain_text, UINT8 pt_len,
tSMP_ENC *p_out)
{
aes_context ctx;
UINT8 *p_start = NULL;
UINT8 *p = NULL;
UINT8 *p_rev_data = NULL; /* input data in big endilan format */
- UINT8 *p_rev_key = NULL; /* input key in big endilan format */
+ UINT8 *p_rev_key = NULL; /* input key in big endilan format */
UINT8 *p_rev_output = NULL; /* encrypted output in big endilan format */
SMP_TRACE_DEBUG0 ("smp_encrypt_data");
@@ -117,19 +117,19 @@ BOOLEAN smp_encrypt_data (UINT8 *key, UINT8 key_len,
p_rev_key = p; /* start at byte 32 */
REVERSE_ARRAY_TO_STREAM (p, key, SMP_ENCRYT_KEY_SIZE); /* byte 32 to byte 47 */
- smp_debug_print_nbyte_little_endian(key, (const UINT8 *)"Key", SMP_ENCRYT_KEY_SIZE);
- smp_debug_print_nbyte_little_endian(p_start, (const UINT8 *)"Plain text", SMP_ENCRYT_DATA_SIZE);
+ smp_debug_print_nbyte_little_endian(key, (const UINT8 *)"Key", SMP_ENCRYT_KEY_SIZE);
+ smp_debug_print_nbyte_little_endian(p_start, (const UINT8 *)"Plain text", SMP_ENCRYT_DATA_SIZE);
p_rev_output = p;
aes_set_key(p_rev_key, SMP_ENCRYT_KEY_SIZE, &ctx);
aes_encrypt(p_rev_data, p, &ctx); /* outputs in byte 48 to byte 63 */
p = p_out->param_buf;
- REVERSE_ARRAY_TO_STREAM (p, p_rev_output, SMP_ENCRYT_DATA_SIZE);
- smp_debug_print_nbyte_little_endian(p_out->param_buf, (const UINT8 *)"Encrypted text", SMP_ENCRYT_KEY_SIZE);
+ REVERSE_ARRAY_TO_STREAM (p, p_rev_output, SMP_ENCRYT_DATA_SIZE);
+ smp_debug_print_nbyte_little_endian(p_out->param_buf, (const UINT8 *)"Encrypted text", SMP_ENCRYT_KEY_SIZE);
p_out->param_len = SMP_ENCRYT_KEY_SIZE;
p_out->status = HCI_SUCCESS;
- p_out->opcode = HCI_BLE_ENCRYPT;
+ p_out->opcode = HCI_BLE_ENCRYPT;
GKI_freebuf(p_start);
@@ -142,7 +142,7 @@ BOOLEAN smp_encrypt_data (UINT8 *key, UINT8 key_len,
** Function smp_generate_passkey
**
** Description This function is called to generate passkey.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -160,7 +160,7 @@ void smp_generate_passkey(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
** Function smp_proc_passkey
**
** Description This function is called to process a passkey.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -178,7 +178,7 @@ void smp_proc_passkey(tSMP_CB *p_cb , tBTM_RAND_ENC *p)
/* truncate by maximum value */
while (passkey > BTM_MAX_PASSKEY_VAL)
passkey >>= 1;
- SMP_TRACE_ERROR1("Passkey generated = %d", passkey);
+ SMP_TRACE_ERROR1("Passkey generated = %d", passkey);
/* save the TK */
memset(p_cb->tk, 0, BT_OCTET16_LEN);
@@ -192,7 +192,7 @@ void smp_proc_passkey(tSMP_CB *p_cb , tBTM_RAND_ENC *p)
(*p_cb->p_callback)(SMP_PASSKEY_NOTIF_EVT, p_cb->pairing_bda, (tSMP_EVT_DATA *)&passkey);
}
- smp_sm_event(p_cb, SMP_KEY_READY_EVT, (tSMP_INT_DATA *)&key);
+ smp_sm_event(p_cb, SMP_KEY_READY_EVT, (tSMP_INT_DATA *)&key);
}
@@ -200,8 +200,8 @@ void smp_proc_passkey(tSMP_CB *p_cb , tBTM_RAND_ENC *p)
**
** Function smp_generate_stk
**
-** Description This function is called to generate STK calculated by running
-** AES with the TK value as key and a concatenation of the random
+** Description This function is called to generate STK calculated by running
+** AES with the TK value as key and a concatenation of the random
** values.
**
** Returns void
@@ -231,8 +231,8 @@ void smp_generate_stk (tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
/* generate STK = Etk(rand|rrand)*/
if (!SMP_Encrypt( p_cb->tk, BT_OCTET16_LEN, ptext, BT_OCTET16_LEN, &output))
{
- SMP_TRACE_ERROR0("smp_generate_stk failed");
- smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status);
+ SMP_TRACE_ERROR0("smp_generate_stk failed");
+ smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status);
}
else
{
@@ -246,7 +246,7 @@ void smp_generate_stk (tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
**
** Description This function is called to start the second pairing phase by
** start generating initializer random number.
-**
+**
**
** Returns void
**
@@ -265,12 +265,12 @@ void smp_generate_confirm (tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
**
** Description This function is called to generate another 64 bits random for
** MRand or Srand.
-**
+**
** Returns void
**
*******************************************************************************/
void smp_genenrate_rand_cont(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
-{
+{
SMP_TRACE_DEBUG0 ("smp_genenrate_rand_cont ");
p_cb->rand_enc_proc = SMP_GEN_SRAND_MRAND_CONT;
/* generate 64 MSB of MRand or SRand */
@@ -284,7 +284,7 @@ void smp_genenrate_rand_cont(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
**
** Description This function is called to calculate LTK, starting with DIV
** generation.
-**
+**
**
** Returns void
**
@@ -317,7 +317,7 @@ void smp_generate_ltk(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
** Function smp_compute_csrk
**
** Description This function is called to calculate CSRK
-**
+**
**
** Returns void
**
@@ -339,12 +339,12 @@ void smp_compute_csrk(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
if (!SMP_Encrypt(er, BT_OCTET16_LEN, buffer, 4, &output))
{
- SMP_TRACE_ERROR0("smp_generate_csrk failed");
- smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status);
+ SMP_TRACE_ERROR0("smp_generate_csrk failed");
+ smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status);
}
else
{
- memcpy((void *)p_cb->csrk, output.param_buf, BT_OCTET16_LEN);
+ memcpy((void *)p_cb->csrk, output.param_buf, BT_OCTET16_LEN);
smp_send_csrk_info(p_cb, NULL);
}
}
@@ -355,7 +355,7 @@ void smp_compute_csrk(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
**
** Description This function is called to calculate LTK, starting with DIV
** generation.
-**
+**
**
** Returns void
**
@@ -406,7 +406,7 @@ void smp_concatenate_local( tSMP_CB *p_cb, UINT8 **p_data, UINT8 op_code)
*******************************************************************************/
void smp_concatenate_peer( tSMP_CB *p_cb, UINT8 **p_data, UINT8 op_code)
{
- UINT8 *p = *p_data;
+ UINT8 *p = *p_data;
SMP_TRACE_DEBUG0 ("smp_concatenate_peer ");
UINT8_TO_STREAM(p, op_code);
@@ -423,9 +423,9 @@ void smp_concatenate_peer( tSMP_CB *p_cb, UINT8 **p_data, UINT8 op_code)
**
** Function smp_gen_p1_4_confirm
**
-** Description Generate Confirm/Compare Step1:
+** Description Generate Confirm/Compare Step1:
** p1 = pres || preq || rat' || iat'
-**
+**
** Returns void
**
*******************************************************************************/
@@ -474,9 +474,9 @@ void smp_gen_p1_4_confirm( tSMP_CB *p_cb, BT_OCTET16 p1)
**
** Function smp_gen_p2_4_confirm
**
-** Description Generate Confirm/Compare Step2:
+** Description Generate Confirm/Compare Step2:
** p2 = padding || ia || ra
-**
+**
** Returns void
**
*******************************************************************************/
@@ -511,7 +511,7 @@ void smp_gen_p2_4_confirm( tSMP_CB *p_cb, BT_OCTET16 p2)
** Function smp_calculate_comfirm
**
** Description This function is called to calculate Confirm value.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -533,8 +533,8 @@ void smp_calculate_comfirm (tSMP_CB *p_cb, BT_OCTET16 rand, BD_ADDR bda)
/* calculate e(k, r XOR p1), where k = TK */
if (!SMP_Encrypt(p_cb->tk, BT_OCTET16_LEN, p1, BT_OCTET16_LEN, &output))
{
- SMP_TRACE_ERROR0("smp_generate_csrk failed");
- smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status);
+ SMP_TRACE_ERROR0("smp_generate_csrk failed");
+ smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status);
}
else
{
@@ -547,7 +547,7 @@ void smp_calculate_comfirm (tSMP_CB *p_cb, BT_OCTET16 rand, BD_ADDR bda)
**
** Description This function is called when SConfirm/MConfirm is generated
** proceed to send the Confirm request/response to peer device.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -572,8 +572,8 @@ static void smp_calculate_comfirm_cont(tSMP_CB *p_cb, tSMP_ENC *p)
/* calculate: Confirm = E(k, p1' XOR p2) */
if (!SMP_Encrypt(p_cb->tk, BT_OCTET16_LEN, p2, BT_OCTET16_LEN, &output))
{
- SMP_TRACE_ERROR0("smp_calculate_comfirm_cont failed");
- smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status);
+ SMP_TRACE_ERROR0("smp_calculate_comfirm_cont failed");
+ smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status);
}
else
{
@@ -595,12 +595,12 @@ static void smp_calculate_comfirm_cont(tSMP_CB *p_cb, tSMP_ENC *p)
**
** Description This function is called when a 48 bits random number is generated
** as SRand or MRand, continue to calculate Sconfirm or MConfirm.
-**
+**
** Returns void
**
*******************************************************************************/
static void smp_genenrate_confirm(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
-{
+{
SMP_TRACE_DEBUG0 ("smp_genenrate_confirm ");
p_cb->rand_enc_proc = SMP_GEN_CONFIRM;
@@ -615,12 +615,12 @@ static void smp_genenrate_confirm(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
** Description This function is called to generate SConfirm for Slave device,
** or MSlave for Master device. This function can be also used for
** generating Compare number for confirm value check.
-**
+**
** Returns void
**
*******************************************************************************/
void smp_generate_compare (tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
-{
+{
SMP_TRACE_DEBUG0 ("smp_generate_compare ");
p_cb->rand_enc_proc = SMP_GEN_COMPARE;
@@ -634,7 +634,7 @@ void smp_generate_compare (tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
**
** Description This function is called when SConfirm/MConfirm is generated
** proceed to send the Confirm request/response to peer device.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -659,7 +659,7 @@ static void smp_process_confirm(tSMP_CB *p_cb, tSMP_ENC *p)
#if (SMP_DEBUG == TRUE)
SMP_TRACE_DEBUG0("Confirm Generated");
smp_debug_print_nbyte_little_endian ((UINT8 *)p_cb->confirm, (const UINT8 *)"Confirm", 16);
-#endif
+#endif
key.key_type = SMP_KEY_TYPE_CFM;
key.p_data = p->param_buf;
@@ -670,9 +670,9 @@ static void smp_process_confirm(tSMP_CB *p_cb, tSMP_ENC *p)
**
** Function smp_process_compare
**
-** Description This function is called when Compare is generated using the
+** Description This function is called when Compare is generated using the
** RRand and local BDA, TK information.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -697,7 +697,7 @@ static void smp_process_compare(tSMP_CB *p_cb, tSMP_ENC *p)
**
** Description This function is called when STK is generated
** proceed to send the encrypt the link using STK.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -722,7 +722,7 @@ static void smp_process_stk(tSMP_CB *p_cb, tSMP_ENC *p)
** Function smp_genenrate_ltk_cont
**
** Description This function is to calculate LTK = d1(ER, DIV, 0)= e(ER, DIV)
-**
+**
** Returns void
**
*******************************************************************************/
@@ -736,17 +736,17 @@ static void smp_genenrate_ltk_cont(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
BTM_GetDeviceEncRoot(er);
/* LTK = d1(ER, DIV, 0)= e(ER, DIV)*/
- if (!SMP_Encrypt(er, BT_OCTET16_LEN, (UINT8 *)&p_cb->div,
+ if (!SMP_Encrypt(er, BT_OCTET16_LEN, (UINT8 *)&p_cb->div,
sizeof(UINT16), &output))
{
- SMP_TRACE_ERROR0("smp_genenrate_ltk_cont failed");
- smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status);
+ SMP_TRACE_ERROR0("smp_genenrate_ltk_cont failed");
+ smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status);
}
else
{
/* mask the LTK */
smp_mask_enc_key(p_cb->loc_enc_size, output.param_buf);
- memcpy((void *)p_cb->ltk, output.param_buf, BT_OCTET16_LEN);
+ memcpy((void *)p_cb->ltk, output.param_buf, BT_OCTET16_LEN);
smp_generate_rand_vector(p_cb, NULL);
}
@@ -757,12 +757,12 @@ static void smp_genenrate_ltk_cont(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
** Function smp_generate_y
**
** Description This function is to proceed generate Y = E(DHK, Rand)
-**
+**
** Returns void
**
*******************************************************************************/
static void smp_generate_y(tSMP_CB *p_cb, tSMP_INT_DATA *p)
-{
+{
BT_OCTET16 dhk;
tSMP_ENC output;
tSMP_STATUS status = SMP_PAIR_FAIL_UNKNOWN;
@@ -771,11 +771,11 @@ static void smp_generate_y(tSMP_CB *p_cb, tSMP_INT_DATA *p)
SMP_TRACE_DEBUG0 ("smp_generate_y ");
BTM_GetDeviceDHK(dhk);
- if (!SMP_Encrypt(dhk, BT_OCTET16_LEN, p_cb->enc_rand,
+ if (!SMP_Encrypt(dhk, BT_OCTET16_LEN, p_cb->enc_rand,
BT_OCTET8_LEN, &output))
{
- SMP_TRACE_ERROR0("smp_generate_y failed");
- smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status);
+ SMP_TRACE_ERROR0("smp_generate_y failed");
+ smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status);
}
else
{
@@ -788,7 +788,7 @@ static void smp_generate_y(tSMP_CB *p_cb, tSMP_INT_DATA *p)
**
** Description This function is called when LTK is generated, send state machine
** event to SMP.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -807,7 +807,7 @@ static void smp_generate_rand_vector (tSMP_CB *p_cb, tSMP_INT_DATA *p)
** Function smp_genenrate_smp_process_edivltk_cont
**
** Description This function is to calculate EDIV = Y xor DIV
-**
+**
** Returns void
**
*******************************************************************************/
@@ -836,12 +836,12 @@ static void smp_process_ediv(tSMP_CB *p_cb, tSMP_ENC *p)
**
** Description This function is to process the rand command finished,
** process the random/encrypted number for further action.
-**
+**
** Returns void
**
*******************************************************************************/
static void smp_rand_back(tBTM_RAND_ENC *p)
-{
+{
tSMP_CB *p_cb = &smp_cb;
UINT8 *pp = p->param_buf;
UINT8 failure = SMP_PAIR_FAIL_UNKNOWN;
@@ -852,7 +852,7 @@ static void smp_rand_back(tBTM_RAND_ENC *p)
{
switch (state)
{
-
+
case SMP_GEN_SRAND_MRAND:
memcpy((void *)p_cb->rand, p->param_buf, p->param_len);
smp_genenrate_rand_cont(p_cb, NULL);
@@ -889,7 +889,7 @@ static void smp_rand_back(tBTM_RAND_ENC *p)
SMP_TRACE_ERROR1("smp_rand_back Key generation failed: (%d)", p_cb->rand_enc_proc);
- smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &failure);
+ smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &failure);
}
#endif
diff --git a/stack/smp/smp_l2c.c b/stack/smp/smp_l2c.c
index 36e6ee7..0356612 100644
--- a/stack/smp/smp_l2c.c
+++ b/stack/smp/smp_l2c.c
@@ -46,7 +46,7 @@ void smp_l2cap_if_init (void)
fixed_reg.pL2CA_FixedConn_Cb = smp_connect_cback;
fixed_reg.pL2CA_FixedData_Cb = smp_data_ind;
fixed_reg.default_idle_tout = 60; /* set 60 seconds timeout, 0xffff default idle timeout */
-
+
/* Now, register with L2CAP */
L2CA_RegisterFixedChannel (L2CAP_SMP_CID, &fixed_reg);
}
@@ -55,8 +55,8 @@ void smp_l2cap_if_init (void)
**
** Function smp_connect_cback
**
-** Description This callback function is called by L2CAP to indicate that
-** SMP channel is
+** Description This callback function is called by L2CAP to indicate that
+** SMP channel is
** connected (conn = TRUE)/disconnected (conn = FALSE).
**
*******************************************************************************/
@@ -70,7 +70,7 @@ static void smp_connect_cback (BD_ADDR bd_addr, BOOLEAN connected, UINT16 reason
if (memcmp(bd_addr, p_cb->pairing_bda, BD_ADDR_LEN) == 0)
{
SMP_TRACE_EVENT3 ("smp_connect_cback() for pairing BDA: %08x%04x Event: %s",
- (bd_addr[0]<<24)+(bd_addr[1]<<16)+(bd_addr[2]<<8) + bd_addr[3],
+ (bd_addr[0]<<24)+(bd_addr[1]<<16)+(bd_addr[2]<<8) + bd_addr[3],
(bd_addr[4]<<8)+bd_addr[5], (connected) ? "connected" : "disconnected");
if (connected)
@@ -80,13 +80,13 @@ static void smp_connect_cback (BD_ADDR bd_addr, BOOLEAN connected, UINT16 reason
p_cb->connect_initialized = TRUE;
/* initiating connection established */
p_cb->role = L2CA_GetBleConnRole(bd_addr);
-
+
/* initialize local i/r key to be default keys */
p_cb->loc_r_key = p_cb->loc_i_key = SMP_SEC_DEFAULT_KEY;
p_cb->loc_auth_req = p_cb->peer_auth_req = SMP_DEFAULT_AUTH_REQ;
p_cb->cb_evt = SMP_IO_CAP_REQ_EVT;
smp_sm_event(p_cb, SMP_L2CAP_CONN_EVT, NULL);
-
+
BTM_ReadConnectionAddr(p_cb->local_bda);
}
}
@@ -105,7 +105,7 @@ static void smp_connect_cback (BD_ADDR bd_addr, BOOLEAN connected, UINT16 reason
**
** Description This function is called when data is received from L2CAP on
** SMP channel.
-**
+**
**
** Returns void
**
@@ -120,7 +120,7 @@ static void smp_data_ind (BD_ADDR bd_addr, BT_HDR *p_buf)
SMP_TRACE_EVENT0 ("Got smp_data_ind");
STREAM_TO_UINT8(cmd, p);
-
+
/* reject the pairing request if there is an on-going SMP pairing */
if (SMP_OPCODE_PAIRING_REQ == cmd || SMP_OPCODE_SEC_REQ == cmd)
@@ -138,10 +138,10 @@ static void smp_data_ind (BD_ADDR bd_addr, BT_HDR *p_buf)
}
if (memcmp(&bd_addr[0], p_cb->pairing_bda, BD_ADDR_LEN) == 0)
- {
+ {
btu_stop_timer (&p_cb->rsp_timer_ent);
smp_sm_event(p_cb, cmd, p);
- }
+ }
GKI_freebuf (p_buf);
}
diff --git a/stack/smp/smp_main.c b/stack/smp/smp_main.c
index 91d0989..1b67011 100644
--- a/stack/smp/smp_main.c
+++ b/stack/smp/smp_main.c
@@ -17,12 +17,12 @@
#include "smp_int.h"
-const char * const smp_state_name [] =
+const char * const smp_state_name [] =
{
"SMP_ST_IDLE",
"SMP_ST_WAIT_APP_RSP",
"SMP_ST_SEC_REQ_PENDING",
- "SMP_ST_PAIR_REQ_RSP",
+ "SMP_ST_PAIR_REQ_RSP",
"SMP_ST_WAIT_CONFIRM",
"SMP_ST_CONFIRM",
"SMP_ST_RAND",
@@ -31,29 +31,29 @@ const char * const smp_state_name [] =
"SMP_ST_RELEASE_DELAY",
"SMP_ST_MAX"
};
-const char * const smp_event_name [] =
+const char * const smp_event_name [] =
{
- "PAIRING_REQ_EVT",
- "PAIRING_RSP_EVT",
- "CONFIRM_EVT",
- "RAND_EVT",
- "PAIRING_FAILED_EVT",
- "ENC_INFO_EVT",
+ "PAIRING_REQ_EVT",
+ "PAIRING_RSP_EVT",
+ "CONFIRM_EVT",
+ "RAND_EVT",
+ "PAIRING_FAILED_EVT",
+ "ENC_INFO_EVT",
"MASTER_ID_EVT",
"ID_INFO_EVT",
"ID_ADDR_EVT",
"SIGN_INFO_EVT",
- "SECURITY_REQ_EVT",
- "KEY_READY_EVT",
- "ENCRYPTED_EVT",
- "L2CAP_CONN_EVT",
- "L2CAP_DISCONN_EVT",
- "API_IO_RSP_EVT",
- "API_SEC_GRANT_EVT",
- "TK_REQ_EVT",
- "AUTH_CMPL_EVT",
- "ENC_REQ_EVT",
- "BOND_REQ_EVT",
+ "SECURITY_REQ_EVT",
+ "KEY_READY_EVT",
+ "ENCRYPTED_EVT",
+ "L2CAP_CONN_EVT",
+ "L2CAP_DISCONN_EVT",
+ "API_IO_RSP_EVT",
+ "API_SEC_GRANT_EVT",
+ "TK_REQ_EVT",
+ "AUTH_CMPL_EVT",
+ "ENC_REQ_EVT",
+ "BOND_REQ_EVT",
"DISCARD_SEC_REQ_EVT",
"RELEASE_DELAY_EVT",
"RELEASE_DELAY_TOUT_EVT",
@@ -109,9 +109,9 @@ enum
SMP_SM_NO_ACTION
};
-static const tSMP_ACT smp_sm_action[] =
+static const tSMP_ACT smp_sm_action[] =
{
- smp_proc_sec_req,
+ smp_proc_sec_req,
smp_send_pair_req,
smp_send_pair_rsp,
smp_send_confirm,
@@ -194,11 +194,11 @@ static const UINT8 smp_ma_idle_table[][SMP_SM_NUM_COLS] = {
static const UINT8 smp_ma_wait_app_rsp_table[][SMP_SM_NUM_COLS] = {
/* Event Action Next State */
-/* SEC_GRANT */ { SMP_PROC_SEC_GRANT, SMP_SEND_APP_CBACK, SMP_ST_WAIT_APP_RSP},
+/* SEC_GRANT */ { SMP_PROC_SEC_GRANT, SMP_SEND_APP_CBACK, SMP_ST_WAIT_APP_RSP},
/* IO_RSP */ { SMP_SEND_PAIR_REQ, SMP_SM_NO_ACTION, SMP_ST_PAIR_REQ_RSP},
-/* KEY_READY */ { SMP_GENERATE_CONFIRM, SMP_SM_NO_ACTION, SMP_ST_WAIT_CONFIRM},/* TK ready */
-/* ENC_REQ */ { SMP_START_ENC, SMP_SM_NO_ACTION, SMP_ST_ENC_PENDING},/* start enc mode setup */
-/* DISCARD_SEC_REQ */ { SMP_PROC_DISCARD, SMP_SM_NO_ACTION, SMP_ST_IDLE}
+/* KEY_READY */ { SMP_GENERATE_CONFIRM, SMP_SM_NO_ACTION, SMP_ST_WAIT_CONFIRM},/* TK ready */
+/* ENC_REQ */ { SMP_START_ENC, SMP_SM_NO_ACTION, SMP_ST_ENC_PENDING},/* start enc mode setup */
+/* DISCARD_SEC_REQ */ { SMP_PROC_DISCARD, SMP_SM_NO_ACTION, SMP_ST_IDLE}
};
static const UINT8 smp_ma_pair_req_rsp_table [][SMP_SM_NUM_COLS] = {
@@ -250,7 +250,7 @@ static const UINT8 smp_ma_rel_delay_table[][SMP_SM_NUM_COLS] = {
/************ SMP Slave FSM State/Event Indirection Table **************/
static const UINT8 smp_sl_entry_map[][SMP_ST_MAX] =
{
-/* state name: Idle Wait SecReq Pair Wait Confirm Init Enc Bond Rel
+/* state name: Idle Wait SecReq Pair Wait Confirm Init Enc Bond Rel
AppRsp Pend ReqRsp Cfm Pend Pend Delay */
/* PAIR_REQ */ { 2, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
/* PAIR_RSP */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
@@ -380,20 +380,20 @@ void smp_set_state(tSMP_STATE state)
{
if (state < SMP_ST_MAX)
{
- SMP_TRACE_DEBUG4( "State change: %s(%d) ==> %s(%d)",
+ SMP_TRACE_DEBUG4( "State change: %s(%d) ==> %s(%d)",
smp_get_state_name(smp_cb.state), smp_cb.state,
- smp_get_state_name(state), state );
+ smp_get_state_name(state), state );
smp_cb.state = state;
}
else
{
- SMP_TRACE_DEBUG1("smp_set_state invalid state =%d", state );
+ SMP_TRACE_DEBUG1("smp_set_state invalid state =%d", state );
}
}
/*******************************************************************************
** Function smp_get_state
-** Returns The smp state
+** Returns The smp state
*******************************************************************************/
tSMP_STATE smp_get_state(void)
{
@@ -406,11 +406,11 @@ tSMP_STATE smp_get_state(void)
** Function smp_sm_event
**
** Description Handle events to the state machine. It looks up the entry
-** in the smp_entry_table array.
-** If it is a valid entry, it gets the state table.Set the next state,
-** if not NULL state.Execute the action function according to the
-** state table. If the state returned by action function is not NULL
-** state, adjust the new state to the returned state.If (api_evt != MAX),
+** in the smp_entry_table array.
+** If it is a valid entry, it gets the state table.Set the next state,
+** if not NULL state.Execute the action function according to the
+** state table. If the state returned by action function is not NULL
+** state, adjust the new state to the returned state.If (api_evt != MAX),
** call callback function.
**
** Returns void.
@@ -431,7 +431,7 @@ void smp_sm_event(tSMP_CB *p_cb, tSMP_EVENT event, void *p_data)
}
SMP_TRACE_DEBUG5( "SMP Role: %s State: [%s (%d)], Event: [%s (%d)]",\
- (p_cb->role == 0x01) ?"Slave" : "Master", smp_get_state_name( p_cb->state),
+ (p_cb->role == 0x01) ?"Slave" : "Master", smp_get_state_name( p_cb->state),
p_cb->state, smp_get_event_name(event), event) ;
/* look up the state table for the current state */
@@ -450,7 +450,7 @@ void smp_sm_event(tSMP_CB *p_cb, tSMP_EVENT event, void *p_data)
}
else
{
- SMP_TRACE_DEBUG4( "Ignore event [%s (%d)] in state [%s (%d)]",
+ SMP_TRACE_DEBUG4( "Ignore event [%s (%d)] in state [%s (%d)]",
smp_get_event_name(event), event, smp_get_state_name(curr_state), curr_state);
return;
}
@@ -489,7 +489,7 @@ const char * smp_get_state_name(tSMP_STATE state)
if (state < SMP_ST_MAX)
{
- p_str = smp_state_name[state];
+ p_str = smp_state_name[state];
}
return p_str;
}
diff --git a/stack/smp/smp_utils.c b/stack/smp/smp_utils.c
index 5065823..91e7057 100644
--- a/stack/smp/smp_utils.c
+++ b/stack/smp/smp_utils.c
@@ -475,7 +475,7 @@ void smp_mask_enc_key(UINT8 loc_enc_size, UINT8 * p_data)
**
** Description utility function to do an biteise exclusive-OR of two bit
** strings of the length of BT_OCTET16_LEN.
-**
+**
** Returns void
**
*******************************************************************************/
@@ -628,7 +628,7 @@ void smp_set_test_rand_value(BOOLEAN enable, UINT8 *p_c_val)
**
** Function smp_set_test_pair_fail_status
**
-** Description This function is called to set the test fairing fair status
+** Description This function is called to set the test fairing fair status
**
** Returns void
**