Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
|
Storage for SMP keys including required connection parameter per local adapter and remote device. More...
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 |
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
:
'bd_'
prefix '010203040506'
local EUI48
local adapter address '_'
separator 'C026DA01DAB1'
remote EUI48
remote device address '1'
BDAddressType
'.key'
suffix
Definition at line 75 of file SMPKeyBin.java.
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.
org.direct_bt.SMPKeyBin.SMPKeyBin | ( | ) |
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.
device | the BTDevice from which all required data is derived |
Definition at line 162 of file SMPKeyBin.java.
|
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.
device | the BTDevice from which all required data is derived |
path | the path for the stored SMPKeyBin file. |
verbose_ | set to true to have detailed write processing logged to stderr, otherwise false |
true
if file has been successfully written, otherwise false
. Definition at line 229 of file SMPKeyBin.java.
|
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.
fname | full path of the stored SMPKeyBin file. |
removeInvalidFile | if 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 |
Definition at line 258 of file SMPKeyBin.java.
|
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.
path | directory for the stored SMPKeyBin file. |
device | BTDevice used to derive the filename, see getFilename() |
verbose_ | set to true to have detailed read processing logged to stderr, otherwise false |
Definition at line 282 of file SMPKeyBin.java.
final boolean org.direct_bt.SMPKeyBin.isVersionValid | ( | ) |
final short org.direct_bt.SMPKeyBin.getVersion | ( | ) |
Definition at line 342 of file SMPKeyBin.java.
final boolean org.direct_bt.SMPKeyBin.isSizeValid | ( | ) |
final short org.direct_bt.SMPKeyBin.getSize | ( | ) |
Definition at line 345 of file SMPKeyBin.java.
final long org.direct_bt.SMPKeyBin.getCreationTime | ( | ) |
Returns the creation timestamp in seconds since Unix epoch.
Definition at line 348 of file SMPKeyBin.java.
final BTRole org.direct_bt.SMPKeyBin.getLocalRole | ( | ) |
Return the local adapter BTRole
.
Definition at line 351 of file SMPKeyBin.java.
final BDAddressAndType org.direct_bt.SMPKeyBin.getLocalAddrAndType | ( | ) |
Return the local adapter address.
Definition at line 354 of file SMPKeyBin.java.
final BDAddressAndType org.direct_bt.SMPKeyBin.getRemoteAddrAndType | ( | ) |
Return the remote device address.
Definition at line 357 of file SMPKeyBin.java.
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.
final BTSecurityLevel org.direct_bt.SMPKeyBin.getSecLevel | ( | ) |
final SMPIOCapability org.direct_bt.SMPKeyBin.getIOCap | ( | ) |
Definition at line 366 of file SMPKeyBin.java.
final boolean org.direct_bt.SMPKeyBin.hasLTKInit | ( | ) |
final boolean org.direct_bt.SMPKeyBin.hasIRKInit | ( | ) |
final boolean org.direct_bt.SMPKeyBin.hasCSRKInit | ( | ) |
final boolean org.direct_bt.SMPKeyBin.hasLKInit | ( | ) |
final SMPLongTermKey org.direct_bt.SMPKeyBin.getLTKInit | ( | ) |
final SMPIdentityResolvingKey org.direct_bt.SMPKeyBin.getIRKInit | ( | ) |
final SMPSignatureResolvingKey org.direct_bt.SMPKeyBin.getCSRKInit | ( | ) |
final SMPLinkKey org.direct_bt.SMPKeyBin.getLKInit | ( | ) |
final void org.direct_bt.SMPKeyBin.setLTKInit | ( | final SMPLongTermKey | v | ) |
final void org.direct_bt.SMPKeyBin.setIRKInit | ( | final SMPIdentityResolvingKey | v | ) |
final void org.direct_bt.SMPKeyBin.setCSRKInit | ( | final SMPSignatureResolvingKey | v | ) |
final void org.direct_bt.SMPKeyBin.setLKInit | ( | final SMPLinkKey | v | ) |
final boolean org.direct_bt.SMPKeyBin.hasLTKResp | ( | ) |
final boolean org.direct_bt.SMPKeyBin.hasIRKResp | ( | ) |
final boolean org.direct_bt.SMPKeyBin.hasCSRKResp | ( | ) |
final boolean org.direct_bt.SMPKeyBin.hasLKResp | ( | ) |
final SMPLongTermKey org.direct_bt.SMPKeyBin.getLTKResp | ( | ) |
final SMPIdentityResolvingKey org.direct_bt.SMPKeyBin.getIRKResp | ( | ) |
final SMPSignatureResolvingKey org.direct_bt.SMPKeyBin.getCSRKResp | ( | ) |
final SMPLinkKey org.direct_bt.SMPKeyBin.getLKResp | ( | ) |
final void org.direct_bt.SMPKeyBin.setLTKResp | ( | final SMPLongTermKey | v | ) |
final void org.direct_bt.SMPKeyBin.setIRKResp | ( | final SMPIdentityResolvingKey | v | ) |
final void org.direct_bt.SMPKeyBin.setCSRKResp | ( | final SMPSignatureResolvingKey | v | ) |
final void org.direct_bt.SMPKeyBin.setLKResp | ( | final SMPLinkKey | v | ) |
final void org.direct_bt.SMPKeyBin.setVerbose | ( | final boolean | v | ) |
final boolean org.direct_bt.SMPKeyBin.isValid | ( | ) |
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.
|
static |
Returns the base filename, see SMPKeyBin
API doc for naming scheme.
Definition at line 455 of file SMPKeyBin.java.
|
static |
|
static |
Definition at line 462 of file SMPKeyBin.java.
final String org.direct_bt.SMPKeyBin.getFilename | ( | final String | path | ) |
Definition at line 465 of file SMPKeyBin.java.
final String org.direct_bt.SMPKeyBin.toString | ( | ) |
|
static |
Definition at line 555 of file SMPKeyBin.java.
|
static |
Definition at line 558 of file SMPKeyBin.java.
final boolean org.direct_bt.SMPKeyBin.remove | ( | final String | path | ) |
Definition at line 561 of file SMPKeyBin.java.
final boolean org.direct_bt.SMPKeyBin.write | ( | final String | path, |
final boolean | overwrite | ||
) |
final boolean org.direct_bt.SMPKeyBin.read | ( | final String | fname | ) |
Definition at line 664 of file SMPKeyBin.java.
|
static |
Definition at line 833 of file SMPKeyBin.java.
|
static |
Definition at line 76 of file SMPKeyBin.java.