nl::Weave::WeaveSecurityManager

摘要

构造函数和析构函数

WeaveSecurityManager(void)

公共类型

KeyErrorMsgRcvdFunct)(uint16_t keyId, uint8_t encType, uint32_t messageId, uint64_t peerNodeId, WEAVE_ERROR keyErr) typedef
void(*
关键错误消息处理函数的类型。
KeyExportCompleteFunct)(WeaveSecurityManager *sm, WeaveConnection *con, void *reqState, uint32_t exportedKeyId, const uint8_t *exportedKey, uint16_t exportedKeyLen) typedef
void(*
密钥导出协议完整处理功能的类型。
KeyExportErrorFunct)(WeaveSecurityManager *sm, WeaveConnection *con, void *reqState, WEAVE_ERROR localErr, StatusReport *statusReport) typedef
void(*
密钥导出协议错误处理函数的类型。
SessionErrorFunct)(WeaveSecurityManager *sm, WeaveConnection *con, void *reqState, WEAVE_ERROR localErr, uint64_t peerNodeId, StatusReport *statusReport) typedef
void(*
SessionEstablishedFunct)(WeaveSecurityManager *sm, WeaveConnection *con, void *reqState, uint16_t sessionKeyId, uint64_t peerNodeId, uint8_t encType) typedef
void(*
State 枚举

公共属性

CASEUseKnownECDHKey
bool
ExchangeManager
FabricState
IdleSessionTimeout
uint32_t
InitiatorAllowedCASEConfigs
uint8_t
InitiatorAllowedCASECurves
uint8_t
InitiatorAllowedKeyExportConfigs
uint8_t
InitiatorCASEConfig
uint32_t
InitiatorCASECurveId
uint32_t
InitiatorKeyExportConfig
uint8_t
OnKeyErrorMsgRcvd
按键错误回调函数。
OnSessionError
SessionErrorFunct
OnSessionEstablished
SessionEstablishedFunct
ResponderAllowedCASEConfigs
uint8_t
ResponderAllowedCASECurves
uint8_t
ResponderAllowedKeyExportConfigs
uint8_t
SessionEstablishTimeout
uint32_t
State
uint8_t
mCASEEngine
mKeyExport
mPASEEngine
mStartKeyExport_OnComplete
密钥导出协议完成回调函数。
mStartKeyExport_OnError
密钥导出协议错误回调函数。
mStartKeyExport_ReqState
void *
mStartSecureSession_OnComplete
SessionEstablishedFunct
mStartSecureSession_OnError
SessionErrorFunct
mStartSecureSession_ReqState
void *
mTAKEEngine

公共函数

CancelSessionEstablishment(void *reqState)
取消正在进行的会话建立。
Init(WeaveExchangeManager & aExchangeMgr, System::Layer & aSystemLayer)
IsKeyError(WEAVE_ERROR err)
bool
检查指定的 Weave 错误代码是否为关键错误代码之一。
OnEncryptedMsgRcvd(uint16_t sessionKeyId, uint64_t peerNodeId, uint8_t encType)
void
ReleaseKey(uint64_t peerNodeId, uint16_t keyId)
void
释放消息加密密钥预留。
ReserveKey(uint64_t peerNodeId, uint16_t keyId)
void
为消息加密密钥进行预留。
SendKeyErrorMsg(WeaveMessageInfo *rcvdMsgInfo, const IPPacketInfo *rcvdMsgPacketInfo, WeaveConnection *con, WEAVE_ERROR keyErr)
发送密钥错误消息。
SetCASEAuthDelegate(WeaveCASEAuthDelegate *delegate)
void
SetKeyExportDelegate(WeaveKeyExportDelegate *delegate)
void
SetTAKEAuthDelegate(WeaveTAKEChallengerAuthDelegate *delegate)
void
SetTAKETokenAuthDelegate(WeaveTAKETokenAuthDelegate *delegate)
void
Shutdown(void)
StartCASESession(WeaveConnection *con, uint64_t peerNodeId, const IPAddress & peerAddr, uint16_t peerPort, WeaveAuthMode requestedAuthMode, void *reqState, SessionEstablishedFunct onComplete, SessionErrorFunct onError, WeaveCASEAuthDelegate *authDelegate, uint64_t terminatingNodeId)
调用此方法可建立新的 CASE 会话或查找现有的 CASE 会话。
StartKeyExport(WeaveConnection *con, uint64_t peerNodeId, const IPAddress & peerAddr, uint16_t peerPort, uint32_t keyId, bool signMessage, void *reqState, KeyExportCompleteFunct onComplete, KeyExportErrorFunct onError, WeaveKeyExportDelegate *keyExportDelegate)
StartPASESession(WeaveConnection *con, WeaveAuthMode requestedAuthMode, void *reqState, SessionEstablishedFunct onComplete, SessionErrorFunct onError, const uint8_t *pw, uint16_t pwLen)
调用此方法来建立安全的 PASE 会话。
StartTAKESession(WeaveConnection *con, WeaveAuthMode requestedAuthMode, void *reqState, SessionEstablishedFunct onComplete, SessionErrorFunct onError, bool encryptAuthPhase, bool encryptCommPhase, bool timeLimitedIK, bool sendChallengerId, WeaveTAKEChallengerAuthDelegate *authDelegate)
调用此方法来建立安全 TAKE 会话。

公共类型

KeyErrorMsgRcvdFunct

void(* KeyErrorMsgRcvdFunct)(uint16_t keyId, uint8_t encType, uint32_t messageId, uint64_t peerNodeId, WEAVE_ERROR keyErr)

关键错误消息处理函数的类型。

具体说明
参数
[in] keyId
加密密钥导致对等端发出密钥错误消息响应。
[in] encType
keyId 关联的加密类型。
[in] messageId
Weave 消息的标识符导致对等方发出关键错误响应。
[in] peerNodeId
发送密钥错误消息的 Weave 节点的标识符。
[in] keyErr
从对等设备收到的错误代码。

KeyExportCompleteFunct

void(* KeyExportCompleteFunct)(WeaveSecurityManager *sm, WeaveConnection *con, void *reqState, uint32_t exportedKeyId, const uint8_t *exportedKey, uint16_t exportedKeyLen)

密钥导出协议完整处理功能的类型。

具体说明
参数
[in] sm
指向 WeaveSecurityManager 对象的指针。
[in] con
指向 WeaveConnection 对象的指针。
[in] reqState
指向密钥导出请求者状态的指针。
[in] keyId
已导出的密钥 ID。
[in] exportedKey
指向导出的密钥的指针。
[in] exportedKeyLen
对导出的密钥长度的引用。

KeyExportErrorFunct

void(* KeyExportErrorFunct)(WeaveSecurityManager *sm, WeaveConnection *con, void *reqState, WEAVE_ERROR localErr, StatusReport *statusReport)

密钥导出协议错误处理函数的类型。

具体说明
参数
[in] sm
指向 WeaveSecurityManager 对象的指针。
[in] con
指向 WeaveConnection 对象的指针。
[in] reqState
指向密钥导出请求者状态的指针。
[in] localErr
在密钥导出协议期间遇到的 WEAVE_ERROR。
[in] statusReport
如果从对等方收到错误状态,则为指向 StatusReport 对象的指针。

SessionErrorFunct

void(* SessionErrorFunct)(WeaveSecurityManager *sm, WeaveConnection *con, void *reqState, WEAVE_ERROR localErr, uint64_t peerNodeId, StatusReport *statusReport)

SessionEstablishedFunct

void(* SessionEstablishedFunct)(WeaveSecurityManager *sm, WeaveConnection *con, void *reqState, uint16_t sessionKeyId, uint64_t peerNodeId, uint8_t encType)

状态

 State

公共属性

CASEUseKnownECDHKey

bool CASEUseKnownECDHKey

ExchangeManager

WeaveExchangeManager * ExchangeManager

FabricState

WeaveFabricState * FabricState

IdleSessionTimeout

uint32_t IdleSessionTimeout

InitiatorAllowedCASEConfigs

uint8_t InitiatorAllowedCASEConfigs

InitiatorAllowedCASECurves

uint8_t InitiatorAllowedCASECurves

InitiatorAllowedKeyExportConfigs

uint8_t InitiatorAllowedKeyExportConfigs

InitiatorCASEConfig

uint32_t InitiatorCASEConfig

InitiatorCASECurveId

uint32_t InitiatorCASECurveId

InitiatorKeyExportConfig

uint8_t InitiatorKeyExportConfig

OnKeyErrorMsgRcvd

KeyErrorMsgRcvdFunct OnKeyErrorMsgRcvd

按键错误回调函数。

收到关键错误消息时调用此函数。

OnSessionError

SessionErrorFunct OnSessionError

OnSessionEstablished

SessionEstablishedFunct OnSessionEstablished

ResponderAllowedCASEConfigs

uint8_t ResponderAllowedCASEConfigs

ResponderAllowedCASECurves

uint8_t ResponderAllowedCASECurves

ResponderAllowedKeyExportConfigs

uint8_t ResponderAllowedKeyExportConfigs

SessionEstablishTimeout

uint32_t SessionEstablishTimeout

状态

uint8_t State

mCASEEngine

WeaveCASEEngine * mCASEEngine

mKeyExport

WeaveKeyExport * mKeyExport

mPASEEngine

WeavePASEEngine * mPASEEngine

mStartKeyExport_OnComplete

KeyExportCompleteFunct mStartKeyExport_OnComplete

密钥导出协议完成回调函数。

当密钥导出过程完成时,将调用此函数。

mStartKeyExport_OnError

KeyExportErrorFunct mStartKeyExport_OnError

密钥导出协议错误回调函数。

当在密钥导出过程中出现错误时,将调用此函数。

mStartKeyExport_ReqState

void * mStartKeyExport_ReqState

mStartSecureSession_OnComplete

SessionEstablishedFunct mStartSecureSession_OnComplete

mStartSecureSession_OnError

SessionErrorFunct mStartSecureSession_OnError

mStartSecureSession_ReqState

void * mStartSecureSession_ReqState

mTAKEEngine

WeaveTAKEEngine * mTAKEEngine

公共函数

CancelSessionEstablishment

WEAVE_ERROR CancelSessionEstablishment(
  void *reqState
)

取消正在进行的会话建立。

具体说明
参数
[in] reqState
与启动会话时应用提供的值匹配的指针值。
返回值
WEAVE_NO_ERROR
如果找到并取消了匹配的正在进行中的会话建立。
WEAVE_ERROR_INCORRECT_STATE
如果没有正在进行的会话建立,或者正在进行的会话与提供的请求状态指针不匹配。

Init

WEAVE_ERROR Init(
  WeaveExchangeManager & aExchangeMgr,
  System::Layer & aSystemLayer
)

IsKeyError

bool IsKeyError(
  WEAVE_ERROR err
)

检查指定的 Weave 错误代码是否为关键错误代码之一。

可调用此函数来确定是否应将密钥错误消息发送给在解码期间未能找到正确密钥的消息的发起者。

具体说明
参数
[in] err
Weave 错误代码。
返回值
true
如果指定的 Weave 错误代码为关键错误,
false
否则。

OnEncryptedMsgRcvd

void OnEncryptedMsgRcvd(
  uint16_t sessionKeyId,
  uint64_t peerNodeId,
  uint8_t encType
)

ReleaseKey

void ReleaseKey(
  uint64_t peerNodeId,
  uint16_t keyId
)

释放消息加密密钥预留。

释放之前放置在消息加密密钥上的预留。

对于放置在特定键上的每个预留,不得多次调用 ReleaseKey() 方法。

此方法接受任何形式的密钥 ID,包括 None。未命名实际键的键 ID 会被忽略。

具体说明
参数
[in] peerNodeId
与密钥共享的对等设备的 Weave 节点 ID。
[in] keyId
应释放其预留的密钥的 ID。

ReserveKey

void ReserveKey(
  uint64_t peerNodeId,
  uint16_t keyId
)

为消息加密密钥进行预留。

密钥预留用于表明特定密钥正被使用且应保留。请注意,对密钥进行预留并不能保证该密钥不会被显式操作(例如,接收 KeyError 消息)移除。

对于放置在特定键上的每个预留,必须进行相应的 ReleaseKey() 调用。

此方法接受任何形式的密钥 ID,包括 None。未命名实际键的键 ID 会被忽略。

具体说明
参数
[in] peerNodeId
与密钥共享的对等设备的 Weave 节点 ID。
[in] keyId
要预留的键的 ID。

SendKeyErrorMsg

WEAVE_ERROR SendKeyErrorMsg(
  WeaveMessageInfo *rcvdMsgInfo,
  const IPPacketInfo *rcvdMsgPacketInfo,
  WeaveConnection *con,
  WEAVE_ERROR keyErr
)

发送密钥错误消息。

当收到的 Weave 消息由于密钥错误而解码失败时,系统会调用此函数。

具体说明
参数
[in] rcvdMsgInfo
指向已接收 Weave 消息的消息信息的指针。
[in] rcvdMsgPacketInfo
指向已接收的 Weave 消息的 IPPacketInfo 对象的指针。
[in] con
指向 WeaveConnection 对象的指针。
[in] keyErr
Weave 密钥错误代码。
返回值
WEAVE_ERROR_NO_MEMORY
如果无法为新交换上下文或新消息缓冲区分配内存。
WEAVE_ERROR_BUFFER_TOO_SMALL
如果缓冲区过小
WEAVE_NO_ERROR
如果方法成功。

SetCASEAuthDelegate

void SetCASEAuthDelegate(
  WeaveCASEAuthDelegate *delegate
)

SetKeyExportDelegate

void SetKeyExportDelegate(
  WeaveKeyExportDelegate *delegate
)

SetTAKEAuthDelegate

void SetTAKEAuthDelegate(
  WeaveTAKEChallengerAuthDelegate *delegate
)

SetTAKETokenAuthDelegate

void SetTAKETokenAuthDelegate(
  WeaveTAKETokenAuthDelegate *delegate
)

关停

WEAVE_ERROR Shutdown(
  void
)

StartCASESession

WEAVE_ERROR StartCASESession(
  WeaveConnection *con,
  uint64_t peerNodeId,
  const IPAddress & peerAddr,
  uint16_t peerPort,
  WeaveAuthMode requestedAuthMode,
  void *reqState,
  SessionEstablishedFunct onComplete,
  SessionErrorFunct onError,
  WeaveCASEAuthDelegate *authDelegate,
  uint64_t terminatingNodeId
)

调用此方法可建立新的 CASE 会话或查找现有的 CASE 会话。

具体说明
参数
[in] con
指向 WeaveConnection 对象的指针。
[in] peerNodeId
对等方的节点标识符。
[in] peerAddr
对等节点的 IP 地址。
[in] peerPort
对等节点的端口。
[in] requestedAuthMode
对等方应通过身份验证的方式进行身份验证。它必须是 CASE 身份验证模式之一。
[in] reqState
指向请求者状态的指针。
[in] onComplete
指向回调函数的指针,一旦建立了请求的安全会话,系统就会调用该函数。
[in] onError
指向回调函数的指针,如果请求的会话建立失败,将调用该函数。
[in] authDelegate
指向 CASE 身份验证委托对象的指针。
[in] terminatingNodeId
会话终止节点的节点标识符。此输入不同于 kNodeIdNotSpecified(表示请求了共享安全会话)。
返回值
WEAVE_NO_ERROR
成功时。

StartKeyExport

WEAVE_ERROR StartKeyExport(
  WeaveConnection *con,
  uint64_t peerNodeId,
  const IPAddress & peerAddr,
  uint16_t peerPort,
  uint32_t keyId,
  bool signMessage,
  void *reqState,
  KeyExportCompleteFunct onComplete,
  KeyExportErrorFunct onError,
  WeaveKeyExportDelegate *keyExportDelegate
)

StartPASESession

WEAVE_ERROR StartPASESession(
  WeaveConnection *con,
  WeaveAuthMode requestedAuthMode,
  void *reqState,
  SessionEstablishedFunct onComplete,
  SessionErrorFunct onError,
  const uint8_t *pw,
  uint16_t pwLen
)

调用此方法来建立安全的 PASE 会话。

具体说明
参数
[in] con
指向 WeaveConnection 对象的指针。
[in] requestedAuthMode
对等方应通过身份验证的方式进行身份验证。它必须是 PASE 身份验证模式之一。
[in] reqState
指向请求者状态的指针。
[in] onComplete
指向回调函数的指针,一旦建立了请求的安全会话,系统就会调用该函数。
[in] onError
指向回调函数的指针,如果请求的会话建立失败,将调用该函数。
[in] pw
指向 PASE 密钥密码的指针。
[in] pwLen
PASE 密钥密码的长度。
返回值
WEAVE_NO_ERROR
成功时。

StartTAKESession

WEAVE_ERROR StartTAKESession(
  WeaveConnection *con,
  WeaveAuthMode requestedAuthMode,
  void *reqState,
  SessionEstablishedFunct onComplete,
  SessionErrorFunct onError,
  bool encryptAuthPhase,
  bool encryptCommPhase,
  bool timeLimitedIK,
  bool sendChallengerId,
  WeaveTAKEChallengerAuthDelegate *authDelegate
)

调用此方法来建立安全 TAKE 会话。

具体说明
参数
[in] con
指向 WeaveConnection 对象的指针。
[in] requestedAuthMode
对等方应通过身份验证的方式进行身份验证。该身份验证模式必须是“TAKE”中的一种。
[in] reqState
指向请求者状态的指针。
[in] onComplete
指向回调函数的指针,一旦建立了请求的安全会话,系统就会调用该函数。
[in] onError
指向回调函数的指针,如果请求的会话建立失败,将调用该函数。
[in] encryptAuthPhase
指示协议身份验证阶段是否应加密的布尔值标记。
[in] encryptCommPhase
指示协议通信阶段是否应加密的布尔值标记。
[in] timeLimitedIK
一个布尔标记,指示识别密钥 (IK) 是否有时间限制。
[in] sendChallengerId
一个布尔标记,指示是否应在消息中包含挑战者标识。如果不包含,则将 Weave 节点 ID 值用作挑战者 ID。
[in] authDelegate
指向 TAKE 挑战者身份验证委托对象的指针。
返回值
WEAVE_NO_ERROR
成功时。

WeaveSecurityManager

 WeaveSecurityManager(
  void
)