63
Bluetooth ® and Microsoft Desktop Products Microsoft Corporation Published: June 2005 Abstract This paper provides an overview of Bluetooth technology with a specific focus on security and one class of Bluetooth Human Interface Devices: keyboards and mouse products. Bluetooth computing has created a major advance in personal computer interaction and, as with any new technology, understanding it is the key to envisioning how it can make a contribution in the workplace. M

Microsoft Hardware Bluetooth White Paper

  • Upload
    hughj

  • View
    51

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Microsoft Hardware Bluetooth White Paper

Bluetooth® and Microsoft Desktop Products

Microsoft Corporation

Published: June 2005

Abstract

This paper provides an overview of Bluetooth technology with a specific focus on security and one class of Bluetooth

Human Interface Devices: keyboards and mouse products. Bluetooth computing has created a major advance in personal

computer interaction and, as with any new technology, understanding it is the key to envisioning how it can make a

contribution in the workplace.

M

Page 2: Microsoft Hardware Bluetooth White Paper

The information contained in this document represents the current view of Microsoft Corporation on the issues discussed as of the date of publication. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication.

This White Paper is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS DOCUMENT.

Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation.

Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property.

© 2005 Microsoft Corporation. All rights reserved.

Microsoft is either a registered trademark or trademark of Microsoft Corporation in the United States and/or other countries.

The names of actual companies and products mentioned herein may be the trademarks of their respective owners.

M

Page 3: Microsoft Hardware Bluetooth White Paper

Bluetooth® and Microsoft® Desktop Products 1

Contents

Contents .......................................................................................................................................................1

Introduction..................................................................................................................................................2

What is Bluetooth®?....................................................................................................................................3

Bluetooth Compared to 27 MHz Technology.............................................................................................3

Bluetooth Devices......................................................................................................................................4

Range ........................................................................................................................................................4

Master/Slave Relationship .........................................................................................................................4

Virtual Cable ..............................................................................................................................................4

Encryption ..................................................................................................................................................5

Frequency Hopping Technology................................................................................................................6

Pairing ..........................................................................................................................................................7

Discovery ...................................................................................................................................................7

Keys ...........................................................................................................................................................7

Authentication ............................................................................................................................................8

Understanding Pairing – An Example .......................................................................................................9

Bluetooth Settings......................................................................................................................................9

Adding a Device.......................................................................................................................................10

Passkey Challenge ..................................................................................................................................10

Summary ....................................................................................................................................................12

Appendix 1: Bluetooth® Security on Microsoft® Desktop Products.....................................................13

Pairing Process for Microsoft Bluetooth Keyboards ................................................................................13

Length and entropy of the PIN .............................................................................................................13

Length and entropy of the Random Number........................................................................................14

Length and entropy of the Bluetooth® address ....................................................................................14

Algorithms used to derive the Security Keys ...........................................................................................14

Conclusion ...............................................................................................................................................15

Appendix 2: Bluetooth® Specification v1.2 Controller Volume, Part H SECURITY SPECIFICATION16

Related Links .............................................................................................................................................17

Page 4: Microsoft Hardware Bluetooth White Paper

Bluetooth® and Microsoft® Desktop Products 2

Introduction

Connections between people are changing as an ever-increasing number of wireless products enable them to enjoy mobility and simplicity without cabling. Introduced in 1999 and evolving, Bluetooth® is a low power, short range radio technology that revolutionizes communications for a wide array of products from mobile phones to computer peripherals. An open specification, Bluetooth offers convenience, enhanced immunity from interference, and security* which have made it the choice of a large and growing number of companies.

This paper provides an overview of Bluetooth technology with a specific focus on communications security and reliability for one class of Bluetooth Human Interface Devices: keyboards and mouse products. Bluetooth computing has created a major advance in personal computer interaction and, as with any new technology, understanding it is the key to envisioning how it can make a contribution in the workplace.

There are two technical appendices to this paper:

• Appendix 1: Bluetooth Security on Microsoft® Desktop Products

For readers who wish some additional technical detail, this appendix provides a brief summary of the implementation for Microsoft Bluetooth keyboards.

• Appendix 2: Bluetooth Specification v1.2 Controller Volume, Part H SECURITY SPECIFICATION

For readers interested in gaining a more thorough understanding of Bluetooth security, the relevant section of the Bluetooth specification is contained herein.

* The Microsoft products referenced within use Bluetooth wireless technology so that users have a more secure computing

experience. The degree of security achieved with any technology depends upon the specific circumstances under which it is

deployed.

Page 5: Microsoft Hardware Bluetooth White Paper

Bluetooth® and Microsoft® Desktop Products 3

What is Bluetooth®?

Bluetooth is an open technology specification owned by the Bluetooth Special Interest Group (SIG), a trade association comprised of members from the telecommunications, computing, and various other technology industries. Ensuring compatibility in a wide variety of products from many manufacturers, Bluetooth technology is increasingly seen as a smart choice for local, private device networking.

Bluetooth is a low power, short range, 2.4 GHz radio technology that eliminates cables between electronic devices such as phones, computers, keyboards, mouse products, printers, and other equipment. Bi-directional radio transmission between these devices delivers physical freedom and ease of use through automatic wireless connection. Up to 7 devices may be connected in a piconet, the fundamental Bluetooth network. The maximum data rate is 1 Mbps, with typical performance in the range of several hundred to 700 kbps.

The primary security of Bluetooth communications is provided by encryption. Bluetooth devices can be designed to implement a very secure, industry standard encryption scheme, known as SAFER+, that has not been compromised (see sidebar). Because Bluetooth is low power it operates over short distances, contributing to reduced radio frequency interference. Interference immunity is further enhanced because Bluetooth employs frequency-hopping spread spectrum technology.

Bluetooth Compared to 27 MHz Technology Devices that communicate at the frequency of 27 MHz do not enjoy the same range, flexibility, and security benefits of Bluetooth. 27 MHz devices tend to be limited by dedicated, proprietary designs, while Bluetooth is an open standard that enables device networking. The same wireless transceiver supplied with a Bluetooth keyboard and mouse enables printing to a Bluetooth printer, transferring files to a PDA, and synchronizing phone contacts with the PC, for example.

Bluetooth has a longer range and yet is less susceptible to interference, enabling co-location of more devices in a smaller area than is possible with 27 MHz devices. The range of Bluetooth devices such as keyboards is generally 10 meters or about 30 feet. 27 MHz devices are much more susceptible to interference and have to contend with signal loss if interference is encountered. Frequency hopping makes Bluetooth devices more immune to interference. Devices that encounter interference on a channel will switch channels and retransmit a packet. This is possible because Bluetooth transmission is bi-directional, and devices are able to communicate whether a packet is not received.

“Recently there has been confusion surrounding security and Bluetooth wireless technology. These have typically involved mobile phones. How these issues apply to other classes of devices has not been discussed. I’d like to do that here. To the best of my knowledge, the encryption algorithm in the Bluetooth specifications has not been compromised [emphasis added]. As such, once paired, the communication between Bluetooth devices is secure. This includes devices such as keyboards connecting to a PC, a mobile phone synchronizing with a PC, and a PDA using a mobile phone as a modem to name just a few of the many other use cases.

“Cases where data has been compromised on mobile phones are the result of implementation issues on that platform. The Bluetooth SIG diligently works with our members to investigate any issues that are reported to understand the root cause of the issue. If it is a specification issue, we work with the membership to address that issue in the specification. If it is an implementation issue, we work with the membership to get patches out and ensure future devices don’t suffer from the same vulnerability. This is an on-going process.”

Mike Foley, Bluetooth SIG March 11, 2005

Page 6: Microsoft Hardware Bluetooth White Paper

Bluetooth® and Microsoft® Desktop Products 4

Industry standard encryption is the basis for Bluetooth® security, which is not the case for 27 MHz technology. 27 MHz devices generally do not use encryption or, if they do, it is a proprietary implementation.

Bluetooth Devices The Bluetooth specification accommodates different devices that are organized into device profiles based on the capabilities of the device. For example, Bluetooth devices range in functionality from headsets to printers and modems. Each class of device has a suitable set of commands, but it is not practical or desirable for all devices to understand all possible commands. For example, a printer without FAX functionality will never need to make a phone call, so the modem commands are not necessary for the printer. For this reason the Bluetooth specification classifies devices based on their functionality. These classes are called profiles.

Keyboards and mouse products fall into the general Human Interface Device (HID) profile. Because HID devices have fewer and simpler capabilities, such devices tend to represent a lower security risk. They have fewer potential avenues for compromise than devices such as mobile phones, which support a large variety of device profiles.

Range Bluetooth devices are grouped into three power classes or levels with typical operating range distances of 10 m, 20 m, and 100 m (approximately 30, 60, and 300 feet, respectively). Most keyboards and mouse products operate at the 10 or 20 meter ranges. The actual effective range for any device may be less, as radio signals can be affected by the physical environment. Since keyboards are generally used within a building, which attenuates radio signals, the actual range could be less than 10 m. A consideration for using Bluetooth in offices is that the range may extend through a floor or ceiling.

Many Bluetooth radios, including the radios used in Microsoft® products, have an active transmit power control feature. If the keyboard is moved closer to the transceiver, the two radios will reduce transmission power accordingly so that they are not transmitting any “louder” than necessary. This further reduces the effective range, but helps to minimize potential interference with other networks.

Master/Slave Relationship A Bluetooth piconet employs a master/slave topology where there is a single master and multiple slave devices. The master device controls communication timing and frequency hopping, as well as determines encryption keys used within the network. While certain classes of devices in one piconet may also be connected to other Bluetooth piconets, this is never the case for keyboards and mouse products. The HID profile requires a single master.

In this paper the term PC will refer to the master while the keyboard is a slave. PC is used throughout and is interchangeable with host or master.

Virtual Cable The keyboard and mouse are so tightly coupled with the PC, the master device to which they are paired, that this pairing is described as being a virtual cable. That is, they have a 1:1 relationship that permits no other devices to join that pairing. Once a device has been virtually cabled, it acts

Page 7: Microsoft Hardware Bluetooth White Paper

Bluetooth® and Microsoft® Desktop Products 5

as if a physical cable exists between it and its PC. A paired keyboard will refuse to connect to any other device, therefore making it very difficult to attack through a Bluetooth® connection. The latter problem has been encountered with some phone implementations of the Bluetooth standard.

This virtual cable remains intact even if power is removed and reapplied to the device, and can only be broken if either the PC or keyboard unplugs itself via a specific Bluetooth command. Should the connection between the paired devices be broken for any other reason (for example, moving out of range), the virtual cable will not be broken. The devices will automatically attempt to reconnect when the cause for the break is removed (moving back into range).

Encryption Encryption is at the core of Bluetooth security, employing a strong algorithm with high speed encryption, long encryption keys (or passwords), and encryption keys that change for each working session. Communications are secured by up to 128-bit encryption using an enhanced version of a strong,

publicly available encryption algorithm known as SAFER+.

Encryption is a Bluetooth recommendation for HID devices such as keyboards, which are often used to enter sensitive information. For example, all Microsoft® Bluetooth keyboards use 128-bit Bluetooth encryption, although Windows® permits unencrypted connections to Bluetooth keyboards. Simple devices, such as a mouse or pointer, may use encryption, but they are not required to do so and generally do not. A Microsoft Bluetooth mouse is not encrypted.

The foundation for encryption is built by the pairing process (described later) which begins with a user-entered PIN (password) and ultimately results in the creation of a semi-permanent Link Key. The Link Key is also knows as the Combination Key or KAB in the Bluetooth Specification. That Link Key is, in turn, used to create the Encryption Keys for communication. No keys are ever transmitted over the radio; only random numbers are exchanged when devices are establishing keys.

While the Link Key must be 128 bits, the Bluetooth specification allows the Encryption Key to be as short as 8 bits. Microsoft Bluetooth keyboards always use 128-bit encryption. The keys are generated through a combination of three inputs: an input key, a 128-bit random number received from the other device, and a third number. The third number is either a 48-bit device address or another generated number. Such a combination key is more secure than a static random number, plus it enables the PC and each slave device pair to have its own unique key. Additional information on encryption can be found in the appendix Bluetooth Security on Microsoft Desktop Products.

The Virtual Cable protects against connection intrusion attacks (which has been a problem for some phone implementations). “The term virtual cable is used to indicate that the HID* has a 1:1 association with a particular host [PC].” (*From section 6.4 of the Bluetooth Human Interface Device Profile 1.0 specification.)

The Microsoft Bluetooth keyboard supports only one connection at a time. For example, a device cannot connect to a keyboard by forming a second connection in order to listen to or manipulate the devices. If a keyboard device is virtually cabled to a PC it means:

• The device has identified itself as virtually cabled.

• There is a 1:1 relationship with that PC.

• The HID device will refuse any attempts by other devices to connect to it.

• The device will automatically reconnect to its bonded PC if the connection is dropped.

• Breaking the virtual cable requires user intervention, e.g., pressing the Make/Break Connection button on the bottom of the Microsoft Bluetooth keyboard, or clicking the Remove button from the Bluetooth Devices dialog in Windows Control Panel.

Pages 35-38, section 6.4, of the Bluetooth Human Interface Device Profile 1.0 specification contain more details about virtual cables.

Page 8: Microsoft Hardware Bluetooth White Paper

Bluetooth® and Microsoft® Desktop Products 6

Frequency Hopping Technology High speed frequency hopping technology significantly reduces radio interference. The general frequency hopping technique is employed in a broad range of products and applications because of this inherent benefit.

Bluetooth® devices operate at a frequency of 2.4 GHz, an open, license-free band that is shared around the world by a wide range of applications and devices. One application is wireless Ethernet based on the IEEE 802.11 standards. This sharing of the frequency band is a key reason why Bluetooth communications need to be robust and resistant to interference.

Frequency-hopping spread spectrum technology greatly reduces the likelihood of interference from other Bluetooth devices operating on another network in the same area. The actual pattern of channel switching is determined by the PC, and it is different for all Bluetooth PCs that may be operating within range of each other. Should interference be encountered on a single channel, packet retransmission will follow immediately on a different channel, one that is likely to be free.

The frequency band is divided into 79 frequency channels, and time is divided into slots that are 625 �s long. Data packets are 1 to 5 slots in length. Two Bluetooth devices will synchronously switch to a new channel in a random manner after each packet is received. Thus channel switching is very fast, up to 1,600 times every second.

Figure 1 provides a graphical depiction of this channel switching. The 79 channels are shown with a total of 16 horizontal elapsed time slots, which represent a total time of just 0.01 second. The channel that was selected for transmission for each time slot is shown and graphed.

New devices compatible with Bluetooth version 1.2 may use a technology called Adaptive Frequency Hopping, in which the device marks frequencies that are known to have interference, and avoids these frequencies for a period of time. For example, there may be a situation where an interfering device is transmitting on a single block of frequencies. The probability of transmission error is reduced by adjusting the hopping pattern

accordingly. Microsoft®’s Optical Desktop Elite for Bluetooth, a combination keyboard, mouse, and USB transceiver, is a product that meets the 1.2 specification.

Communications can be monitored once the sequence is known, so Bluetooth’s security defense is based principally on encryption. Frequency hopping makes it more difficult for communication to be intercepted and monitored, but it does not prevent it.

Figure 1 – Frequency Hopping

Page 9: Microsoft Hardware Bluetooth White Paper

Bluetooth® and Microsoft® Desktop Products 7

Pairing

Secure, encrypted communication between two devices requires that they share a common starting point, or password/PIN, for encryption and decryption. Nearly everyone recognizes that a password can be weak (simple to break) or strong (difficult to break). Longer passwords are more difficult to break than shorter passwords. Security is also enhanced if passwords are changed frequently, and if there is more than just a single password. And, of course, passwords should never be shared (communicated) openly. These same security characteristics are found in Bluetooth® encryption:

• Use of an initial password

• Strong, 128-bit password length

• Dual passwords for operation (a single Link Key for every connected device, plus an additional Encryption Key for each session)

• Changing operational password (Encryption Key)

• Keys/passwords are never communicated over the radio

Pairing is the process by which two Bluetooth devices bond and share a key, which is another word for password. Both devices begin with an initial password, but pairing is a highly secure multi-step, multi-password process. Its purpose is to create the semi-permanent key, called the Link Key. The Link Key is the password that is used to generate a second key, the Encryption Key, which is unique for each operating session (defined below). The creation of the Link Key begins with the use of a PIN or Passkey.

Discovery Devices must be discovered before actual communication can begin. For Bluetooth devices, this involves enabling device discovery and making inquiry scans. Once the PC finds a device, it requests basic information that identifies the device’s type and capabilities.

Discovery is not certain. Devices may or may not be discoverable depending on their applications or configuration settings. While discovery might happen automatically for some Bluetooth devices, for added security Windows® XP SP2 (SP2) and Microsoft® keyboards require user intervention. Discovery is turned off by default, which means the PC and device cannot be found unless a user specifically turns on that capability. Conversely, a mouse and keyboard that are paired to a PC can return from a powered-off state and find the PC even if it is not discoverable. The PC must respond to a connection request from a paired device.

Keys For keyboards, the pairing process comprises the entry of a Passkey/PIN, the creation and verification of an Authentication key, and the creation and verification of the Link Key. Pairing is complete when the Link Key has been generated and verified. Figure 2 shows the sequential relationship between the keys. The first two keys are temporary and are discarded immediately after use. Once the Link Key has been created and verified, an Encryption Key is created for the next session and communication can begin:

Page 10: Microsoft Hardware Bluetooth White Paper

Bluetooth® and Microsoft® Desktop Products 8

Pairing is done only once. It is unaffected by powering the PC off and on, moving out of and back within range, or by battery replacement. Those actions do, however, constitute the end of an operating session and the beginning of a new session, so they result in the Link Key being used to generate a new Encryption Key for the new session. But the Link Key remains the same unless a user takes specific action to change it. The basic pairing and subsequent session process flow is shown from top to bottom in the simplified diagram in Figure 3:

Authentication Link Keys are unique between each device and PC, so a PC paired with three devices would share three different Link Keys. Link Keys are used for each party (device and PC) to verify that the other party is in fact who it says it is, as well as for generating encryption keys.

For device A to authenticate device B, device A creates a random number and sends it to B. Device B receives the random number, encrypts it with its Link Key, and sends it back to A. Device A then decrypts this transmission using its Link Key and compares it to the original random number. If those numbers match, then device A knows that device B has the same Link Key, and device B is therefore authenticated. Device B also performs the same process with device A to verify its identity. Authentication has taken place once both numbers are verified.

It is important to reemphasize two points:

• At no time is any key transmitted over the Bluetooth radio.

• After the initial PIN, 128-bit encryption is used for all keys and random numbers.

• Temporary • 8-16 digits • Used to create

Authentication Key

• Temporary • 128 bits • Used to create Link Key

• Semi-permanent • 128 bits • Used to create

Encryption Keys

• Session only • 128 bits • Used to encrypt/

decrypt transmission

Passkey/PIN Authentication Key Link Key Encryption Key

Pairing Session

Pairing

Session

Bluetooth Keyboard PC

Enter Passkey/PIN

Random number generated

Random number generated

Random number generated

Authentication Key created

Link Key created

Encryption Key created

Exchange and verify random numbers

Exchange and verify random numbers

Exchange and verify random numbers

Random number generated

Random number generated

Random number generated

Enter Passkey/PIN

Link Key created

Encryption Key created

Encrypt/Decrypt Encrypt/Decrypt Encrypted Traffic

Authentication Key created

Figure 3 – Pairing Process Flow

Figure 2 – Bluetooth® Security Keys

Page 11: Microsoft Hardware Bluetooth White Paper

Bluetooth® and Microsoft® Desktop Products 9

Understanding Pairing – An Example

Microsoft® Windows® XP helps with discovering, authenticating, and connecting to Bluetooth® devices through its wizard. The wizard serves as a good vehicle to describe and understand the pairing process. The discussion that follows uses the Microsoft Optical Desktop Elite for Bluetooth, a keyboard and mouse desktop combination, to illustrate pairing.

Bluetooth Settings The pairing process for Bluetooth devices can be started from the Control Panel, assuming that SP2 has been installed. Windows XP SP2 includes the drivers for certain Bluetooth radios (http://support.microsoft.com/?id=841803). It is important to note that standard user level rights are sufficient for installing the Bluetooth drivers or for pairing keyboards and mouse products. Clicking on Bluetooth Devices (Figure 4) in the Control Panel will display the

Bluetooth Devices dialog.

Before adding a new device, existing devices should be reviewed. The Devices tab will show all the devices that are currently paired with the PC. Figure 5 shows a situation in which there are two devices already paired with the PC: a mouse and keyboard.

Notice that the keyboard has security enabled (Passkey enabled) while the mouse does not (No passkey).

The Options tab (Figure 6) contains the settings that control how Windows XP SP2 manages Bluetooth connections. In the Connections grouping, the checkbox “Allow Bluetooth devices to connect to this computer” should be on. This enables a keyboard and mouse to recover from their power saving states. Disabling this box will disallow Bluetooth communications with the Microsoft keyboard and mouse.

If security is a concern, the “Turn discovery on” checkbox should be left unchecked. This will prevent the PC from responding to a general inquiry and make the PC undiscoverable by unpaired devices. Only a Bluetooth device that is already paired with the PC will be able to discover the PC. For security purposes, this is the default setting.

The checkbox “Alert me when a new Bluetooth device wants to connect” is checked by default in Windows XP SP2. This can be

Figure 4 – Control Panel

Figure 5 – Devices

Figure 6 – Options

Page 12: Microsoft Hardware Bluetooth White Paper

Bluetooth® and Microsoft® Desktop Products 10

unchecked if security is a concern, with the effect that the user will not be prompted if a device tries to pair with the PC. Thus any connection attempt not initiated by the user through the PC will fail. Alternatively, leaving the box checked would also serve to detect and alert a user to the existence of potential threats. Any such attempt could simply be declined. Users always have the option to manually initiate pairing from the user interface by adding a new device through the Control Panel.

Adding a Device On the Devices tab there is an Add button that will initiate pairing by running the Bluetooth® Device Wizard (Figure 7).

Note the security warning at the bottom: “Add only Bluetooth devices that you trust.” A trusted device is one that the user or the user’s company owns and controls. An untrusted device is one that is public, or it may be one that is in a different physical location.

A device in a different location could still be trusted if it is owned by and under company control, e.g., a shared printer in another room. Adding a public device that is not trusted is probably not a good idea. If a public device is

added, the user may remove it or restrict it to only the minimum services necessary on the Services tab in the Bluetooth Devices dialog.

Checking the box “My device is set up and ready to be found.” and clicking Next will initiate discovery. At this point the device must be discoverable. (For Microsoft® Bluetooth hardware this is done with a “Make/Break Connection” button on the bottom of the devices.) Refer to the device documentation for specifics. The PC will scan for available Bluetooth devices that are within range, and display icons, names, and status: “New device” or “Already connected” (Figure 8).

Selecting the desired device and clicking Next continues the pairing process.

Passkey Challenge Some Bluetooth devices require authentication before the device can be used with Windows®. During authentication, the same passkey must be entered into the Bluetooth Connection Wizard and into the Bluetooth device. As discussed earlier, the passkey, or PIN, is a temporary key that is entered by the user. Its only purpose is to generate an initial Authentication key and then the PIN is discarded. The PIN and all keys are never transmitted over the radio.

Windows XP SP2 offers the following PIN options when connecting a Bluetooth device (also shown in Figure 9 below):

Figure 7 – Wizard

Figure 8 – Device Selection

Page 13: Microsoft Hardware Bluetooth White Paper

Bluetooth® and Microsoft® Desktop Products 11

• Choose a passkey for me – the default choice, this creates an 8-character random numerical string.

• Use the passkey found in the documentation – not applicable for keyboards, this applies to devices like a printer that do not have a method for PIN input.

• Let me choose my own passkey – Windows® recommends that the user choose a numeric PIN 8 - 16 characters in length, but it does not enforce the minimum length. This is the recommended choice.

• Don’t use a passkey – this pairs both devices with security turned off. This option is meant for devices like mouse products that do not support authentication or encryption. (This is not recommended for keyboards, since this would mean that the keystrokes would be sent unencrypted. Windows will not enforce this, so it is possible for a user to pair a keyboard with security turned off.)

Note the security warning at the bottom of Figure 9 that instructs the user to enter a strong PIN for the pairing process. If a user chooses to enter his own passkey, the passkey must first be entered from a keyboard other than the Bluetooth® keyboard that is being connected.

Once the passkey has been entered on the PC, the user is prompted to enter the same PIN from the Bluetooth keyboard (Figure 10). If the PIN entered on the Bluetooth keyboard matches the PIN entered on the PC (with the attached keyboard), authentication succeeds. If the PINs do not match, authentication fails. For security purposes, there is a timeout for completion of this step.

Once the PIN is entered, the pairing process proceeds rapidly to completion. That completion process is important to understanding Bluetooth security. The PIN is simply an initial input to the generation of the temporary 128-bit Authentication key. This means that the PIN is only used for the next few transactions (typically under a minute) and then it is discarded.

Figure 9 – Passkey Selection

Figure 10 – Passkey Entry

Page 14: Microsoft Hardware Bluetooth White Paper

Bluetooth® and Microsoft® Desktop Products 12

Summary

Bluetooth® technology delivers on the promise of reliable wireless connectivity – with respect to interference, security, and range, Bluetooth is the best wireless implementation available for personal computing hardware in the workplace. Security and freedom from interference are concerns whenever communications are involved, and they are particularly important when considering wireless technology instead of wired or cabled technology. In the previous discussion, and in the keyboard example, different elements of Bluetooth security and interference immunity have been mentioned. Some of those elements are fundamental to the Bluetooth specification, while others are application implementations unique to the devices. As we have seen, the Bluetooth standard basically encompasses the following:

• Frequency-hopping spread spectrum technology, which makes Bluetooth communications relatively immune to interference.

• Bidirectional communication that enables packet retransmission also contributes to interference immunity.

• Encryption algorithms, which are strong and employ 128-bit keys.

• Procedures for configuring and controlling security, such as the pairing sequence for creating Link and Encryption Keys, where keys are never transmitted over the radio.

• “Virtual cable” or an exclusive 1:1 relationship between the Bluetooth keyboard and the PC, meaning that no other devices are permitted to have that relationship.

• Additionally, when compared to 27 MHz devices, Bluetooth also offers the advantages of being able to connect multiple devices and longer range.

We have also seen Bluetooth keyboard security elements that are provided by Windows® XP SP2:

• Bluetooth Wizard for device connection that is fast and simple, relying on a Passkey/PIN that is not transmitted over the radio.

• Bluetooth Devices dialog in Control Panel for configuration, where, by default, the PC cannot be discovered by another Bluetooth device.

Refer to http://www.microsoft.com/hardware for more information about Microsoft® Bluetooth products.

Page 15: Microsoft Hardware Bluetooth White Paper

Bluetooth® and Microsoft® Desktop Products 13

Appendix 1: Bluetooth® Security on Microsoft® Desktop Products

The information contained within this Appendix is a more detailed, technical description of how the Bluetooth encryption process works.

Pairing Process for Microsoft Bluetooth Keyboards Pairing, or the process of creating a trusted relationship between two devices, involves a succession of security key creation:

• Entry of the one-time PIN

• Generation of the one-time Init Key (using the PIN)

• Generation of the semi-permanent Link Key (using the Init Key)

Once the Link Key has been created, each working session begins with:

• Generation of the Encryption Key (using the Link Key). A new Encryption Key is generated each time a session is begun.

As described previously, pairing is initiated by pressing the Make/Break Connection button under the keyboard and running the Add Bluetooth Device Wizard in Windows® XP SP2. It is necessary to pair the keyboard to the PC only once.

With the exception of the PIN, which can be generated by the user, all other input security keys employed by Microsoft Bluetooth keyboards are 128 bits in length. These keys are combination keys that require three inputs:

• Input key, which is one of the keys in the process. See Figure 11 for process flow.

• Random number

• Bluetooth address

Length and entropy of the PIN

The PIN chosen and entered by the user is comprised of only numerical characters. It is 1 to 16 characters in length. The Windows XP SP2 user interface presents the following options when pairing a Bluetooth device:

• Choose a passkey for me – This default option creates a random numerical string of 8 characters.

• Use the passkey found in the documentation – Not applicable for keyboards, this option applies to devices like printers that do not have a method for PIN input.

• Let me choose my own passkey – Windows recommends that the user choose a numeric PIN 8 to 16 characters in length, but does not enforce the minimum length.

• Don’t use a passkey – This option pairs both devices with security turned off. This option is meant for devices like mice that do not support authentication or encryption. It is NOT recommended for keyboards, since keystrokes would be sent unencrypted. Windows does not enforce this, so it is possible for a user to pair a keyboard with security turned off.

Page 16: Microsoft Hardware Bluetooth White Paper

Bluetooth® and Microsoft® Desktop Products 14

Length and entropy of the Random Number

The 128-bit random number is the output of the same Massey/Rueppel generator used for the encryption operations. The seed that is used in the random number generator is a 128-bit value which is a combination of the:

• 32-bit Bluetooth clock snapped at a random time in the firmware

• Other values read from the hardware, such as radio symbol tracking register values, piconet slot offset register values, and a few others.

Length and entropy of the Bluetooth® address

The 48-bit Bluetooth address is a unique number assigned to the device. All Bluetooth devices have unique addresses that are assigned by the IEEE to device manufacturers.

The top 24 bits identify the manufacturer and are assigned out of the same IEEE OUI space as MAC addresses. The lower 24 bits are assigned by the manufacturer to identify the specific device.

Algorithms used to derive the Security Keys Refer to Appendix 2: Bluetooth® Specification v1.2 Controller Volume, Part H SECURITY SPECIFICATION. The authentication functions are called E1, E2 and E3. E2 and E3 are variations of E1:

“The authentication function E1 is a computationally secure authentication code. E1 uses the encryption function SAFER+. The algorithm is an enhanced version of an existing 64-bit block cipher SAFER-SK128, and it is freely available.” (From section 6.1 of Part H SECURITY SPECIFICATION.)

The 128-bit Initialization Key is generated by the E2 algorithm and takes the following inputs:

• PIN (8 to 128 bits)

• BD_ADDR of the Claimant device (the keyboard) (48 bits)

E22 E22 Random Numbers

E21 E21 Random Numbers

E1 Authentication E1 AuthenticationAuthentication

Exchange

E3 E3

PIN PIN

Generate Initialization

Key

Generate Initialization

Key

Generate Link Key

Generate Link Key

Link Key

Link Key

E0 Stream Cipher E0 Stream Cipher Encrypted Traffic

Generate Encryption

Key

Generate Encryption

Key

Random Numbers

1-16 characters

128 bits

128 bits

128 bits

Figure 11

Page 17: Microsoft Hardware Bluetooth White Paper

Bluetooth® and Microsoft® Desktop Products 15

• RND (128 bits)

The Initialization Key is discarded after the combination Link Key is generated. The 128-bit Link Key is generated by the E1 algorithm and takes the following inputs:

• 128-bit Random Number from device A (RANDA)

• 128-bit Random Number from device B (RANDB)

• 128-bit Initialization Key

• 48-bit Bluetooth address of device A (BD_ADDRA)

• 48-bit Bluetooth address of device B (BD_ADDRB)

A new 128-bit Encryption Key is generated by the E3 algorithm whenever a new encrypted connection is formed, i.e., a new session. In the case of a keyboard, this occurs when the keyboard reconnects to Windows® XP through user activity after becoming disconnected, e.g., after 10 minutes of inactivity.

The Bluetooth® specification allows for the negotiation of the size of the Encryption Key, which can be as short as 8 bits and up to 128 bits. Microsoft® keyboards with the Microsoft Wireless Transceiver for Bluetooth (included with the Microsoft Optical Desktop Elite for Bluetooth) and Windows XP SP2 always use 128-bit encryption keys.

The Encryption Key takes the following inputs:

• 128-bit Link Key

• 128-bit Random Number

• 96-bit Ciphering Offset Number (COF)

The COF is the number (Authentication Ciphering Offset or ACO) generated by E1 during pairing.

Conclusion • SAFER+ 128-bit encryption is employed.

• Keys are never transmitted over the radio.

• As previously discussed, the Virtual Cable protects against connection intrusion attacks (which has been a problem for some phone implementations).

• For further information refer to Appendix 2, Bluetooth® Specification v1.2 Controller Volume, Part H SECURITY SPECIFICATION, which follows on the next page.

Page 18: Microsoft Hardware Bluetooth White Paper

Bluetooth® and Microsoft® Desktop Products 16

Appendix 2: Bluetooth® Specification v1.2 Controller Volume, Part H SECURITY SPECIFICATION

Page 19: Microsoft Hardware Bluetooth White Paper

Part H

SECURITY SPECIFICATION

This document describes the specification of the security system which may be used at the link layer. The Encryption, Authentication and Key Generation schemes are specified. The requirements for the supporting process of random number generation are also specified.

Core System Package [Controller volume]

Page 20: Microsoft Hardware Bluetooth White Paper

746 05 November 2003

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 746 of 790

Security Specification

Page 21: Microsoft Hardware Bluetooth White Paper

05 November 2003 747

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 747 of 790

Security Specification

CONTENTS

1 Security Overview ............................................................................7492 Random Number Generation ..........................................................7513 Key Management..............................................................................753

3.1 Key Types ................................................................................7533.2 Key Generation and Initialization .............................................755

3.2.1 Generation of initialization key, ...................................7563.2.2 Authentication..............................................................7563.2.3 Generation of a unit key ..............................................7563.2.4 Generation of a combination key.................................7573.2.5 Generating the encryption key ....................................7583.2.6 Point-to-multipoint configuration..................................7593.2.7 Modifying the link keys ................................................7603.2.8 Generating a master key .............................................760

4 Encryption.........................................................................................7634.1 Encryption Key Size Negotiation..............................................7644.2 Encryption of Broadcast Messages..........................................7644.3 Encryption Concept..................................................................7654.4 Encryption Algorithm................................................................766

4.4.1 The operation of the cipher .........................................7684.5 LFSR Initialization ....................................................................7694.6 Key Stream Sequence .............................................................772

5 Authentication ..................................................................................7735.1 Repeated Attempts ..................................................................775

6 The Authentication And Key-Generating Functions.....................7776.1 The Authentication Function E1...............................................7776.2 The Functions Ar and A’r..........................................................779

6.2.1 The round computations..............................................7796.2.2 The substitution boxes “e” and “l”................................7796.2.3 Key scheduling ............................................................780

6.3 E2-Key Generation Function for Authentication.......................7816.4 E3-Key Generation Function for Encryption.............................783

7 List of Figures...................................................................................7858 List of Tables ....................................................................................787

Page 22: Microsoft Hardware Bluetooth White Paper

748 05 November 2003

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 748 of 790

Security Specification

Page 23: Microsoft Hardware Bluetooth White Paper

Security Overview 05 November 2003 749

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 749 of 790

Security Specification

1 SECURITY OVERVIEW

Bluetooth wireless technology provides peer-to-peer communications over short distances. In order to provide usage protection and information confiden-tiality, the system provides security measures both at the application layer and the link layer. These measures are designed to be appropriate for a peer envi-ronment. This means that in each device, the authentication and encryption routines are implemented in the same way. Four different entities are used for maintaining security at the link layer: a Bluetooth device address, two secret keys, and a pseudo-random number that shall be regenerated for each new transaction. The four entities and their sizes are summarized in Table 1.1.

The Bluetooth device address (BD_ADDR) is the 48-bit address. The BD_ADDR can be obtained via user interactions, or, automatically, via an inquiry routine by a device.

The secret keys are derived during initialization and are never disclosed. The encryption key is derived from the authentication key during the authentication process. For the authentication algorithm, the size of the key used is always 128 bits. For the encryption algorithm, the key size may vary between 1 and 16 octets (8 - 128 bits). The size of the encryption key is configurable for two rea-sons. The first has to do with the many different requirements imposed on cryp-tographic algorithms in different countries − both with respect to export regulations and official attitudes towards privacy in general. The second reason is to facilitate a future upgrade path for the security without the need of a costly redesign of the algorithms and encryption hardware; increasing the effective key size is the simplest way to combat increased computing power at the oppo-nent side.

The encryption key is entirely different from the authentication key (even though the latter is used when creating the former, as is described in Section 6.4 on page 783). Each time encryption is activated, a new encryption key shall be generated. Thus, the lifetime of the encryption key does not necessarily cor-respond to the lifetime of the authentication key.

It is anticipated that the authentication key will be more static in its nature than the encryption key − once established, the particular application running on the device decides when, or if, to change it. To underline the fundamental impor-

Entity Size

BD_ADDR 48 bits

Private user key, authentication 128 bits

Private user key, encryptionconfigurable length (byte-wise)

8-128 bits

RAND 128 bits

Table 1.1: Entities used in authentication and encryption procedures.

Page 24: Microsoft Hardware Bluetooth White Paper

750 05 November 2003 Security Overview

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 750 of 790

Security Specification

tance of the authentication key to a specific link, it is often be referred to as the link key.

The RAND is a pseudo-random number which can be derived from a random or pseudo-random process in the device. This is not a static parameter, it will change frequently.

In the remainder of this chapter, the terms user and application will be used interchangeably to designate the entity that is at either side.

Page 25: Microsoft Hardware Bluetooth White Paper

Random Number Generation 05 November 2003 751

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 751 of 790

Security Specification

2 RANDOM NUMBER GENERATION

Each device has a pseudo-random number generator. Pseudo-random num-bers are used for many purposes within the security functions − for instance, for the challenge-response scheme, for generating authentication and encryp-tion keys, etc. Ideally, a true random generator based on some physical pro-cess with inherent randomness should be used as a seed. Examples of such processes are thermal noise from a semiconductor or resistor and the fre-quency instability of a free running oscillator. For practical reasons, a software based solution with a pseudo-random generator is probably preferable. In gen-eral, it is quite difficult to classify the randomness of a pseudo-random sequence. Within this specification, the requirements placed on the random numbers used are non-repeating and randomly generated.

The expression ‘non-repeating’ means that it shall be highly unlikely that the value will repeat itself within the lifetime of the authentication key. For example, a non-repeating value could be the output of a counter that is unlikely to repeat during the lifetime of the authentication key, or a date/time stamp.

The expression ‘randomly generated’ means that it shall not be possible to pre-dict its value with a chance that is significantly larger than 0 (e.g., greater than

for a key length of L bits).

The LM may use such a generator for various purposes; i.e. whenever a ran-dom number is needed (such as the RANDs, the unit keys, Kinit, Kmaster, and random back-off or waiting intervals).

1 2L⁄

Page 26: Microsoft Hardware Bluetooth White Paper

752 05 November 2003 Random Number Generation

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 752 of 790

Security Specification

Page 27: Microsoft Hardware Bluetooth White Paper

Key Management 05 November 2003 753

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 753 of 790

Security Specification

3 KEY MANAGEMENT

It is important that the encryption key size within a specific device cannot be set by the user − this should be a factory preset entity. In order to prevent the user from over-riding the permitted key size, the Bluetooth baseband processing shall not accept an encryption key given from higher software layers. When-ever a new encryption key is required, it shall be created as defined in Section 6.4 on page 783.

Changing a link key shall also be done through the defined baseband proce-dures. Depending on what kind of link key it is, different approaches are required. The details are found in Section 3.2.7 on page 760.

3.1 KEY TYPES

The link key is a 128-bit random number which is shared between two or more parties and is the base for all security transactions between these parties. The link key itself is used in the authentication routine. Moreover, the link key is used as one of the parameters when the encryption key is derived.

In the following, a session is defined as the time interval for which the device is a member of a particular piconet. Thus, the session terminates when the device disconnects from the piconet.

The link keys are either semi-permanent or temporary. A semi-permanent link key may be stored in non-volatile memory and may be used after the current session is terminated. Consequently, once a semi-permanent link key is defined, it may be used in the authentication of several subsequent connec-tions between the devices sharing it. The designation semi-permanent is justi-fied by the possibility of changing it. How to do this is described in Section 3.2.7 on page 760.

The lifetime of a temporary link key is limited by the lifetime of the current ses-sion − it shall not be reused in a later session. Typically, in a point-to-multipoint configuration where the same information is to be distributed securely to sev-eral recipients, a common encryption key is useful. To achieve this, a special link key (denoted master key) may temporarily replace the current link keys. The details of this procedure are found in Section 3.2.6 on page 759.

In the following, the current link key is the link key in use at the current moment. It can be semi-permanent or temporary. Thus, the current link key is used for all authentications and all generation of encryption keys in the on-going connec-tion (session).

Page 28: Microsoft Hardware Bluetooth White Paper

754 05 November 2003 Key Management

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 754 of 790

Security Specification

In order to accommodate different types of applications, four types of link keys have been defined:

• the combination key KAB

• the unit key KA

• the temporary key Kmaster

• the initialization key Kinit

Note: the use of unit keys is deprecated since it is implicitly insecure.

In addition to these keys there is an encryption key, denoted Kc. This key is derived from the current link key. Whenever encryption is activated by an LM command, the encryption key shall be changed automatically. The purpose of separating the authentication key and encryption key is to facilitate the use of a shorter encryption key without weakening the strength of the authentication procedure. There are no governmental restrictions on the strength of authenti-cation algorithms. However, in some countries, such restrictions exist on the strength of encryption algorithms.

The combination key KAB and the unit key KA are functionally indistinguishable; the difference is in the way they are generated. The unit key KA is generated in, and therefore dependent on, a single device A. The unit key shall be generated once at installation of the device; thereafter, it is very rarely changed. The com-bination key is derived from information in both devices A and B, and is there-fore always dependent on two devices. The combination key is derived for each new combination of two devices.

It depends on the application or the device whether a unit key or a combination key is used. Devices which have little memory to store keys, or are installed in equipment that will be accessible to a large group of users, should use their own unit key. In that case, they only have to store a single key. Applications that require a higher security level should use the combination keys. These applications will require more memory since a combination key for each link to a different device has to be stored.

The master key, Kmaster, shall only be used during the current session. It shall only replace the original link key temporarily. For example, this may be utilized when a master wants to reach more than two devices simultaneously using the same encryption key, see Section 3.2.6 on page 759.

The initialization key, Kinit, shall be used as the link key during the initialization process when no combination or unit keys have been defined and exchanged yet or when a link key has been lost. The initialization key protects the transfer of initialization parameters. The key is derived from a random number, an L-octet PIN code, and a BD_ADDR. This key shall only be used during initialization.

Page 29: Microsoft Hardware Bluetooth White Paper

Key Management 05 November 2003 755

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 755 of 790

Security Specification

The PIN may be a fixed number provided with the device (for example when there is no user interface as in a PSTN plug). Alternatively, the PIN can be selected by the user, and then entered in both devices that are to be matched. The latter procedure should be used when both devices have a user interface, for example a phone and a laptop. Entering a PIN in both devices is more secure than using a fixed PIN in one of the devices, and should be used when-ever possible. Even if a fixed PIN is used, it shall be possible to change the PIN; this is in order to prevent re-initialization by users who once got hold of the PIN. If no PIN is available, a default value of zero may be used. The length of this default PIN is one byte, PIN(default) = 0x00. This default PIN may be pro-vided by the host.

For many applications the PIN code will be a relatively short string of numbers. Typically, it may consist of only four decimal digits. Even though this gives suffi-cient security in many cases, there exist countless other, more sensitive, situa-tions where this is not reliable enough. Therefore, the PIN code may be chosen to be any length from 1 to 16 octets. For the longer lengths, the devices exchanging PIN codes may not use mechanical (i.e. human) interaction, but rather may use software at the application layer. For example, this can be a Dif-fie-Hellman key agreement, where the exchanged key is passed on to the generation process in both devices, just as in the case of a shorter PIN code.

3.2 KEY GENERATION AND INITIALIZATIONThe link keys must be generated and distributed among the devices in order to be used in the authentication procedure. Since the link keys shall be secret, they shall not be obtainable through an inquiry routine in the same way as the Bluetooth device addresses. The exchange of the keys takes place during an initialization phase which shall be carried out separately for each two devices that are using authentication and encryption. The initialization procedures con-sist of the following five parts:• generation of an initialization key

• generation of link key

• link key exchange

• authentication

• generation of encryption key in each device (optional)

After the initialization procedure, the devices can proceed to communicate, or the link can be disconnected. If encryption is implemented, the E0 algorithm shall be used with the proper encryption key derived from the current link key. For any new connection established between devices A and B, they should use the common link key for authentication, instead of once more deriving Kinit from the PIN. A new encryption key derived from that particular link key shall be cre-ated next time encryption is activated.

If no link key is available, the LM shall automatically start an initialization proce-dure.

Kinit

Page 30: Microsoft Hardware Bluetooth White Paper

756 05 November 2003 Key Management

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 756 of 790

Security Specification

3.2.1 Generation of initialization key,

A link key is used temporarily during initialization, the initialization key . This key shall be derived by the algorithm from a BD_ADDR, a PIN code, the length of the PIN (in octets), and a random number IN_RAND. The princi-ple is depicted in Figure 6.4 on page 783. The 128-bit output from shall be used for key exchange during the generation of a link key. When the devices have performed the link key exchange, the initialization key shall be discarded.

When the initialization key is generated, the PIN is augmented with the BD_ADDR. If one device has a fixed PIN the BD_ADDR of the other device shall be used. If both devices have a variable PIN the BD_ADDR of the device that received IN_RAND shall be used. If both devices have a fixed PIN they cannot be paired. Since the maximum length of the PIN used in the algorithm cannot exceed 16 octets, it is possible that not all octets of BD_ADDR will be used. This procedure ensures that depends on the identity of the device with a variable PIN. A fraudulent device may try to test a large number of PINs by claiming another BD_ADDR each time. It is the application’s responsibility to take countermeasures against this threat. If the device address is kept fixed, the waiting interval before the next try may be increased exponentially (see Section 5.1 on page 775).

The details of the algorithm can be found in Section 6.3 on page 781.

3.2.2 Authentication

The authentication procedure shall be carried out as described in Section 5 on page 773. During each authentication, a new AU_RANDA shall be issued.

Mutual authentication is achieved by first performing the authentication proce-dure in one direction and then immediately performing the authentication pro-cedure in the opposite direction.

As a side effect of a successful authentication procedure an auxiliary parame-ter, the Authenticated Ciphering Offset (ACO), will be computed. The ACO shall be used for ciphering key generation as described in Section 3.2.5 on page 758.

The claimant/verifier status is determined by the LM.

3.2.3 Generation of a unit key

A unit key shall be generated when the device is in operation for the first time; i.e. not during each initialization. The unit key shall be generated by the algo-rithm as described in Section 6.3 on page 781. Once created, the unit key should be stored in non-volatile memory and very rarely changed. If after initialization

Kinit

Kinit

E22

E22

Kinit

E22

KA

E21

Page 31: Microsoft Hardware Bluetooth White Paper

Key Management 05 November 2003 757

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 757 of 790

Security Specification

the unit key is changed, any previously initialized devices will possess a wrong link key. At initialization, the application must determine which of the two parties will provide the unit key as the link key. Typically, this will be the device with restricted memory capabilities, since this device only has to remember its own unit key. The unit key shall be transferred to the other party and then stored as the link key for that particular party. So, for example in Figure 3.1 on page 757, the unit key of device A, , is being used as the link key for the connection A-B; device A sends the unit key to device B; device B will store as the link key

. For another initialization, for example with device C, device A will reuse its unit key , whereas device C stores it as .

Figure 3.1: Generation of unit key. When the unit key has been exchanged, the initialization key is discarded in both devices.

3.2.4 Generation of a combination key

To use a combination key, it is first generated during the initialization proce-dure. The combination key is the combination of two numbers generated in device A and B, respectively. First, each device shall generate a random num-ber, LK_RANDA and LK_RANDB. Then, utilizing with the random number and their own BD_ADDRs, the two random numbers

(EQ 1)

and

(EQ 2)

shall be created in device A and device B, respectively. These numbers consti-tute the devices’ contribution to the combination key that is to be created. Then, the two random numbers LK_RANDA and LK_RANDB shall be exchanged securely by XORing with the current link key, . Thus, device A shall send to device B, while device B shall send

to device A. If this is done during the initialization phase the link key .

KA

KA KA

KBA

KA KCA

KA

UNIT BUNIT A

Kinit

K K = BA A

initK

E21

LK_KA E21 LK_RANDA BD_ADDRA,( ),=

LK_KB E21 LK_RANDB BD_ADDRB,( ),=

KK LK_RANDA⊕

K LK_RANDB⊕

K Kinit=

Page 32: Microsoft Hardware Bluetooth White Paper

758 05 November 2003 Key Management

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 758 of 790

Security Specification

When the random numbers and have been mutually exchanged, each device shall recalculate the other device’s contribution to the combination key. This is possible since each device knows the Bluetooth device address of the other device. Thus, device A shall calculate (EQ 2) on page 757 and device B shall calculate (EQ 1) on page 757. After this, both devices shall combine the two numbers to generate the 128-bit link key. The combining operation is a simple bitwise modulo-2 addition (i.e. XOR). The result shall be stored in device A as the link key and in device B as the link key . When both devices have derived the new combination key, a mutual authentication procedure shall be initiated to confirm the success of the trans-action. The old link key shall be discarded after a successful exchange of a new combination key. The message flow between master and slave and the principle for creating the combination key is depicted in Figure 3.2 on page 758.

Figure 3.2: Generating a combination key. The old link key (K) is discarded after the exchange of a new combination key has succeeded

3.2.5 Generating the encryption key

The encryption key, , is derived by algorithm from the current link key, a 96-bit Ciphering OFfset number (COF), and a 128-bit random number. The COF is determined in one of two ways. If the current link key is a master key, then COF shall be derived from the master BD_ADDR. Otherwise the value of COF shall be set to the value of ACO as computed during the authentication procedure. Therefore:1

1. denotes the concatenation of and .

LK_RANDA LK_RANDB

KAB

KBA

Unit B

LK_KA E21 LK_RANDA BD_ADDRA,( )=

CA

CA LK_RANDA K⊕=

Authentication

LK_KB E21 LK_RANDB BD_ADDRB,( )=

LK_KB E21 LK_RANDB BD_ADDRB,( )=

LK_RANDA CA K⊕=

CB LK_RANDB K⊕=

CB

LK_RANDB CB K⊕=

LK_KA E21 LK_RANDA BD_ADDRA,( )=

KAB LK_KA LK_KB⊕= KBA LK_KA LK_KB⊕ KAB= =

Unit A

KC E3

x y∪ x y

Page 33: Microsoft Hardware Bluetooth White Paper

Key Management 05 November 2003 759

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 759 of 790

Security Specification

(EQ 3)

There is an explicit call of when the LM activates encryption. Consequently, the encryption key is automatically changed each time the device enters encryption mode. The details of the key generating function can be found in Section 6.4 on page 783.

3.2.6 Point-to-multipoint configuration

It is possible for the master to use separate encryption keys for each slave in a point-to-multipoint configuration with ciphering activated. Then, if the applica-tion requires more than one slave to listen to the same payload, each slave must be addressed individually. This can cause unwanted capacity loss for the piconet. Moreover, a slave might not be capable of switching between two or more encryption keys in real time (e.g., after looking at the LT_ADDR in the header). Thus, the master cannot use different encryption keys for broadcast messages and individually addressed traffic. Therefore, the master may tell several slave devices to use a common link key (and, hence, indirectly also to use a common encryption key) and may then broadcast the information encrypted. For many applications, this key is only of temporary interest. In the following discussion, this key is denoted by .

The transfer of necessary parameters shall be protected by the routine described in Section 3.2.8 on page 760. After the confirmation of successful reception in each slave, the master shall issue a command to the slaves to replace their respective current link key by the new (temporary) master key. Before encryption can be activated, the master shall also generate and distrib-ute a common EN_RAND to all participating slaves. Using this random number and the newly derived master key, each slave shall generate a new encryption key.

Note that the master must negotiate the encryption key length to use individu-ally with each slave that will use the master key. If the master has already negotiated with some of these slaves, it has knowledge of the sizes that can be accepted. There may be situations where the permitted key lengths of some devices are incompatible. In that case, the master must exclude the limiting device from the group.

When all slaves have received the necessary data, the master can communi-cate information on the piconet securely using the encryption key derived from the new temporary link key. Each slave in possession of the master key can eavesdrop on all encrypted traffic, not only the traffic intended for itself. The master may tell all participants to fall back to their old link keys simultaneously.

COF BD_ADDR BD_ADDR,∪ if link key is a master key ACO, otherwise.⎩

⎨⎧

=

E3

E3

Kmaster

Page 34: Microsoft Hardware Bluetooth White Paper

760 05 November 2003 Key Management

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 760 of 790

Security Specification

3.2.7 Modifying the link keys

A link key based on a unit key can be changed. The unit key is created once during first use. Typically, the link key should be changed rather than the unit key, as several devices may share the same unit key as link key (e.g. a printer whose unit key is distributed to all users using the printer’s unit key as link key). Changing the unit key will require re-initialization of all devices connecting. Changing the unit key can be justified in some circumstances, e.g. to deny access to all previously allowed devices.

If the key change concerns combination keys, then the procedure is straightfor-ward. The change procedure is identical to the procedure described in Figure 3.2 on page 758, using the current value of the combination key as link key. This procedure can be carried out at any time after the authentication and encryption start. Since the combination key corresponds to a single link, it can be modified each time this link is established. This will improve the security of the system since then old keys lose their validity after each session.

Starting up an entirely new initialization procedure is also possible. In that case, user interaction is necessary since a PIN will be required in the authentication and encryption procedures.

3.2.8 Generating a master key

The key-change routines described so far are semi-permanent. To create the master link key, which can replace the current link key during a session (see Section 3.2.6 on page 759), other means are needed. First, the master shall create a new link key from two 128-bit random numbers, RAND1 and RAND2. This shall be done by

(EQ 4)

This key is a 128-bit random number. The reason for using the output of and not directly choosing a random number as the key, is to avoid possible problems with degraded randomness due to a poor implementation of the ran-dom number generator within the device.

Then, a third random number, RAND, shall be transmitted to the slave. Using with the current link key and RAND as inputs, both the master and the

slave shall compute a 128-bit overlay. The master shall send the bitwise XOR of the overlay and the new link key to the slave. The slave, who knows the overlay, shall recalculate . To confirm the success of this transaction, the devices shall perform a mutual authentication procedure using the new link key. This procedure shall then be repeated for each slave that receives the new link key. The ACO values from the authentications shall not replace the current ACO, as this ACO is needed to (re)compute a ciphering key when the master falls back to the previous (non-temporary) link key.

Kmaster E22 RAND1 RAND2 16, ,( ).=

E22

E22

Kmaster

Page 35: Microsoft Hardware Bluetooth White Paper

Key Management 05 November 2003 761

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 761 of 790

Security Specification

The master activates encryption by an LM command. Before activating encryp-tion, the master shall ensure that all slaves receive the same random number, EN_RAND, since the encryption key is derived through the means of indi-vidually in all participating devices. Each slave shall compute a new encryption key as follows:

(EQ 5)

where the value of COF shall be derived from the master’s BD_ADDR as spec-ified by equation (EQ 3) on page 759. The details of the encryption key gener-ating function are described in Section 6.4 on page 783. The message flow between the master and the slave when generating the master key is depicted in Figure 3.3. Note that in this case the ACO produced during the authentica-tion is not used when computing the ciphering key.

Figure 3.3: Master link key distribution and computation of the corresponding encryption key.

E3

KC E3 Kmaster EN_RAND, COF,( )=

Master Slave

RANDKmaster E22 RAND1 RAND2, 16,( )=

OVL E22 K RAND, 16,( )= OVL E22 K RAND, 16,( )=C OVL Kmaster⊕=

Kmaster OVL C⊕=

C

Authentication

Page 36: Microsoft Hardware Bluetooth White Paper

762 05 November 2003 Key Management

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 762 of 790

Security Specification

Page 37: Microsoft Hardware Bluetooth White Paper

Encryption 05 November 2003 763

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 763 of 790

Security Specification

4 ENCRYPTION

User information can be protected by encryption of the packet payload; the access code and the packet header shall never be encrypted. The encryption of the payload shall be carried out with a stream cipher called E0 that shall be re-synchronized for every payload. The overall principle is shown in Figure 4.1 on page 763.

The stream cipher system E0 shall consist of three parts:

• the first part performs initialization (generation of the payload key). The pay-load key generator shall combine the input bits in an appropriate order and shall shift them into the four LFSRs used in the key stream generator.

• the second part generates the key stream bits this shall use a method derived from the summation stream cipher generator attributable to Massey and Rueppel. The second part is the main part of the cipher system, as it will also be used for initialization.

• the third part performs encryption and decryption.

The Massey and Rueppel method has been thoroughly investigated, and there exist good estimates of its strength with respect to presently known methods for cryptanalysis. Although the summation generator has weaknesses that can be used in correlation attacks, the high re-synchronization frequency will dis-rupt such attacks.

Figure 4.1: Stream ciphering for Bluetooth with E0.

generatorKey stream z

plain text/cipher text

cipher text/ plain text

address

generator

payload key

payload key

clock

Kc

RAND

Page 38: Microsoft Hardware Bluetooth White Paper

764 05 November 2003 Encryption

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 764 of 790

Security Specification

4.1 ENCRYPTION KEY SIZE NEGOTIATION

Each device implementing the baseband specification shall have a parameter defining the maximal allowed key length, (number of octets in the key). For each application using encryption, a number shall be defined indicating the smallest acceptable key size for that particular application. Before generating the encryption key, the devices involved shall negotiate to decide the key size to use.

The master shall send a suggested value, , to the slave. Initially, the sug-gested value shall be set to . If , and, the slave supports the suggested length, the slave shall acknowledge and this value shall be the length of the encryption key for this link. However, if both conditions are not ful-filled, the slave shall send a new proposal, , to the master. This value shall be the largest among all supported lengths less than the previous master suggestion. Then, the master shall perform the corresponding test on the slave suggestion. This procedure shall be repeated until a key length agreement is reached, or, one device aborts the negotiation. An abort may be caused by lack of support for and all smaller key lengths, or if in one of the devices. In case of an abort link encryption can not be employed.

The possibility of a failure in setting up a secure link is an unavoidable conse-quence of letting the application decide whether to accept or reject a suggested key size. However, this is a necessary precaution. Otherwise a fraudulent device could enforce a weak protection on a link by claiming a small maximum key size.

4.2 ENCRYPTION OF BROADCAST MESSAGES

There may be three settings for the baseband regarding encryption:

1. No encryption. This is the default setting. No messages are encrypted

2. Point-to-point only encryption. Broadcast messages are not encrypted. This may be enabled either during the connection establishment procedure or after the connection has been established.

3. Point-to-point and broadcast encryption. All messages are encrypted. This may be enabled after the connection has been established only. This setting should not be enabled unless all affected links share the same master link key as well as the same EN_RAND value, both used in generating the encryption key.

Lmax 1 Lmax 16≤ ≤,

Lmin

LsugM( )

LmaxM( ) Lmin

S( ) LsugM( )≤

LsugS( ) Lsug

M( )<

Lsug Lsug Lmin<

Page 39: Microsoft Hardware Bluetooth White Paper

Encryption 05 November 2003 765

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 765 of 790

Security Specification

4.3 ENCRYPTION CONCEPT

For the encryption routine, a stream cipher algorithm is used in which ciphering bits are bit-wise modulo-2 added to the data stream to be sent over the air interface. The payload is ciphered after the CRC bits are appended, but, prior to the FEC encoding.

Each packet payload shall be ciphered separately. The cipher algorithm uses the master Bluetooth device address (BD_ADDR), 26 bits of the master real-time clock (CLK 26-1) and the encryption key as input, see Figure 4.2 on page 766 (where it is assumed that device A is the master).

The encryption key KC is derived from the current link key, COF, and a random number, EN_RANDA (see Section 6.4 on page 783). The random number shall be issued by the master before entering encryption mode. Note that EN_RANDA is publicly known since it is transmitted as plain text over the air.

Within the algorithm, the encryption key is modified into another key denoted . The maximum effective size of this key shall be factory preset and may be set to any multiple of eight between one and sixteen (8-128 bits). The procedure for deriving the key is described in Section 4.5 on page 769.

The real-time clock is incremented for each slot. The algorithm shall be re-initialized at the start of each new packet (i.e. for Master-to-Slave as well as for Slave-to-Master transmission). By using CLK26-1 at least one bit is changed between two transmissions. Thus, a new keystream is generated after each re-initialization. For packets covering more than a single slot, the Bluetooth clock as found in the first slot shall be used for the entire packet.

The encryption algorithm generates a binary keystream, , which shall be modulo-2 added to the data to be encrypted. The cipher is symmetric; decryption shall be performed in exactly the same way using the same key as used for encryption.

Broadcast traffic Individually addressed traffic

No encryption No encryption

No encryption Encryption,

Encryption, Encryption,

Table 4.1: Possible encryption modes for a slave in possession of a master key.

Kmaster

Kmaster Kmaster

E0

KC

E0 KC

K′C

E0

E0 Kcipher

Page 40: Microsoft Hardware Bluetooth White Paper

766 05 November 2003 Encryption

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 766 of 790

Security Specification

Figure 4.2: Functional description of the encryption procedure

4.4 ENCRYPTION ALGORITHM

The system uses linear feedback shift registers (LFSRs) whose output is com-bined by a simple finite state machine (called the summation combiner) with 16 states. The output of this state machine is the key stream sequence, or, during initialization phase, the randomized initial start value. The algorithm uses an encryption key , a 48-bit Bluetooth address, the master clock bits CLK26-1, and a 128-bit RAND value. Figure 4.3 on page 767 shows the setup.

There are four LFSRs (LFSR1,...,LFSR4) of lengths , , , and, , with feedback polynomials as specified in Table 4.2 on page 767. The total length of the registers is 128. These polynomials are all primitive. The Hamming weight of all the feedback polynomials is chosen to be five − a rea-sonable trade-off between reducing the number of required XOR gates in the hardware implementation and obtaining good statistical properties of the gen-erated sequences.

dataB-A

dataA-B

Kcipher Kcipher

E0

E0

Device BDevice A (master)

data

clockA

Kc

BD_ADDRA

clockA

BD_ADDRA

EN_RANDA

Kc

KC

L1 25= L2 31= L3 33=

L4 39=

Page 41: Microsoft Hardware Bluetooth White Paper

Encryption 05 November 2003 767

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 767 of 790

Security Specification

Figure 4.3: Concept of the encryption engine.

Let denote the symbol of LFSRi. The value is derived from the four-tuple using the following equation:

(EQ 6)

where the sum is over the integers. Thus can take the values 0,1,2,3, or 4. The output of the summation generator is obtained by the following equations:

(EQ 7)

feedback weight

1 25 5

2 31 5

3 33 5

4 39 5

Table 4.2: The four primitive feedback polynomials.

LFSR1

LFSR2

LFSR3

LFSR4

initi

al v

alue

s x1t

x2t

x3t

x4t

c0t

Encryption Stream Zt

Summation Combiner Logic

+

XOR

+ /2

21

3

2

2

3 2

T1

T2

blend

z-1

z-1

ct

ct+1

st+1

yt

XOR

2

2

x1t

x2t

x3t

x4t

i Li fi t( )

t25 t20 t12 t8 1+ + + +

t31 t24 t16 t12 1+ + + +

t33 t28 t24 t4 1+ + + +

t39 t36 t28 t4 1+ + + +

xti tth yt

xt1 … xt

4, ,

yt xti

i 1=

4

∑= ,

yt

zt xt1 xt

2 xt3 xt

4 ct0⊕ ⊕ ⊕ ⊕ 0 1,{ },∈=

Page 42: Microsoft Hardware Bluetooth White Paper

768 05 November 2003 Encryption

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 768 of 790

Security Specification

(EQ 8)

(EQ 9)

where and are two different linear bijections over GF(4). Suppose GF(4) is generated by the irreducible polynomial , and let be a zero of this polynomial in GF(4). The mappings and are now defined as:

The elements of GF(4) can be written as binary vectors. This is summarized in Table 4.3.

Since the mappings are linear, they can be implemented using XOR gates; i.e.

4.4.1 The operation of the cipher

Figure 4.4 on page 768 gives an overview of the operation in time. The encryp-tion algorithm shall run through the initialization phase before the start of trans-mission or reception of a new packet. Thus, for multislot packets the cipher is initialized using the clock value of the first slot in the multislot sequence.

Figure 4.4: Overview of the operation of the encryption engine. Between each start of a packet (TX or RX), the LFSRs are re-initialized.

00 00 00

01 01 11

10 10 01

11 11 10

Table 4.3: The mappings T1 and T2.

st 1+ st 1+1 st 1+

0,( ) yt ct+

2-------------- 0 1 2 3, , ,{ },∈= =

ct 1+ ct 1+1 ct 1+

0,( ) st 1+ T1 ct[ ] T2 ct 1–[ ],⊕ ⊕= =

T1 .[ ] T2 .[ ]

x2 x 1+ + αT1 T2

T1: GF 4( ) GF 4( )→

x x|→

T2: GF 4( ) GF 4( )→

x α 1+( )x.|→

x T1 x[ ] T2 x[ ]

T1: x1 x0,( ) x1 x0,( ),|→

T2: x1 x0,( ) x0 x1 x0⊕,( ).|→

Page 43: Microsoft Hardware Bluetooth White Paper

Encryption 05 November 2003 769

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 769 of 790

Security Specification

4.5 LFSR INITIALIZATION

The key stream generator is loaded with an initial value for the four LFSRs (in total 128 bits) and the 4 bits that specify the values of and . The 132 bit initial value is derived from four inputs by using the key stream generator. The input parameters are the key , a 128-bit random number RAND, a 48-bit Bluetooth device address, and the 26 master clock bits CLK26-1.

The effective length of the encryption key may vary between 8 and 128 bits. Note that the actual key length as obtained from is 128 bits. Then, within , the key length may be reduced by a modulo operation between and a poly-nomial of desired degree. After reduction, the result is encoded with a block code in order to distribute the starting states more uniformly. The operation shall be as defined in (EQ 10) on page 770.

When the encryption key has been created the LFSRs are loaded with their ini-tial values. Then, 200 stream cipher bits are created by operating the genera-tor. Of these bits, the last 128 are fed back into the key stream generator as an initial value of the four LFSRs. The values of and are kept. From this point on, when clocked the generator produces the encryption (decryption) sequence which is bitwise XORed to the transmitted (received) payload data.

In the following, octet i of a binary sequence is . Bit 0 of is the LSB. Then, the LSB of corresponds to bit of the sequence , the MSB of

is bit of . For instance, bit 24 of the Bluetooth device address is the LSB of BD_ADDR[3].

The details of the initialization shall be as follows:

1. Create the encryption key to use from the 128-bit secret key and the 128-bit publicly known EN_RAND. Let , be the

clock cycles (time)

Init Encrypt/Decrypt Encrypt/DecryptInit

Master → Slave Slave → Master

c0 c 1–

KC

E3 E0

KC

ct ct 1–

X X i[ ] XX i[ ] 8i X

X i[ ] 8i 7+ X

KCL 1 L 16≤ ≤,

Page 44: Microsoft Hardware Bluetooth White Paper

770 05 November 2003 Encryption

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 770 of 790

Security Specification

effective key length in number of octets. The resulting encryption key is :

(EQ 10)

where and . The polynomials are defined in Table 4.4.

2. Shift the 3 inputs , the Bluetooth device address, the clock, and the six-bit constant 111001 into the LFSRs. In total, 208 bits are shifted in:a) Open all switches shown in Figure 4.5 on page 771;b) Arrange inputs bits as shown in Figure 4.5; Set the content of all

shift register elements to zero. Set . c) Start shifting bits into the LFSRs. The rightmost bit at each level of

Figure 4.5 is the first bit to enter the corresponding LFSR.d) When the first input bit at level i reaches the rightmost position of

LFSRi, close the switch of this LFSR.e) At (when the switch of LFSR4 is closed), reset both blend

registers ; Up to this point, the content of and has been of no concern. However, their content will now be

used in computing the output sequence.f) From now on output symbols are generated. The remaining input

bits are continuously shifted into their corresponding shift registers. When the last bit has been shifted in, the shift register is clocked with input = 0;

Note: When finished, LFSR1 has effectively clocked 30 times with feedback closed, LFSR2 has clocked 24 times, LFSR3 has clocked 22 times, and LFSR4 has effectively clocked 16 times with feedback closed.

3. To mix initial data, continue to clock until 200 symbols have been produced with all switches closed ( );

4. Keep blend registers and , make a parallel load of the last 128 generated bits into the LFSRs according to Figure 4.6 at ;

After the parallel load in item 4, the blend register contents shall be updated for each subsequent clock.

deg deg

1 [8] 00000000 00000000 00000000 0000011d [119] 00e275a0 abd218d4 cf928b9b bf6cb08f

2 [16] 00000000 00000000 00000000 0001003f [112] 0001e3f6 3d7659b3 7f18c258 cff6efef

3 [24] 00000000 00000000 00000000 010000db [104] 000001be f66c6c3a b1030a5a 1919808b

4 [32] 00000000 00000000 00000001 000000af [96] 00000001 6ab89969 de17467f d3736ad9

Table 4.4: Polynomials used when creating K’c. . 1

K'C

K'C x( ) g2L( ) x( ) KC x( ) mod g1

L( ) x( )( ),=

deg g1L( ) x( )( ) 8L= deg g2

L( ) x( )( ) 128 8L–≤

K'C

t 0=

t 39=c39 c39 1– 0= = ct

ct 1–

t 239=

ct ct 1–t 240=

L g1L( ) g2

L( )

Page 45: Microsoft Hardware Bluetooth White Paper

Encryption 05 November 2003 771

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 771 of 790

Security Specification

In Figure 4.5, all bits are shifted into the LFSRs, starting with the least signifi-cant bit (LSB). For instance, from the third octet of the address, BD_ADDR[2], first BD_ADDR16 is entered, followed by BD_ADDR17, etc. Furthermore, CL0 corresponds to CLK1,..., CL25 corresponds to CLK26.

Note that the output symbols are taken from the positions 24, 24, 32, and 32 for LFSR1, LFSR2,LFSR3, and LFSR4, respectively (counting the leftmost position as number 1).

Figure 4.5: Arranging the input to the LFSRs.

5 [40] 00000000 00000000 00000100 00000039 [88] 00000000 01630632 91da50ec 55715247

6 [48] 00000000 00000000 00010000 00000291 [77] 00000000 00002c93 52aa6cc0 54468311

7 [56] 00000000 00000000 01000000 00000095 [71] 00000000 000000b3 f7fffce2 79f3a073

8 [64] 00000000 00000001 00000000 0000001b [63] 00000000 00000000 a1ab815b c7ec8025

9 [72] 00000000 00000100 00000000 00000609 [49] 00000000 00000000 0002c980 11d8b04d

10 [80] 00000000 00010000 00000000 00000215 [42] 00000000 00000000 0000058e 24f9a4bb

11 [88] 00000000 01000000 00000000 0000013b [35] 00000000 00000000 0000000c a76024d7

12 [96] 00000001 00000000 00000000 000000dd [28] 00000000 00000000 00000000 1c9c26b9

13 [104] 00000100 00000000 00000000 0000049d [21] 00000000 00000000 00000000 0026d9e3

14 [112] 00010000 00000000 00000000 0000014f [14] 00000000 00000000 00000000 00004377

15 [120] 01000000 00000000 00000000 000000e7 [7] 00000000 00000000 00000000 00000089

16 [128] 1 00000000 00000000 00000000 00000000 [0] 00000000 00000000 00000000 00000001

1. All polynomials are in hexadecimal notation. The LSB is in the rightmost position.

deg deg

Table 4.4: Polynomials used when creating K’c. . 1

L g1L( ) g2

L( )

xti i, 1 … 4, ,=

= CLCL ...CL[0]

= CLCL ...CL[0]L

U

3 0

7 4

CL24

CL[0]L

CL25

UCL[0]

X 4

X

X

X 1

2

3

0 0 116 24

24

36

8 12 20

12

24

24

32

32

28

284

4

t

t

t

t

Kc'[0]Kc'[4]Kc'[8]Kc'[12]CL[1]ADR[2]

Kc'[1]Kc'[5]Kc'[9]Kc'[13]ADR[0]ADR[3]

Kc'[2]Kc'[6]Kc'[10]Kc'[14]CL[2]ADR[4]

Kc'[11] Kc'[7] Kc'[3] 1 1 1Kc'[15]ADR[1]ADR[5]

Page 46: Microsoft Hardware Bluetooth White Paper

772 05 November 2003 Encryption

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 772 of 790

Security Specification

In Figure 4.6, the 128 binary output symbols Z0,..., Z127 are arranged in octets denoted Z[0],..., Z[15]. The LSB of Z[0] corresponds to the first of these sym-bols, the MSB of Z[15] is the last output from the generator. These bits shall be loaded into the LFSRs according to the figure. It is a parallel load and no update of the blend registers is done. The first output symbol is generated at the same time. The octets shall be written into the registers with the LSB in the leftmost position (i.e. the opposite of before). For example, Z24 is loaded into position 1 of LFSR4.

Figure 4.6: Distribution of the 128 last generated output symbols within the LFSRs.

4.6 KEY STREAM SEQUENCE

When the initialization is finished, the output from the summation combiner is used for encryption/decryption. The first bit to use shall be the one produced at the parallel load, i.e. at . The circuit shall be run for the entire length of the current payload. Then, before the reverse direction is started, the entire ini-tialization process shall be repeated with updated values on the input parame-ters.

Sample data of the encryption output sequence can be found in [Part G] Sec-tion 1 on page 649. A necessary, but not sufficient, condition for all Bluetooth compliant implementations of encryption is to produce these encryption streams for identical initialization values.

Z[3]

Xt

4

Xt

Xt

Xt

1

2

3

Z[4] Z[8]

Z[5]

Z[13]

Z[9]

Z[14]

Z[10]

Z[11]

Z[0]

Z[12]7-1

Z[6]

Z[7] Z[15]7-1

Z[2]

Z[1]

Z[12]0

Z[15]0

24

24

32

32

24

20128

12 16

4

4

24

28 36

28

t 240=

Page 47: Microsoft Hardware Bluetooth White Paper

Authentication 05 November 2003 773

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 773 of 790

Security Specification

5 AUTHENTICATION

Authentication uses a challenge-response scheme in which a claimant’s knowl-edge of a secret key is checked through a 2-move protocol using symmetric secret keys. The latter implies that a correct claimant/verifier pair share the same secret key, for example K. In the challenge-response scheme the verifier challenges the claimant to authenticate a random input (the challenge), denoted by AU_RANDA, with an authentication code, denoted by , and return the result SRES to the verifier, see Figure 5.1 on page 773. This figure also shows that the input to E1 consists of the tuple AU_RANDA and the Blue-tooth device address (BD_ADDR) of the claimant. The use of this address pre-vents a simple reflection attack1. The secret K shared by devices A and B is the current link key.

Figure 5.1: Challenge-response for the Bluetooth.

The challenge-response scheme for symmetric keys is depicted in Figure 5.2 on page 774.

1. The reflection attack actually forms no threat because all service requests are dealt with on a FIFO bases. When preemption is introduced, this attack is potentially dangerous.

E1

E1 E1

AU_RANDA

BD_ADDRB

Link key

AU_RANDA

BD_ADDRB

SRES’

AU_RANDA

SRES

?=SRES

Verifier (Device A) Claimant (Device B)

Link key

SRES

ACO ACO

Page 48: Microsoft Hardware Bluetooth White Paper

774 05 November 2003 Authentication

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 774 of 790

Security Specification

Figure 5.2: Challenge-response for symmetric key systems.

The verifier is not required to be the master. The application indicates which device has to be authenticated. Some applications only require a one-way authentication. However, some peer-to-peer communications, should use a mutual authentication in which each device is subsequently the challenger (verifier) in two authentication procedures. The LM shall process authentication preferences from the application to determine in which direction(s) the authen-tication(s) takes place. For mutual authentication with the devices of Figure 5.1 on page 773, after device A has successfully authenticated device B, device B could authenticate device A by sending an AU_RANDB (different from the AU_RANDA that device A issued) to device A, and deriving the SRES and SRES’ from the new AU_RANDB, the address of device A, and the link key KAB.

If an authentication is successful the value of ACO as produced by shall be retained.

Verifier(User A)

Claimant(User B, with identity IDB)

RAND

SRESSRES E key IDB RAND, ,( )=

SRES' E key IDB RAND, ,( )=

Check: SRES' SRES=

E1

Page 49: Microsoft Hardware Bluetooth White Paper

Authentication 05 November 2003 775

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 775 of 790

Security Specification

5.1 REPEATED ATTEMPTS

When the authentication attempt fails, a waiting interval shall pass before the verifier will initiate a new authentication attempt to the same claimant, or before it will respond to an authentication attempt initiated by a device claiming the same identity as the failed device. For each subsequent authentication failure with the same Bluetooth device address, the waiting interval shall be increased exponentially. That is, after each failure, the waiting interval before a new attempt can be made, could be for example, twice as long as the waiting inter-val prior to the previous attempt1. The waiting interval shall be limited to a max-imum. The maximum waiting interval depends on the implementation. The waiting time shall exponentially decrease to a minimum when no new failed attempts are made during a certain time period. This procedure prevents an intruder from repeating the authentication procedure with a large number of dif-ferent keys.

To make the system less vulnerable to denial-of-service attacks, the devices should keep a list of individual waiting intervals for each device it has established contact with. The size of this list may be restricted to only contain the N devices with which the most recent contacts have been made. The number N may vary for different devices depending on available memory size and user environment.

1. Another appropriate value larger than 1 may be used.

Page 50: Microsoft Hardware Bluetooth White Paper

776 05 November 2003 Authentication

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 776 of 790

Security Specification

Page 51: Microsoft Hardware Bluetooth White Paper

The Authentication And Key-Generating Functions 05 November 2003 777

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 777 of 790

Security Specification

6 THE AUTHENTICATION AND KEY-GENERATING FUNCTIONS

This section describes the algorithms used for authentication and key genera-tion.

6.1 THE AUTHENTICATION FUNCTION E1

The authentication function is a computationally secure authentication code. uses the encryption function SAFER+. The algorithm is an enhanced version of an existing 64-bit block cipher SAFER-SK128, and it is freely avail-able. In the following discussion, the block cipher will be denoted as the func-tion which maps using a 128-bit key, a 128-bit input to a 128-bit output, i.e.

(EQ 11)

The details of are given in the next section. The function is constructed using as follows

(EQ 12)

where , where is a keyed hash function defined as1,

(EQ 13)

and where

(EQ 14)

is an expansion of the octet word into a 128-bit word. The function is

evaluated twice for each evaluation of . The key for the second use of

(actually ) is offset from as follows2

1. The operator +16 denotes bytewise addition mod 256 of the 16 octets, and the operator ⊕16 denotes bytewise XORing of the 16 octets.

2. The constants are the largest primes below 257 for which 10 is a primitive root.

E1

E1

Ar

Ar: 0 1,{ }128 0 1,{ }128× 0 1,{ }128→

k x×( ) t.|→

Ar E1

Ar

E1: 0 1,{ }128 0 1,{ }128 0 1,{ }48×× 0 1,{ }32 0 1,{ }96×→

K RAND address, ,( ) SRES ACO,( ),|→

SRES Hash K RAND,address 6,,( ) 0 … 3, ,[ ]= Hash

Hash: 0 1,{ }128 0 1,{ }128 0 1,{ }8 L× 6 12,{ }××× 0 1,{ }128→

K I1 I2 L, , ,( ) A'r K̃[ ] E I2 L,( ) Ar K I1,( )⊕16 I1( )+16[ ],( ),|→

E: 0 1,{ }8 L× 6 12,{ }× 0 1,{ }8 16×→

X 0 … L, , 1–[ ] L,( ) X i(mod L)[ ] for i = 0...15( ),|→

L X Ar

E1 K̃ Ar

A'r K

Page 52: Microsoft Hardware Bluetooth White Paper

778 05 November 2003 The Authentication And Key-Generating

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 778 of 790

Security Specification

(EQ 15)

A data flowchart of the computation of is shown in Figure 6.1 on page 778. is also used to deliver the parameter ACO (Authenticated Ciphering Offset)

that is used in the generation of the ciphering key by , see equations (EQ 3) on page 759 and (EQ 23) on page 783. The value of ACO is formed by the octets 4 through 15 of the output of the hash function defined in (EQ 13) on page 777, i.e.

. (EQ 16)

Figure 6.1: Flow of data for the computation of .

K̃ 0[ ] K 0[ ] 233+( )= mod 256, K̃ 1[ ] K 1[ ] 229,⊕=

K̃ 2[ ] K 2[ ] 223+( )= mod 256, K̃ 3[ ] K 3[ ] 193,⊕=

K̃ 4[ ] K 4[ ] 179+( )= mod 256, K̃ 5[ ] K 5[ ] 167,⊕=

K̃ 6[ ] K 6[ ] 149+( )= mod 256, K̃ 7[ ] K 7[ ] 131,⊕=

K̃ 8{ } K 8[ ] 233,⊕= K̃ 9[ ] K 9[ ] 229+( )= mod 256,K̃ 10[ ] K 10[ ] 223,⊕= K̃ 11[ ] K 11[ ] 193+( )= mod 256,K̃ 12[ ] K 12[ ] 179,⊕= K̃ 13[ ] K 13[ ] 167+( )= mod 256,K̃ 14[ ] K 14[ ] 149,⊕= K̃ 15[ ] K 15[ ] 131+( )= mod 256.

E1

E1

E3

ACO Hash K RAND,address 6,,( ) 4 … 15, ,[ ]=

+16offset

RAND

E

32 96

SRES ACO

address

+16

xor

add

xor :16 8-bit xor-ings

add: 16 8-bit additions mod 256

Ar

A'r

K

48

128

L 6=

E1

Page 53: Microsoft Hardware Bluetooth White Paper

The Authentication And Key-Generating Functions 05 November 2003 779

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 779 of 790

Security Specification

6.2 THE FUNCTIONS Ar AND A’r

The function is identical to SAFER+. It consists of a set of 8 layers, (each layer is called a round) and a parallel mechanism for generating the sub keys

, , which are the round keys to be used in each round. The function will produce a 128-bit result from a 128-bit random input string and a 128-bit key. Besides the function , a slightly modified version referred to as

is used in which the input of round 1 is added to the input of round 3. This is done to make the modified version non-invertible and prevents the use of (especially in ) as an encryption function. See Figure 6.2 on page 780 for details.

6.2.1 The round computations

The computations in each round are a composition of encryption with a round key, substitution, encryption with the next round key, and, finally, a Pseudo Hadamard Transform (PHT). The computations in a round shall be as shown in Figure 6.2 on page 780. The sub keys for round are denoted

, , . After the last round is applied identically to all previous odd numbered keys.

6.2.2 The substitution boxes “e” and “l”

In Figure 6.2 on page 780 two boxes are shown, marked “e” and “l”. These boxes implement the same substitutions as are used in SAFER+; i.e. they implement

Their role, as in the SAFER+ algorithm, is to introduce non-linearity.

Ar

Kp j[ ] p 1 2 … 17, , ,=

Ar

A′rA′r

E2x

r r, 1 2 … 8, , ,=

K2r 1– j[ ] K2r j[ ] j 0 1 … 15, , ,= K17 j[ ]

e l, : 0 … 255, ,{ } 0 … 255, ,{ },→

e : i 45i (mod 257)( ) (mod 256),|→

l : i j s.t. i|→ e j( ).=

Page 54: Microsoft Hardware Bluetooth White Paper

780 05 November 2003 The Authentication And Key-Generating

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 780 of 790

Security Specification

Figure 6.2: One round in and . The permutation boxes show how input byte indices are mapped onto output byte indices. Thus, position 8 is mapped on position 0 (leftmost), position 11 is mapped on position 1, et cetera.

6.2.3 Key scheduling

In each round, 2 batches of 16 octet-wide keys are needed. These round keys are derived as specified by the key scheduling in SAFER+. Figure 6.3 on page 781 gives an overview of how the round keys are determined. The bias vectors B2, B3, ..., B17 shall be computed according to following equation:

(EQ 17)

e e e e e e e e

PHT PHT PHT PHT PHT PHT

PHT PHT

PHT

PHT PHT

PHT

PHT PHT PHT PHT

PHT PHT PHT PHT PHT PHT PHT PHT

addition mod 256

bitwise XOR

PHT(x,y)= (2x+y mod 256, x+y mod 256)

2rK [0..15]

2r

l l l l l l l l

Only for A’r in round 3

A input[0..15]

128

128

PERMUTE: 8 11 12 15 2 1 6 5 10 9 14 13 0 7 4 3

PERMUTE: 8 11 12 15 2 1 6 5 10 9 14 13 0 7 4 3

PERMUTE: 8 11 12 15 2 1 6 5 10 9 14 13 0 7 4 3

PHT PHT PHT PHT PHT PHT PHT PHT

128 K [0..15]17

128

Only after last round

2r-1K [0..15]

RO

UN

D r

, r=1

,2,..

.,8

60 1 2 3 4 5 7 8 9 10 11 12 13 14 15

2rK [15]K [0]

Ar A'r

Kp j[ ]

Bp i[ ] 45 4517p i 1+ + mod 257( ) mod 257( ) mod 256( ), for i 0 … 15., ,= =

Page 55: Microsoft Hardware Bluetooth White Paper

The Authentication And Key-Generating Functions 05 November 2003 781

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 781 of 790

Security Specification

Figure 6.3: Key scheduling in .

6.3 E2-KEY GENERATION FUNCTION FOR AUTHENTICATION

The key used for authentication shall be derived through the procedure that is shown in Figure 6.4 on page 783. The figure shows two modes of operation for the algorithm. In the first mode, produces a 128-bit kink key, , using a 128-bit RAND value and a 48-bit address. This mode shall be utilized when creating unit keys and combination keys. In the second mode, produces a 128-bit link key, , using a 128-bit RAND value and an octet user PIN. The second mode shall be used to create the initialization key, and also when a master key is to be generated.

When the initialization key is generated, the PIN is augmented with the BD_ADDR, see Section 3.2.1 on page 756 for which address to use. The aug-mentation shall always start with the least significant octet of the address immediately following the most significant octet of the PIN. Since the maximum length of the PIN used in the algorithm cannot exceed 16 octets, it is possible that not all octets of BD_ADDR will be used.

1

16

K

16

160 1 14

0 1514

0 1 1514

0 1 1514

0 1 1514

+

+

+15

1

...

bit-by-bitmodulo two

1,2,3,...,15,16

2,3,4,...,16,0

Select Bytes

16,0,1,...,13,14

16

16

160,1,2,...,14,15

16

B

B

B

2

3

17

K

K

2

3

17

K

Rotate each octet left by 3 bit positions

Rotate each octet left by 3 bit positions

Rotate each octet left by 3 bit positions

128 bit Key grouped in 16 octets

sum octets

Select octets

Select octets

Select octets

Ar

E21 K

E22

K L

Page 56: Microsoft Hardware Bluetooth White Paper

782 05 November 2003 The Authentication And Key-Generating

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 782 of 790

Security Specification

This key generating algorithm again exploits the cryptographic function. for mode 1 (denoted ) is computed according to following equations:

(EQ 18)

where (for mode 1)

(EQ 19)

Let be the number of octets in the user PIN. The augmenting is defined by

(EQ 20)

Then, in mode 2, (denoted ) is

(EQ 21)

where

(EQ 22)

and is the number of octets in PIN’.

E2

E21

E21: 0 1,{ }128 0 1,{ }48× 0 1,{ }128→

RAND address,( ) A'r X Y,( )|→

X RAND 0…14[ ] RAND 15[ ] 6⊕( )∪=

Y address i (mod 6)[ ]

i 0=

15

∪=

⎩⎪⎪⎨⎪⎪⎧

L

PIN'PIN 0…L 1–[ ] BD_ADDR 0… 5 15 L–,{ }min[ ],∪

PIN 0…L 1–[ ],⎩⎨⎧

=L 16,<L 16,=

E2 E22

E22: 0 1,{ }8L' 0 1,{ }128 1 2 … 16, , ,{ }×× 0 1,{ }128→

PIN' RAND, L′,( ) A'r X Y,( )|→

X PIN' i (mod L')[ ]

i 0=

15

∪= ,

Y RAND 0…14[ ] RAND 15[ ] L'⊕( ),∪=⎩⎪⎪⎨⎪⎪⎧

L' min 16 L 6+,{ }=

Page 57: Microsoft Hardware Bluetooth White Paper

The Authentication And Key-Generating Functions 05 November 2003 783

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 783 of 790

Security Specification

Figure 6.4: Key generating algorithm and its two modes. Mode 1 is used for unit and combination keys, while mode 2 is used for and .

6.4 E3-KEY GENERATION FUNCTION FOR ENCRYPTION

The ciphering key used by shall be generated by . The function is constructed using as follows

(EQ 23)

where is the hash function as defined by (EQ 13) on page 777. The key length produced is 128 bits. However, before use within , the encryption key

is shortened to the correct encryption key length, as described in Section 4.5 on page 769. A block scheme of is depicted in Figure 6.5.

The value of COF is determined as specified by equation (EQ 3) on page 759.

Figure 6.5: Generation of the encryption key.

E22

RAND

PIN’

128

8L’

Key

128

E21

RAND

BD_ADDR

128

48

Key

128

Mode 1 Mode 2L’

E2

Kinit Kmaster

KC E0 E3 E3

A'r

E3: 0 1,{ }128 0 1,{ }128 0 1,{ }96×× 0 1,{ }128→

K RAND COF,,( ) Hash K RAND COF, 12, ,( )|→

HashE0

KC

E3

E3

EN_RAND128

128

128

96

KC

Link key

COF

Page 58: Microsoft Hardware Bluetooth White Paper

784 05 November 2003 The Authentication And Key-Generating

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 784 of 790

Security Specification

Page 59: Microsoft Hardware Bluetooth White Paper

List of Figures 05 November 2003 785

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 785 of 790

Security Specification

7 LIST OF FIGURES

Figure 3.1: Generation of unit key. When the unit key has been exchanged, the initialization key is discarded in both devices. ...................757

Figure 3.2: Generating a combination key. The old link key (K) is discarded after the exchange of a new combination key has succeeded 758

Figure 3.3: Master link key distribution and computation of the corresponding encryption key. ........................................................................761

Figure 4.1: Stream ciphering for Bluetooth with E0. ..................................763Figure 4.2: Functional description of the encryption procedure ................766Figure 4.3: Concept of the encryption engine. ..........................................767Figure 4.4: Overview of the operation of the encryption engine. Between each

start of a packet (TX or RX), the LFSRs are re-initialized. ........ 768Figure 4.5: Arranging the input to the LFSRs. ...........................................771Figure 4.6: Distribution of the 128 last generated output symbols within the

LFSRs. ....................................................................................772Figure 5.1: Challenge-response for the Bluetooth. ....................................773Figure 5.2: Challenge-response for symmetric key systems. ....................774Figure 6.1: Flow of data for the computation of . ...................................778Figure 6.2: One round in and . The permutation boxes show how input byte

indices are mapped onto output byte indices. Thus, position 8 is mapped on position 0 (leftmost), position 11 is mapped on position 1, et cetera. ................................................................780

Figure 6.3: Key scheduling in . ..............................................................781

Figure 6.4: Key generating algorithm and its two modes. Mode 1 is used for unit and combination keys, while mode 2 is used for and

. ....................................................................................783Figure 6.5: Generation of the encryption key. ...........................................783

E1

Ar

E2

Kinit

Kmaster

Page 60: Microsoft Hardware Bluetooth White Paper

786 05 November 2003 List of Figures

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 786 of 790

Security Specification

Page 61: Microsoft Hardware Bluetooth White Paper

List of Tables 05 November 2003 787

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 787 of 790

Security Specification

8 LIST OF TABLES

Table 1.1: Entities used in authentication and encryption procedures......749Table 4.1: Possible encryption modes for a slave in possession of a master

key............................................................................................765Table 4.2: The four primitive feedback polynomials..................................767Table 4.3: The mappings T1 and T2. ..........................................................768Table 4.4: Polynomials used when creating K’c. . ...................................770

Page 62: Microsoft Hardware Bluetooth White Paper

788 05 November 2003 List of Tables

BLUETOOTH SPECIFICATION Version 1.2 [vol 2] page 788 of 790

Security Specification

Page 63: Microsoft Hardware Bluetooth White Paper

Bluetooth® and Microsoft® Desktop Products 17

Related Links

See the following resources for additional information:

• "Bluetooth.org - The Official Bluetooth Membership Site" at https://www.bluetooth.org

• "The Official Bluetooth® Wireless Info Site" at http://www.bluetooth.com

• Compatibility of Bluetooth devices with Microsoft® products at http://www.microsoft.com/hardware/bluetooth