Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
org.direct_bt.SMPKeyBin Class Reference

Storage for SMP keys including required connection parameter per local adapter and remote device. More...

Collaboration diagram for org.direct_bt.SMPKeyBin:

Public Member Functions

 SMPKeyBin ()
 
 SMPKeyBin (final BTRole localRole_, final BDAddressAndType localAddress_, final BDAddressAndType remoteAddress_, final BTSecurityLevel sec_level_, final SMPIOCapability io_cap_)
 
final long getCreationTime ()
 Returns the creation timestamp in seconds since Unix epoch. More...
 
final SMPSignatureResolvingKey getCSRKInit ()
 
final SMPSignatureResolvingKey getCSRKResp ()
 
final String getFileBasename ()
 Returns the base filename, see SMPKeyBin API doc for naming scheme. More...
 
final String getFilename (final String path)
 
final SMPIOCapability getIOCap ()
 
final SMPIdentityResolvingKey getIRKInit ()
 
final SMPIdentityResolvingKey getIRKResp ()
 
final SMPLinkKey getLKInit ()
 
final SMPLinkKey getLKResp ()
 
final BDAddressAndType getLocalAddrAndType ()
 Return the local adapter address. More...
 
final BTRole getLocalRole ()
 Return the local adapter BTRole. More...
 
final SMPLongTermKey getLTKInit ()
 
final SMPLongTermKey getLTKResp ()
 
final BDAddressAndType getRemoteAddrAndType ()
 Return the remote device address. More...
 
final BTSecurityLevel getSecLevel ()
 
final short getSize ()
 
final short getVersion ()
 
final boolean hasCSRKInit ()
 
final boolean hasCSRKResp ()
 
final boolean hasIRKInit ()
 
final boolean hasIRKResp ()
 
final boolean hasLKInit ()
 
final boolean hasLKResp ()
 
final boolean hasLTKInit ()
 
final boolean hasLTKResp ()
 
final boolean isSizeValid ()
 
final boolean isValid ()
 
final boolean isVersionValid ()
 
final boolean read (final String fname)
 
final boolean remove (final String path)
 
final void setCSRKInit (final SMPSignatureResolvingKey v)
 
final void setCSRKResp (final SMPSignatureResolvingKey v)
 
final void setIRKInit (final SMPIdentityResolvingKey v)
 
final void setIRKResp (final SMPIdentityResolvingKey v)
 
final void setLKInit (final SMPLinkKey v)
 
final void setLKResp (final SMPLinkKey v)
 
final void setLTKInit (final SMPLongTermKey v)
 
final void setLTKResp (final SMPLongTermKey v)
 
final void setVerbose (final boolean v)
 
final String toString ()
 
final boolean uses_SC ()
 Return whether Secure Connection (SC) is being used via LTK keys. More...
 
final boolean write (final String path, final boolean overwrite)
 

Static Public Member Functions

static SMPKeyBin create (final BTDevice device)
 Create a new SMPKeyBin instance based upon given BTDevice's BTSecurityLevel, SMPPairingState, PairingMode and LTK keys. More...
 
static boolean createAndWrite (final BTDevice device, final String path, final boolean verbose_)
 Create a new SMPKeyBin instance on the fly based upon given BTDevice's BTSecurityLevel, SMPPairingState, PairingMode and LTK keys. More...
 
final static String getFileBasename (final BDAddressAndType localAddress_, final BDAddressAndType remoteAddress_)
 Returns the base filename, see SMPKeyBin API doc for naming scheme. More...
 
final static String getFilename (final String path, final BDAddressAndType localAddress_, final BDAddressAndType remoteAddress_)
 
final static String getFilename (final String path, final BTDevice remoteDevice)
 
static void main (final String[] args)
 
static SMPKeyBin read (final String fname, final boolean verbose_)
 Create a new SMPKeyBin instance based upon stored file denoted by fname. More...
 
static SMPKeyBin read (final String path, final BTDevice device, final boolean verbose_)
 Create a new SMPKeyBin instance based upon the given BTDevice's matching filename, see SMPKeyBin API doc for filename naming scheme. More...
 
final static boolean remove (final String path, final BDAddressAndType localAddress_, final BDAddressAndType remoteAddress_)
 
final static boolean remove (final String path, final BTDevice remoteDevice_)
 

Static Public Attributes

static final short VERSION = (short)0b0101010101010101 + (short)6
 

Detailed Description

Storage for SMP keys including required connection parameter per local adapter and remote device.

File format version 5.

Storage for a device's BDAddressAndType, its security connection setup BTSecurityLevel + SMPIOCapability and optionally the initiator and responder LTK, CSRK and LK within one file.

Since the LTK, CSRK and LK are optionally set depending on their availability per initiator and responder, implementation supports mixed mode for certain devices. E.g. LTK responder key only etc.

Data is stored in ByteOrder#LITTLE_ENDIAN format, native to Bluetooth.

Filename as retrieved by getFileBasename(BDAddressAndType) and getFileBasename() has the following form bd_010203040506_C026DA01DAB11.key:

Definition at line 75 of file SMPKeyBin.java.

Constructor & Destructor Documentation

◆ SMPKeyBin() [1/2]

org.direct_bt.SMPKeyBin.SMPKeyBin ( final BTRole  localRole_,
final BDAddressAndType  localAddress_,
final BDAddressAndType  remoteAddress_,
final BTSecurityLevel  sec_level_,
final SMPIOCapability  io_cap_ 
)

Definition at line 286 of file SMPKeyBin.java.

◆ SMPKeyBin() [2/2]

org.direct_bt.SMPKeyBin.SMPKeyBin ( )

Definition at line 315 of file SMPKeyBin.java.

Here is the caller graph for this function:

Member Function Documentation

◆ create()

static SMPKeyBin org.direct_bt.SMPKeyBin.create ( final BTDevice  device)
static

Create a new SMPKeyBin instance based upon given BTDevice's BTSecurityLevel, SMPPairingState, PairingMode and LTK keys.

Returned SMPKeyBin shall be tested if valid via SMPKeyBin#isValid(), whether the retrieved data from BTDevice is consistent and hence having BTDevice is a well connected state.

Parameters
devicethe BTDevice from which all required data is derived
Returns
a valid SMPKeyBin instance if properly connected, otherwise an invalid instance.
See also
BTDevice
isValid()

Definition at line 162 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ createAndWrite()

static boolean org.direct_bt.SMPKeyBin.createAndWrite ( final BTDevice  device,
final String  path,
final boolean  verbose_ 
)
static

Create a new SMPKeyBin instance on the fly based upon given BTDevice's BTSecurityLevel, SMPPairingState, PairingMode and LTK keys.

If valid, instance is stored to a file denoted by path and BTDevice#getAddressAndType().

If BTDevice#getPairingMode() is PairingMode#PRE_PAIRED, an existing file will not be overwritten. Otherwise, a new key is assumed and an existing file shall be overwritten.

Method returns false if resulting SMPKeyBin is not SMPKeyBin#isValid(). Otherwise, method returns the SMPKeyBin#write(String) result.

Parameters
devicethe BTDevice from which all required data is derived
paththe path for the stored SMPKeyBin file.
verbose_set to true to have detailed write processing logged to stderr, otherwise false
Returns
true if file has been successfully written, otherwise false.
See also
BTDevice
create(BTDevice)
#write(String)
isValid()

Definition at line 229 of file SMPKeyBin.java.

◆ read() [1/3]

static SMPKeyBin org.direct_bt.SMPKeyBin.read ( final String  fname,
final boolean  verbose_ 
)
static

Create a new SMPKeyBin instance based upon stored file denoted by fname.

Returned SMPKeyBin shall be tested if valid via SMPKeyBin#isValid(), whether the read() operation was successful and data is consistent.

If file is invalid, it is removed.

Parameters
fnamefull path of the stored SMPKeyBin file.
removeInvalidFileif true and file is invalid, remove it. Otherwise keep it alive.
verbose_set to true to have detailed read processing logged to stderr, otherwise false
Returns
valid SMPKeyBin instance if file exist and read successfully, otherwise invalid SMPKeyBin instance.
See also
isValid()
#read(String, String)

Definition at line 258 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ read() [2/3]

static SMPKeyBin org.direct_bt.SMPKeyBin.read ( final String  path,
final BTDevice  device,
final boolean  verbose_ 
)
static

Create a new SMPKeyBin instance based upon the given BTDevice's matching filename, see SMPKeyBin API doc for filename naming scheme.

Returned SMPKeyBin shall be tested if valid via SMPKeyBin::isValid(), whether the read() operation was successful and data is consistent.

If file is invalid, it is removed.

Parameters
pathdirectory for the stored SMPKeyBin file.
deviceBTDevice used to derive the filename, see getFilename()
verbose_set to true to have detailed read processing logged to stderr, otherwise false
Returns
valid SMPKeyBin instance if file exist and read successfully, otherwise invalid SMPKeyBin instance.
See also
getFilename()
isValid()
read()

Definition at line 282 of file SMPKeyBin.java.

◆ isVersionValid()

final boolean org.direct_bt.SMPKeyBin.isVersionValid ( )

Definition at line 341 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ getVersion()

final short org.direct_bt.SMPKeyBin.getVersion ( )

Definition at line 342 of file SMPKeyBin.java.

◆ isSizeValid()

final boolean org.direct_bt.SMPKeyBin.isSizeValid ( )

Definition at line 344 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ getSize()

final short org.direct_bt.SMPKeyBin.getSize ( )

Definition at line 345 of file SMPKeyBin.java.

◆ getCreationTime()

final long org.direct_bt.SMPKeyBin.getCreationTime ( )

Returns the creation timestamp in seconds since Unix epoch.

Definition at line 348 of file SMPKeyBin.java.

◆ getLocalRole()

final BTRole org.direct_bt.SMPKeyBin.getLocalRole ( )

Return the local adapter BTRole.

Definition at line 351 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ getLocalAddrAndType()

final BDAddressAndType org.direct_bt.SMPKeyBin.getLocalAddrAndType ( )

Return the local adapter address.

Definition at line 354 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ getRemoteAddrAndType()

final BDAddressAndType org.direct_bt.SMPKeyBin.getRemoteAddrAndType ( )

Return the remote device address.

Definition at line 357 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ uses_SC()

final boolean org.direct_bt.SMPKeyBin.uses_SC ( )

Return whether Secure Connection (SC) is being used via LTK keys.

Definition at line 360 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ getSecLevel()

final BTSecurityLevel org.direct_bt.SMPKeyBin.getSecLevel ( )

Definition at line 365 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ getIOCap()

final SMPIOCapability org.direct_bt.SMPKeyBin.getIOCap ( )

Definition at line 366 of file SMPKeyBin.java.

◆ hasLTKInit()

final boolean org.direct_bt.SMPKeyBin.hasLTKInit ( )

Definition at line 368 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ hasIRKInit()

final boolean org.direct_bt.SMPKeyBin.hasIRKInit ( )

Definition at line 369 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ hasCSRKInit()

final boolean org.direct_bt.SMPKeyBin.hasCSRKInit ( )

Definition at line 370 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ hasLKInit()

final boolean org.direct_bt.SMPKeyBin.hasLKInit ( )

Definition at line 371 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ getLTKInit()

final SMPLongTermKey org.direct_bt.SMPKeyBin.getLTKInit ( )

Definition at line 372 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ getIRKInit()

final SMPIdentityResolvingKey org.direct_bt.SMPKeyBin.getIRKInit ( )

Definition at line 373 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ getCSRKInit()

final SMPSignatureResolvingKey org.direct_bt.SMPKeyBin.getCSRKInit ( )

Definition at line 374 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ getLKInit()

final SMPLinkKey org.direct_bt.SMPKeyBin.getLKInit ( )

Definition at line 375 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ setLTKInit()

final void org.direct_bt.SMPKeyBin.setLTKInit ( final SMPLongTermKey  v)

Definition at line 376 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ setIRKInit()

final void org.direct_bt.SMPKeyBin.setIRKInit ( final SMPIdentityResolvingKey  v)

Definition at line 381 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ setCSRKInit()

final void org.direct_bt.SMPKeyBin.setCSRKInit ( final SMPSignatureResolvingKey  v)

Definition at line 386 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ setLKInit()

final void org.direct_bt.SMPKeyBin.setLKInit ( final SMPLinkKey  v)

Definition at line 391 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ hasLTKResp()

final boolean org.direct_bt.SMPKeyBin.hasLTKResp ( )

Definition at line 397 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ hasIRKResp()

final boolean org.direct_bt.SMPKeyBin.hasIRKResp ( )

Definition at line 398 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ hasCSRKResp()

final boolean org.direct_bt.SMPKeyBin.hasCSRKResp ( )

Definition at line 399 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ hasLKResp()

final boolean org.direct_bt.SMPKeyBin.hasLKResp ( )

Definition at line 400 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ getLTKResp()

final SMPLongTermKey org.direct_bt.SMPKeyBin.getLTKResp ( )

Definition at line 401 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ getIRKResp()

final SMPIdentityResolvingKey org.direct_bt.SMPKeyBin.getIRKResp ( )

Definition at line 402 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ getCSRKResp()

final SMPSignatureResolvingKey org.direct_bt.SMPKeyBin.getCSRKResp ( )

Definition at line 403 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ getLKResp()

final SMPLinkKey org.direct_bt.SMPKeyBin.getLKResp ( )

Definition at line 404 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ setLTKResp()

final void org.direct_bt.SMPKeyBin.setLTKResp ( final SMPLongTermKey  v)

Definition at line 405 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ setIRKResp()

final void org.direct_bt.SMPKeyBin.setIRKResp ( final SMPIdentityResolvingKey  v)

Definition at line 410 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ setCSRKResp()

final void org.direct_bt.SMPKeyBin.setCSRKResp ( final SMPSignatureResolvingKey  v)

Definition at line 415 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ setLKResp()

final void org.direct_bt.SMPKeyBin.setLKResp ( final SMPLinkKey  v)

Definition at line 420 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ setVerbose()

final void org.direct_bt.SMPKeyBin.setVerbose ( final boolean  v)

Definition at line 426 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ isValid()

final boolean org.direct_bt.SMPKeyBin.isValid ( )

Definition at line 428 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ getFileBasename() [1/2]

final String org.direct_bt.SMPKeyBin.getFileBasename ( )

Returns the base filename, see SMPKeyBin API doc for naming scheme.

Definition at line 448 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ getFileBasename() [2/2]

final static String org.direct_bt.SMPKeyBin.getFileBasename ( final BDAddressAndType  localAddress_,
final BDAddressAndType  remoteAddress_ 
)
static

Returns the base filename, see SMPKeyBin API doc for naming scheme.

Definition at line 455 of file SMPKeyBin.java.

◆ getFilename() [1/3]

final static String org.direct_bt.SMPKeyBin.getFilename ( final String  path,
final BDAddressAndType  localAddress_,
final BDAddressAndType  remoteAddress_ 
)
static

Definition at line 459 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ getFilename() [2/3]

final static String org.direct_bt.SMPKeyBin.getFilename ( final String  path,
final BTDevice  remoteDevice 
)
static

Definition at line 462 of file SMPKeyBin.java.

◆ getFilename() [3/3]

final String org.direct_bt.SMPKeyBin.getFilename ( final String  path)

Definition at line 465 of file SMPKeyBin.java.

◆ toString()

final String org.direct_bt.SMPKeyBin.toString ( )

Definition at line 470 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ remove() [1/3]

final static boolean org.direct_bt.SMPKeyBin.remove ( final String  path,
final BTDevice  remoteDevice_ 
)
static

Definition at line 555 of file SMPKeyBin.java.

◆ remove() [2/3]

final static boolean org.direct_bt.SMPKeyBin.remove ( final String  path,
final BDAddressAndType  localAddress_,
final BDAddressAndType  remoteAddress_ 
)
static

Definition at line 558 of file SMPKeyBin.java.

◆ remove() [3/3]

final boolean org.direct_bt.SMPKeyBin.remove ( final String  path)

Definition at line 561 of file SMPKeyBin.java.

◆ write()

final boolean org.direct_bt.SMPKeyBin.write ( final String  path,
final boolean  overwrite 
)

Definition at line 565 of file SMPKeyBin.java.

Here is the caller graph for this function:

◆ read() [3/3]

final boolean org.direct_bt.SMPKeyBin.read ( final String  fname)

Definition at line 664 of file SMPKeyBin.java.

◆ main()

static void org.direct_bt.SMPKeyBin.main ( final String[]  args)
static

Definition at line 833 of file SMPKeyBin.java.

Member Data Documentation

◆ VERSION

final short org.direct_bt.SMPKeyBin.VERSION = (short)0b0101010101010101 + (short)6
static

Definition at line 76 of file SMPKeyBin.java.


The documentation for this class was generated from the following file: