linux/net/bluetooth/selftest.c

/*
   BlueZ - Bluetooth protocol stack for Linux

   Copyright (C) 2014 Intel Corporation

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License version 2 as
   published by the Free Software Foundation;

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
   IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
   SOFTWARE IS DISCLAIMED.
*/

#include <linux/debugfs.h>

#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>

#include "ecdh_helper.h"
#include "smp.h"
#include "selftest.h"

#if IS_ENABLED(CONFIG_BT_SELFTEST_ECDH)

static const u8 priv_a_1[32] __initconst =;
static const u8 priv_b_1[32] __initconst =;
static const u8 pub_a_1[64] __initconst =;
static const u8 pub_b_1[64] __initconst =;
static const u8 dhkey_1[32] __initconst =;

static const u8 priv_a_2[32] __initconst =;
static const u8 priv_b_2[32] __initconst =;
static const u8 pub_a_2[64] __initconst =;
static const u8 pub_b_2[64] __initconst =;
static const u8 dhkey_2[32] __initconst =;

static const u8 priv_a_3[32] __initconst =;
static const u8 pub_a_3[64] __initconst =;
static const u8 dhkey_3[32] __initconst =;

static int __init test_ecdh_sample(struct crypto_kpp *tfm, const u8 priv_a[32],
				   const u8 priv_b[32], const u8 pub_a[64],
				   const u8 pub_b[64], const u8 dhkey[32])
{}

static char test_ecdh_buffer[32];

static ssize_t test_ecdh_read(struct file *file, char __user *user_buf,
			      size_t count, loff_t *ppos)
{}

static const struct file_operations test_ecdh_fops =;

static int __init test_ecdh(void)
{}

#else

static inline int test_ecdh(void)
{
	return 0;
}

#endif

static int __init run_selftest(void)
{}

#if IS_MODULE(CONFIG_BT)

/* This is run when CONFIG_BT_SELFTEST=y and CONFIG_BT=m and is just a
 * wrapper to allow running this at module init.
 *
 * If CONFIG_BT_SELFTEST=n, then this code is not compiled at all.
 */
int __init bt_selftest(void)
{
	return run_selftest();
}

#else

/* This is run when CONFIG_BT_SELFTEST=y and CONFIG_BT=y and is run
 * via late_initcall() as last item in the initialization sequence.
 *
 * If CONFIG_BT_SELFTEST=n, then this code is not compiled at all.
 */
static int __init bt_selftest_init(void)
{}
late_initcall(bt_selftest_init);

#endif