Bluetooth: Remove dead code

Since now TinyCrypt is always enabled there is no need for HCI
backup code.

Change-Id: I6cf9c2bd15dc9a6c0dd98cd7aff0ea137eb0be8b
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This commit is contained in:
Szymon Janc 2016-02-11 15:29:58 +01:00 committed by Johan Hedberg
commit 8dbd8dcc5b
2 changed files with 1 additions and 78 deletions

View file

@ -33,10 +33,8 @@
#include <bluetooth/hci.h> #include <bluetooth/hci.h>
#include <bluetooth/driver.h> #include <bluetooth/driver.h>
#if defined(CONFIG_TINYCRYPT_SHA256_HMAC_PRNG)
#include <tinycrypt/hmac_prng.h> #include <tinycrypt/hmac_prng.h>
#include <tinycrypt/utils.h> #include <tinycrypt/utils.h>
#endif /* CONFIG_TINYCRYPT_SHA256_HMAC_PRNG */
#include "stack.h" #include "stack.h"
@ -102,9 +100,7 @@ static struct nano_fifo avail_hci_evt;
static NET_BUF_POOL(hci_evt_pool, CONFIG_BLUETOOTH_HCI_EVT_COUNT, EVT_BUF_SIZE, static NET_BUF_POOL(hci_evt_pool, CONFIG_BLUETOOTH_HCI_EVT_COUNT, EVT_BUF_SIZE,
&avail_hci_evt, NULL, 0); &avail_hci_evt, NULL, 0);
#if defined(CONFIG_TINYCRYPT_SHA256_HMAC_PRNG)
static struct tc_hmac_prng_struct prng; static struct tc_hmac_prng_struct prng;
#endif /* CONFIG_TINYCRYPT_SHA256_HMAC_PRNG */
#if defined(CONFIG_BLUETOOTH_CONN) #if defined(CONFIG_BLUETOOTH_CONN)
static void report_completed_packet(struct net_buf *buf) static void report_completed_packet(struct net_buf *buf)
@ -1187,7 +1183,6 @@ static void hci_cmd_status(struct net_buf *buf)
} }
} }
#if defined(CONFIG_TINYCRYPT_SHA256_HMAC_PRNG)
static int prng_reseed(struct tc_hmac_prng_struct *h) static int prng_reseed(struct tc_hmac_prng_struct *h)
{ {
uint8_t seed[32]; uint8_t seed[32];
@ -1267,35 +1262,6 @@ int bt_rand(void *buf, size_t len)
return -EIO; return -EIO;
} }
#else
int bt_rand(void *buf, size_t len)
{
uint8_t *ptr = buf;
while (len > 0) {
struct bt_hci_rp_le_rand *rp;
struct net_buf *rsp;
size_t copy;
int err;
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_RAND, NULL, &rsp);
if (err) {
BT_ERR("HCI_LE_Random failed (%d)", err);
return err;
}
rp = (void *)rsp->data;
copy = min(len, sizeof(rp->rand));
memcpy(ptr, rp->rand, copy);
net_buf_unref(rsp);
len -= copy;
ptr += copy;
}
return 0;
}
#endif /* CONFIG_TINYCRYPT_SHA256_HMAC_PRNG */
static int le_set_nrpa(void) static int le_set_nrpa(void)
{ {
@ -2112,13 +2078,7 @@ static int le_init(void)
} }
#endif /* CONFIG_BLUETOOTH_SMP && !CONFIG_TINYCRYPT_ECC_DH*/ #endif /* CONFIG_BLUETOOTH_SMP && !CONFIG_TINYCRYPT_ECC_DH*/
#if defined(CONFIG_TINYCRYPT_SHA256_HMAC_PRNG) return prng_init(&prng);
err = prng_init(&prng);
if (err) {
return err;
}
#endif /* CONFIG_TINYCRYPT_SHA256_HMAC_PRNG */
return 0;
} }
#if defined(CONFIG_BLUETOOTH_BREDR) #if defined(CONFIG_BLUETOOTH_BREDR)

View file

@ -34,11 +34,9 @@
#include <bluetooth/bluetooth.h> #include <bluetooth/bluetooth.h>
#include <bluetooth/conn.h> #include <bluetooth/conn.h>
#if defined(CONFIG_TINYCRYPT_AES)
#include <tinycrypt/aes.h> #include <tinycrypt/aes.h>
#include <tinycrypt/utils.h> #include <tinycrypt/utils.h>
#include <tinycrypt/cmac_mode.h> #include <tinycrypt/cmac_mode.h>
#endif
#if defined(CONFIG_TINYCRYPT_ECC_DH) #if defined(CONFIG_TINYCRYPT_ECC_DH)
#include <tinycrypt/ecc.h> #include <tinycrypt/ecc.h>
@ -290,7 +288,6 @@ static void swap_in_place(uint8_t *buf, uint16_t len)
} }
} }
#if defined(CONFIG_TINYCRYPT_AES)
static int le_encrypt(const uint8_t key[16], const uint8_t plaintext[16], static int le_encrypt(const uint8_t key[16], const uint8_t plaintext[16],
uint8_t enc_data[16]) uint8_t enc_data[16])
{ {
@ -317,40 +314,6 @@ static int le_encrypt(const uint8_t key[16], const uint8_t plaintext[16],
return 0; return 0;
} }
#else
static int le_encrypt(const uint8_t key[16], const uint8_t plaintext[16],
uint8_t enc_data[16])
{
struct bt_hci_cp_le_encrypt *cp;
struct bt_hci_rp_le_encrypt *rp;
struct net_buf *buf, *rsp;
int err;
BT_DBG("key %s plaintext %s", h(key, 16), h(plaintext, 16));
buf = bt_hci_cmd_create(BT_HCI_OP_LE_ENCRYPT, sizeof(*cp));
if (!buf) {
return -ENOBUFS;
}
cp = net_buf_add(buf, sizeof(*cp));
memcpy(cp->key, key, sizeof(cp->key));
memcpy(cp->plaintext, plaintext, sizeof(cp->plaintext));
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_ENCRYPT, buf, &rsp);
if (err) {
return err;
}
rp = (void *)rsp->data;
memcpy(enc_data, rp->enc_data, sizeof(rp->enc_data));
net_buf_unref(rsp);
BT_DBG("enc_data %s", h(enc_data, 16));
return 0;
}
#endif
static int smp_ah(const uint8_t irk[16], const uint8_t r[3], uint8_t out[3]) static int smp_ah(const uint8_t irk[16], const uint8_t r[3], uint8_t out[3])
{ {