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 $ 2672f00208SRuslan Ermilov.\" 271a63eb31SJulian Elischer.Dd November 16, 2002 281a63eb31SJulian Elischer.Dt HCSECD 8 291a63eb31SJulian Elischer.Os 301a63eb31SJulian Elischer.Sh NAME 311a63eb31SJulian Elischer.Nm hcsecd 321a63eb31SJulian Elischer.Nd control link keys and PIN codes for Bluetooth devices 331a63eb31SJulian Elischer.Sh SYNOPSIS 341a63eb31SJulian Elischer.Nm 3572f00208SRuslan Ermilov.Op Fl dh 3672f00208SRuslan Ermilov.Fl f Ar configfile 371a63eb31SJulian Elischer.Sh DESCRIPTION 381a63eb31SJulian ElischerThe 391a63eb31SJulian Elischer.Nm 400986ab12SMaksim Yevmenkindaemon controls link keys and PIN codes for Bluetooth devices. 41cda869c9SMarkus BruefferIt opens a raw HCI socket and listens for 420986ab12SMaksim Yevmenkin.Dv Link_Key_Request , 431a63eb31SJulian Elischer.Dv PIN_Code_Request 440986ab12SMaksim Yevmenkinand 450986ab12SMaksim Yevmenkin.Dv Link_Key_Notification 4672f00208SRuslan ErmilovHCI events. 470986ab12SMaksim Yevmenkin.Pp 48cda869c9SMarkus BruefferOnce a 490986ab12SMaksim Yevmenkin.Dv Link_Key_Request 500986ab12SMaksim Yevmenkinor 510986ab12SMaksim Yevmenkin.Dv PIN_Code_Request 52cda869c9SMarkus BruefferHCI event is received, the daemon scans the configuration file for a 53cda869c9SMarkus Brueffermatching entry. 540986ab12SMaksim YevmenkinThe remote device BD_ADDR is used as a key. 5572f00208SRuslan ErmilovIf no matching entry was found, the default entry will be used. 560986ab12SMaksim YevmenkinIf no default entry was found then it is assumed that no link key and no 570986ab12SMaksim YevmenkinPIN code exists. 58cda869c9SMarkus BruefferFor any given entry, the link key takes precedence over the PIN code. 59cda869c9SMarkus BruefferIf a link key was not specified, the device must generate the link key from 60cda869c9SMarkus Bruefferthe PIN code. 61cda869c9SMarkus BruefferIf an entry was found and the link key (or PIN code) exists, the 621a63eb31SJulian Elischer.Dv Link_Key_Request_Reply 631a63eb31SJulian Elischer(or 6472f00208SRuslan Ermilov.Dv PIN_Code_Request_Reply ) 6572f00208SRuslan Ermilovcommand will be sent back to the device. 6672f00208SRuslan ErmilovOtherwise, the 671a63eb31SJulian Elischer.Dv Link_Key_Request_Negative_Reply 681a63eb31SJulian Elischer(or 6972f00208SRuslan Ermilov.Dv PIN_Code_Request_Negative_Reply ) 7072f00208SRuslan Ermilovcommand will be sent back to the device. 711a63eb31SJulian Elischer.Pp 721a63eb31SJulian ElischerThe 731a63eb31SJulian Elischer.Nm 740986ab12SMaksim Yevmenkindaemon also handles HCI 751a63eb31SJulian Elischer.Dv Link_Key_Notification 76cda869c9SMarkus Bruefferevents and caches link keys created from the PIN codes in memory. 770986ab12SMaksim YevmenkinTo preserve link keys between restarts the 780986ab12SMaksim Yevmenkin.Nm 790986ab12SMaksim Yevmenkindaemon dumps link keys for all entries in the 800986ab12SMaksim Yevmenkin.Pa /var/db/hcsecd.keys 810986ab12SMaksim Yevmenkinlink keys file. 82cda869c9SMarkus BruefferIf it exists, the link keys file gets processed by the 830986ab12SMaksim Yevmenkin.Nm 840986ab12SMaksim Yevmenkindaemon after it processes its main configuration file. 85cda869c9SMarkus BruefferThe link keys file gets written every time the 860986ab12SMaksim Yevmenkin.Nm 87cda869c9SMarkus Bruefferdaemon shuts down gracefully. 88cda869c9SMarkus BruefferIt is possible to force the 890986ab12SMaksim Yevmenkin.Nm 90cda869c9SMarkus Bruefferdaemon to re-read its main configuration file and dump the link keys file by 91cda869c9SMarkus Brueffersending the 920986ab12SMaksim Yevmenkin.Dv HUP 930986ab12SMaksim Yevmenkinsignal to the 940986ab12SMaksim Yevmenkin.Nm 950986ab12SMaksim Yevmenkinprocess. 96cda869c9SMarkus BruefferThe user is expected to not modify the link keys file by hand. 971a63eb31SJulian Elischer.Pp 981a63eb31SJulian ElischerThe command line options are as follows: 9972f00208SRuslan Ermilov.Bl -tag -width indent 1001a63eb31SJulian Elischer.It Fl d 1011a63eb31SJulian ElischerDo not detach from the controlling terminal. 10272f00208SRuslan Ermilov.It Fl f Ar configfile 103cda869c9SMarkus BruefferSpecify the name of the configuration file. 10472f00208SRuslan ErmilovThe default is 1050986ab12SMaksim Yevmenkin.Pa /etc/bluetooth/hcsecd.conf . 1061a63eb31SJulian Elischer.It Fl h 1071a63eb31SJulian ElischerDisplay usage message and exit. 1081a63eb31SJulian Elischer.El 1091a63eb31SJulian Elischer.Sh FILES 1100986ab12SMaksim Yevmenkin.Bl -tag -width ".Pa /etc/bluetooth/hcsecd.conf" -compact 1110986ab12SMaksim Yevmenkin.It Pa /etc/bluetooth/hcsecd.conf 1124b1493e5SMaksim Yevmenkin.It Pa /var/db/hcsecd.keys 1134b1493e5SMaksim Yevmenkin.It Pa /var/run/hcsecd.pid 1141a63eb31SJulian Elischer.El 1151a63eb31SJulian Elischer.Sh SEE ALSO 1161a63eb31SJulian Elischer.Xr ng_btsocket 4 , 11772f00208SRuslan Ermilov.Xr ng_hci 4 , 1180986ab12SMaksim Yevmenkin.Xr hcsecd.conf 5 , 119*66d62998SWarner Losh.Xr hccontrol 8 1201a63eb31SJulian Elischer.Sh AUTHORS 12101c2b8acSBaptiste Daroussin.An Maksim Yevmenkin Aq Mt m_evmenkin@yahoo.com 12259a3c79dSRuslan Ermilov.Sh BUGS 123cda869c9SMarkus BruefferCurrently there is no way to select the link key or the PIN code based on 124cda869c9SMarkus Bruefferwhich local device received the request. 125cda869c9SMarkus BruefferEverything is based on the remote device BD_ADDR. 126cda869c9SMarkus BruefferAn interface for external helpers to obtain link keys and PIN codes is missing. 127