selftest.c (e5451c8f8330e03ad3cfa16048b4daf961af434f) selftest.c (58771c1cb0023fdd744e76d6cad7716dc4f579ee)
1/*
2 BlueZ - Bluetooth protocol stack for Linux
3
4 Copyright (C) 2014 Intel Corporation
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License version 2 as
8 published by the Free Software Foundation;

--- 12 unchanged lines hidden (view full) ---

21 SOFTWARE IS DISCLAIMED.
22*/
23
24#include <linux/debugfs.h>
25
26#include <net/bluetooth/bluetooth.h>
27#include <net/bluetooth/hci_core.h>
28
1/*
2 BlueZ - Bluetooth protocol stack for Linux
3
4 Copyright (C) 2014 Intel Corporation
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License version 2 as
8 published by the Free Software Foundation;

--- 12 unchanged lines hidden (view full) ---

21 SOFTWARE IS DISCLAIMED.
22*/
23
24#include <linux/debugfs.h>
25
26#include <net/bluetooth/bluetooth.h>
27#include <net/bluetooth/hci_core.h>
28
29#include "ecc.h"
29#include "ecdh_helper.h"
30#include "smp.h"
31#include "selftest.h"
32
33#if IS_ENABLED(CONFIG_BT_SELFTEST_ECDH)
34
35static const u8 priv_a_1[32] __initconst = {
36 0xbd, 0x1a, 0x3c, 0xcd, 0xa6, 0xb8, 0x99, 0x58,
37 0x99, 0xb7, 0x40, 0xeb, 0x7b, 0x60, 0xff, 0x4a,

--- 101 unchanged lines hidden (view full) ---

139};
140
141static int __init test_ecdh_sample(const u8 priv_a[32], const u8 priv_b[32],
142 const u8 pub_a[64], const u8 pub_b[64],
143 const u8 dhkey[32])
144{
145 u8 dhkey_a[32], dhkey_b[32];
146
30#include "smp.h"
31#include "selftest.h"
32
33#if IS_ENABLED(CONFIG_BT_SELFTEST_ECDH)
34
35static const u8 priv_a_1[32] __initconst = {
36 0xbd, 0x1a, 0x3c, 0xcd, 0xa6, 0xb8, 0x99, 0x58,
37 0x99, 0xb7, 0x40, 0xeb, 0x7b, 0x60, 0xff, 0x4a,

--- 101 unchanged lines hidden (view full) ---

139};
140
141static int __init test_ecdh_sample(const u8 priv_a[32], const u8 priv_b[32],
142 const u8 pub_a[64], const u8 pub_b[64],
143 const u8 dhkey[32])
144{
145 u8 dhkey_a[32], dhkey_b[32];
146
147 ecdh_shared_secret(pub_b, priv_a, dhkey_a);
148 ecdh_shared_secret(pub_a, priv_b, dhkey_b);
147 compute_ecdh_secret(pub_b, priv_a, dhkey_a);
148 compute_ecdh_secret(pub_a, priv_b, dhkey_b);
149
150 if (memcmp(dhkey_a, dhkey, 32))
151 return -EINVAL;
152
153 if (memcmp(dhkey_b, dhkey, 32))
154 return -EINVAL;
155
156 return 0;

--- 115 unchanged lines hidden ---
149
150 if (memcmp(dhkey_a, dhkey, 32))
151 return -EINVAL;
152
153 if (memcmp(dhkey_b, dhkey, 32))
154 return -EINVAL;
155
156 return 0;

--- 115 unchanged lines hidden ---