aboutsummaryrefslogtreecommitdiffstats
path: root/api/direct_bt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-12-10 12:49:29 +0100
committerSven Gothel <[email protected]>2020-12-10 12:49:29 +0100
commit718878201d3171f68cbede2722e8b6a372c4e610 (patch)
treead792153d7e243d210aa982f79d13e0b4053c981 /api/direct_bt
parentab5f9da859b8c30f3b93f7b167bf87bd808f4d44 (diff)
MgmtLongTermKeyInfo: Add toSMPLongTermKeyInfo() conversion
Diffstat (limited to 'api/direct_bt')
-rw-r--r--api/direct_bt/MgmtTypes.hpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/api/direct_bt/MgmtTypes.hpp b/api/direct_bt/MgmtTypes.hpp
index 66844551..e0ed1f84 100644
--- a/api/direct_bt/MgmtTypes.hpp
+++ b/api/direct_bt/MgmtTypes.hpp
@@ -42,6 +42,7 @@
#include "HCIComm.hpp"
#include "DBTTypes.hpp"
+#include "SMPTypes.hpp"
namespace direct_bt {
@@ -227,6 +228,42 @@ namespace direct_bt {
", ltk "+jau::bytesHexString(ltk.data, 0, sizeof(ltk), true /* lsbFirst */, false /* leading0X */)+
"]";
}
+
+ /**
+ * Convert this instance into its platform agnostic SMPLongTermKeyInfo type.
+ */
+ SMPLongTermKeyInfo toSMPLongTermKeyInfo() const noexcept {
+ direct_bt::SMPLongTermKeyInfo res;
+ res.clear();
+ if( master ) {
+ res.properties |= SMPLongTermKeyInfo::Property::RESPONDER;
+ }
+ switch( key_type ) {
+ case MgmtLTKType::NONE:
+ res.clear();
+ break;
+ case MgmtLTKType::UNAUTHENTICATED: // = 0x00, // master ? SMP_LTK : SMP_LTK_SLAVE
+ break;
+ case MgmtLTKType::AUTHENTICATED: // = 0x01, // master ? SMP_LTK : SMP_LTK_SLAVE
+ res.properties |= SMPLongTermKeyInfo::Property::AUTH;
+ break;
+ case MgmtLTKType::UNAUTHENTICATED_P256: // = 0x02, // SMP_LTK_P256
+ res.properties |= SMPLongTermKeyInfo::Property::SC;
+ break;
+ case MgmtLTKType::AUTHENTICATED_P256: // = 0x03, // SMP_LTK_P256
+ res.properties |= SMPLongTermKeyInfo::Property::SC;
+ res.properties |= SMPLongTermKeyInfo::Property::AUTH;
+ break;
+ case MgmtLTKType::DEBUG_P256: // = 0x04, // SMP_LTK_P256_DEBUG
+ res.properties |= SMPLongTermKeyInfo::Property::SC;
+ break;
+ }
+ res.enc_size = enc_size;
+ res.ediv = ediv;
+ res.rand = rand;
+ res.ltk = ltk;
+ return res;
+ }
} );
/**
@@ -1400,7 +1437,7 @@ namespace direct_bt {
/**
* uint8_t store_hint,
- * MgmtLongTermKey key
+ * MgmtLongTermKeyInfo key
*/
class MgmtEvtNewLongTermKey : public MgmtEvent
{