11a63eb31SJulian Elischer.\" Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com> 21a63eb31SJulian Elischer.\" All rights reserved. 31a63eb31SJulian Elischer.\" 41a63eb31SJulian Elischer.\" Redistribution and use in source and binary forms, with or without 51a63eb31SJulian Elischer.\" modification, are permitted provided that the following conditions 61a63eb31SJulian Elischer.\" are met: 71a63eb31SJulian Elischer.\" 1. Redistributions of source code must retain the above copyright 81a63eb31SJulian Elischer.\" notice, this list of conditions and the following disclaimer. 91a63eb31SJulian Elischer.\" 2. Redistributions in binary form must reproduce the above copyright 101a63eb31SJulian Elischer.\" notice, this list of conditions and the following disclaimer in the 111a63eb31SJulian Elischer.\" documentation and/or other materials provided with the distribution. 121a63eb31SJulian Elischer.\" 131a63eb31SJulian Elischer.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 141a63eb31SJulian Elischer.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 151a63eb31SJulian Elischer.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 161a63eb31SJulian Elischer.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 171a63eb31SJulian Elischer.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 181a63eb31SJulian Elischer.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 191a63eb31SJulian Elischer.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 201a63eb31SJulian Elischer.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 211a63eb31SJulian Elischer.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 221a63eb31SJulian Elischer.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 231a63eb31SJulian Elischer.\" SUCH DAMAGE. 241a63eb31SJulian Elischer.\" 250986ab12SMaksim Yevmenkin.\" $Id: hcsecd.8,v 1.8 2003/09/08 18:54:20 max Exp $ 261a63eb31SJulian Elischer.\" $FreeBSD$ 2772f00208SRuslan Ermilov.\" 281a63eb31SJulian Elischer.Dd November 16, 2002 291a63eb31SJulian Elischer.Dt HCSECD 8 301a63eb31SJulian Elischer.Os 311a63eb31SJulian Elischer.Sh NAME 321a63eb31SJulian Elischer.Nm hcsecd 331a63eb31SJulian Elischer.Nd control link keys and PIN codes for Bluetooth devices 341a63eb31SJulian Elischer.Sh SYNOPSIS 351a63eb31SJulian Elischer.Nm 3672f00208SRuslan Ermilov.Op Fl dh 3772f00208SRuslan Ermilov.Fl f Ar configfile 381a63eb31SJulian Elischer.Sh DESCRIPTION 391a63eb31SJulian ElischerThe 401a63eb31SJulian Elischer.Nm 410986ab12SMaksim Yevmenkindaemon controls link keys and PIN codes for Bluetooth devices. 42cda869c9SMarkus BruefferIt opens a raw HCI socket and listens for 430986ab12SMaksim Yevmenkin.Dv Link_Key_Request , 441a63eb31SJulian Elischer.Dv PIN_Code_Request 450986ab12SMaksim Yevmenkinand 460986ab12SMaksim Yevmenkin.Dv Link_Key_Notification 4772f00208SRuslan ErmilovHCI events. 480986ab12SMaksim Yevmenkin.Pp 49cda869c9SMarkus BruefferOnce a 500986ab12SMaksim Yevmenkin.Dv Link_Key_Request 510986ab12SMaksim Yevmenkinor 520986ab12SMaksim Yevmenkin.Dv PIN_Code_Request 53cda869c9SMarkus BruefferHCI event is received, the daemon scans the configuration file for a 54cda869c9SMarkus Brueffermatching entry. 550986ab12SMaksim YevmenkinThe remote device BD_ADDR is used as a key. 5672f00208SRuslan ErmilovIf no matching entry was found, the default entry will be used. 570986ab12SMaksim YevmenkinIf no default entry was found then it is assumed that no link key and no 580986ab12SMaksim YevmenkinPIN code exists. 59cda869c9SMarkus BruefferFor any given entry, the link key takes precedence over the PIN code. 60cda869c9SMarkus BruefferIf a link key was not specified, the device must generate the link key from 61cda869c9SMarkus Bruefferthe PIN code. 62cda869c9SMarkus BruefferIf an entry was found and the link key (or PIN code) exists, the 631a63eb31SJulian Elischer.Dv Link_Key_Request_Reply 641a63eb31SJulian Elischer(or 6572f00208SRuslan Ermilov.Dv PIN_Code_Request_Reply ) 6672f00208SRuslan Ermilovcommand will be sent back to the device. 6772f00208SRuslan ErmilovOtherwise, the 681a63eb31SJulian Elischer.Dv Link_Key_Request_Negative_Reply 691a63eb31SJulian Elischer(or 7072f00208SRuslan Ermilov.Dv PIN_Code_Request_Negative_Reply ) 7172f00208SRuslan Ermilovcommand will be sent back to the device. 721a63eb31SJulian Elischer.Pp 731a63eb31SJulian ElischerThe 741a63eb31SJulian Elischer.Nm 750986ab12SMaksim Yevmenkindaemon also handles HCI 761a63eb31SJulian Elischer.Dv Link_Key_Notification 77cda869c9SMarkus Bruefferevents and caches link keys created from the PIN codes in memory. 780986ab12SMaksim YevmenkinTo preserve link keys between restarts the 790986ab12SMaksim Yevmenkin.Nm 800986ab12SMaksim Yevmenkindaemon dumps link keys for all entries in the 810986ab12SMaksim Yevmenkin.Pa /var/db/hcsecd.keys 820986ab12SMaksim Yevmenkinlink keys file. 83cda869c9SMarkus BruefferIf it exists, the link keys file gets processed by the 840986ab12SMaksim Yevmenkin.Nm 850986ab12SMaksim Yevmenkindaemon after it processes its main configuration file. 86cda869c9SMarkus BruefferThe link keys file gets written every time the 870986ab12SMaksim Yevmenkin.Nm 88cda869c9SMarkus Bruefferdaemon shuts down gracefully. 89cda869c9SMarkus BruefferIt is possible to force the 900986ab12SMaksim Yevmenkin.Nm 91cda869c9SMarkus Bruefferdaemon to re-read its main configuration file and dump the link keys file by 92cda869c9SMarkus Brueffersending the 930986ab12SMaksim Yevmenkin.Dv HUP 940986ab12SMaksim Yevmenkinsignal to the 950986ab12SMaksim Yevmenkin.Nm 960986ab12SMaksim Yevmenkinprocess. 97cda869c9SMarkus BruefferThe user is expected to not modify the link keys file by hand. 981a63eb31SJulian Elischer.Pp 991a63eb31SJulian ElischerThe command line options are as follows: 10072f00208SRuslan Ermilov.Bl -tag -width indent 1011a63eb31SJulian Elischer.It Fl d 1021a63eb31SJulian ElischerDo not detach from the controlling terminal. 10372f00208SRuslan Ermilov.It Fl f Ar configfile 104cda869c9SMarkus BruefferSpecify the name of the configuration file. 10572f00208SRuslan ErmilovThe default is 1060986ab12SMaksim Yevmenkin.Pa /etc/bluetooth/hcsecd.conf . 1071a63eb31SJulian Elischer.It Fl h 1081a63eb31SJulian ElischerDisplay usage message and exit. 1091a63eb31SJulian Elischer.El 1101a63eb31SJulian Elischer.Sh FILES 1110986ab12SMaksim Yevmenkin.Bl -tag -width ".Pa /etc/bluetooth/hcsecd.conf" -compact 1120986ab12SMaksim Yevmenkin.It Pa /etc/bluetooth/hcsecd.conf 1134b1493e5SMaksim Yevmenkin.It Pa /var/db/hcsecd.keys 1144b1493e5SMaksim Yevmenkin.It Pa /var/run/hcsecd.pid 1151a63eb31SJulian Elischer.El 1161a63eb31SJulian Elischer.Sh SEE ALSO 1171a63eb31SJulian Elischer.Xr ng_btsocket 4 , 11872f00208SRuslan Ermilov.Xr ng_hci 4 , 1190986ab12SMaksim Yevmenkin.Xr hcsecd.conf 5 , 120*66d62998SWarner Losh.Xr hccontrol 8 1211a63eb31SJulian Elischer.Sh AUTHORS 12201c2b8acSBaptiste Daroussin.An Maksim Yevmenkin Aq Mt m_evmenkin@yahoo.com 12359a3c79dSRuslan Ermilov.Sh BUGS 124cda869c9SMarkus BruefferCurrently there is no way to select the link key or the PIN code based on 125cda869c9SMarkus Bruefferwhich local device received the request. 126cda869c9SMarkus BruefferEverything is based on the remote device BD_ADDR. 127cda869c9SMarkus BruefferAn interface for external helpers to obtain link keys and PIN codes is missing. 128