Loading net/bluetooth/Kconfig +7 −0 Original line number Diff line number Diff line Loading @@ -84,4 +84,11 @@ config BT_SELFTEST_ECDH Run test cases for ECDH cryptographic functionality used by the Bluetooth Low Energy Secure Connections feature. config BT_SELFTEST_SMP bool "SMP test cases" depends on BT_LE && BT_SELFTEST help Run test cases for SMP cryptographic functionality, including both legacy SMP as well as the Secure Connections features. source "drivers/bluetooth/Kconfig" net/bluetooth/selftest.c +7 −0 Original line number Diff line number Diff line Loading @@ -22,8 +22,10 @@ */ #include <net/bluetooth/bluetooth.h> #include <net/bluetooth/hci_core.h> #include "ecc.h" #include "smp.h" #include "selftest.h" #if IS_ENABLED(CONFIG_BT_SELFTEST_ECDH) Loading Loading @@ -195,7 +197,12 @@ static int __init run_selftest(void) BT_INFO("Starting self testing"); err = test_ecdh(); if (err) goto done; err = bt_selftest_smp(); done: BT_INFO("Finished self testing"); return err; Loading net/bluetooth/smp.c +39 −0 Original line number Diff line number Diff line Loading @@ -3022,3 +3022,42 @@ void smp_unregister(struct hci_dev *hdev) smp_del_chan(chan); } } #if IS_ENABLED(CONFIG_BT_SELFTEST_SMP) static int __init run_selftests(struct crypto_blkcipher *tfm_aes, struct crypto_hash *tfm_cmac) { BT_INFO("SMP test passed"); return 0; } int __init bt_selftest_smp(void) { struct crypto_blkcipher *tfm_aes; struct crypto_hash *tfm_cmac; int err; tfm_aes = crypto_alloc_blkcipher("ecb(aes)", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(tfm_aes)) { BT_ERR("Unable to create ECB crypto context"); return PTR_ERR(tfm_aes); } tfm_cmac = crypto_alloc_hash("cmac(aes)", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(tfm_cmac)) { BT_ERR("Unable to create CMAC crypto context"); crypto_free_blkcipher(tfm_aes); return PTR_ERR(tfm_cmac); } err = run_selftests(tfm_aes, tfm_cmac); crypto_free_hash(tfm_cmac); crypto_free_blkcipher(tfm_aes); return err; } #endif net/bluetooth/smp.h +13 −0 Original line number Diff line number Diff line Loading @@ -192,4 +192,17 @@ int smp_generate_rpa(struct hci_dev *hdev, const u8 irk[16], bdaddr_t *rpa); int smp_register(struct hci_dev *hdev); void smp_unregister(struct hci_dev *hdev); #if IS_ENABLED(CONFIG_BT_SELFTEST_SMP) int bt_selftest_smp(void); #else static inline int bt_selftest_smp(void) { return 0; } #endif #endif /* __SMP_H */ Loading
net/bluetooth/Kconfig +7 −0 Original line number Diff line number Diff line Loading @@ -84,4 +84,11 @@ config BT_SELFTEST_ECDH Run test cases for ECDH cryptographic functionality used by the Bluetooth Low Energy Secure Connections feature. config BT_SELFTEST_SMP bool "SMP test cases" depends on BT_LE && BT_SELFTEST help Run test cases for SMP cryptographic functionality, including both legacy SMP as well as the Secure Connections features. source "drivers/bluetooth/Kconfig"
net/bluetooth/selftest.c +7 −0 Original line number Diff line number Diff line Loading @@ -22,8 +22,10 @@ */ #include <net/bluetooth/bluetooth.h> #include <net/bluetooth/hci_core.h> #include "ecc.h" #include "smp.h" #include "selftest.h" #if IS_ENABLED(CONFIG_BT_SELFTEST_ECDH) Loading Loading @@ -195,7 +197,12 @@ static int __init run_selftest(void) BT_INFO("Starting self testing"); err = test_ecdh(); if (err) goto done; err = bt_selftest_smp(); done: BT_INFO("Finished self testing"); return err; Loading
net/bluetooth/smp.c +39 −0 Original line number Diff line number Diff line Loading @@ -3022,3 +3022,42 @@ void smp_unregister(struct hci_dev *hdev) smp_del_chan(chan); } } #if IS_ENABLED(CONFIG_BT_SELFTEST_SMP) static int __init run_selftests(struct crypto_blkcipher *tfm_aes, struct crypto_hash *tfm_cmac) { BT_INFO("SMP test passed"); return 0; } int __init bt_selftest_smp(void) { struct crypto_blkcipher *tfm_aes; struct crypto_hash *tfm_cmac; int err; tfm_aes = crypto_alloc_blkcipher("ecb(aes)", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(tfm_aes)) { BT_ERR("Unable to create ECB crypto context"); return PTR_ERR(tfm_aes); } tfm_cmac = crypto_alloc_hash("cmac(aes)", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(tfm_cmac)) { BT_ERR("Unable to create CMAC crypto context"); crypto_free_blkcipher(tfm_aes); return PTR_ERR(tfm_cmac); } err = run_selftests(tfm_aes, tfm_cmac); crypto_free_hash(tfm_cmac); crypto_free_blkcipher(tfm_aes); return err; } #endif
net/bluetooth/smp.h +13 −0 Original line number Diff line number Diff line Loading @@ -192,4 +192,17 @@ int smp_generate_rpa(struct hci_dev *hdev, const u8 irk[16], bdaddr_t *rpa); int smp_register(struct hci_dev *hdev); void smp_unregister(struct hci_dev *hdev); #if IS_ENABLED(CONFIG_BT_SELFTEST_SMP) int bt_selftest_smp(void); #else static inline int bt_selftest_smp(void) { return 0; } #endif #endif /* __SMP_H */