Bluetooth: SMP: Add LE SC smp_f5 init test

This run smp_f5 function with test vectors from Core Specification 4.2.

Change-Id: I1ef0ddf54c058bd7a9b7cc635fd785267a1bafd8
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This commit is contained in:
Szymon Janc 2015-11-09 10:14:43 +01:00 committed by Anas Nashif
commit b1a1197d8c

View file

@ -2457,6 +2457,41 @@ static int smp_f4_test(void)
return 0;
}
static int smp_f5_test(void)
{
uint8_t w[32] = { 0x98, 0xa6, 0xbf, 0x73, 0xf3, 0x34, 0x8d, 0x86,
0xf1, 0x66, 0xf8, 0xb4, 0x13, 0x6b, 0x79, 0x99,
0x9b, 0x7d, 0x39, 0x0a, 0xa6, 0x10, 0x10, 0x34,
0x05, 0xad, 0xc8, 0x57, 0xa3, 0x34, 0x02, 0xec };
uint8_t n1[16] = { 0xab, 0xae, 0x2b, 0x71, 0xec, 0xb2, 0xff, 0xff,
0x3e, 0x73, 0x77, 0xd1, 0x54, 0x84, 0xcb, 0xd5 };
uint8_t n2[16] = { 0xcf, 0xc4, 0x3d, 0xff, 0xf7, 0x83, 0x65, 0x21,
0x6e, 0x5f, 0xa7, 0x25, 0xcc, 0xe7, 0xe8, 0xa6 };
bt_addr_le_t a1 = { .type = 0x00,
.val = { 0xce, 0xbf, 0x37, 0x37, 0x12, 0x56 } };
bt_addr_le_t a2 = { .type = 0x00,
.val = {0xc1, 0xcf, 0x2d, 0x70, 0x13, 0xa7 } };
uint8_t exp_ltk[16] = { 0x38, 0x0a, 0x75, 0x94, 0xb5, 0x22, 0x05,
0x98, 0x23, 0xcd, 0xd7, 0x69, 0x11, 0x79,
0x86, 0x69 };
uint8_t exp_mackey[16] = { 0x20, 0x6e, 0x63, 0xce, 0x20, 0x6a, 0x3f,
0xfd, 0x02, 0x4a, 0x08, 0xa1, 0x76, 0xf1,
0x65, 0x29 };
uint8_t mackey[16], ltk[16];
int err;
err = smp_f5(w, n1, n2, &a1, &a2, mackey, ltk);
if (err) {
return err;
}
if (memcmp(mackey, exp_mackey, 16) || memcmp(ltk, exp_ltk, 16)) {
return -EINVAL;
}
return 0;
}
static int smp_self_test(void)
{
int err;
@ -2479,6 +2514,12 @@ static int smp_self_test(void)
return err;
}
err = smp_f5_test();
if (err) {
BT_ERR("SMP f5 self test failed\n");
return err;
}
return 0;
}
#else