Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 61a50c1

Browse files
author
Jay Logue
authored
Merge pull request #51 from openweave/feature/jay/key-export-delegate-enhancements
WeaveKeyExportDelegate Enhancements
2 parents b758187 + 15fda5c commit 61a50c1

16 files changed

+1075
-575
lines changed

build/config/standalone/WeaveProjectConfig.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,6 @@
5959

6060
#define WEAVE_CONFIG_LEGACY_CASE_AUTH_DELEGATE 0
6161

62+
#define WEAVE_CONFIG_LEGACY_KEY_EXPORT_DELEGATE 0
63+
6264
#endif /* WEAVEPROJECTCONFIG_H */

src/lib/core/WeaveConfig.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,16 @@
15221522
#define WEAVE_CONFIG_ENABLE_KEY_EXPORT_RESPONDER 1
15231523
#endif // WEAVE_CONFIG_ENABLE_KEY_EXPORT_RESPONDER
15241524

1525+
/**
1526+
* @def WEAVE_CONFIG_LEGACY_KEY_EXPORT_DELEGATE
1527+
*
1528+
* @brief
1529+
* Enable use of the legacy WeaveKeyExportDelegate interface.
1530+
*/
1531+
#ifndef WEAVE_CONFIG_LEGACY_KEY_EXPORT_DELEGATE
1532+
#define WEAVE_CONFIG_LEGACY_KEY_EXPORT_DELEGATE 1
1533+
#endif
1534+
15251535
/**
15261536
* @def WEAVE_CONFIG_REQUIRE_AUTH
15271537
*

src/lib/core/WeaveSecurityMgr.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2206,7 +2206,7 @@ void WeaveSecurityManager::HandleKeyExportMessageInitiator(ExchangeContext *ec,
22062206
PacketBuffer::Free(msgBuf);
22072207
msgBuf = NULL;
22082208

2209-
err = secMgr->SendKeyExportRequest(newConfig, secMgr->mKeyExport->KeyId, secMgr->mKeyExport->SignMessages);
2209+
err = secMgr->SendKeyExportRequest(newConfig, secMgr->mKeyExport->KeyId(), secMgr->mKeyExport->SignMessages());
22102210
SuccessOrExit(err);
22112211

22122212
break;
@@ -2216,7 +2216,7 @@ void WeaveSecurityManager::HandleKeyExportMessageInitiator(ExchangeContext *ec,
22162216
uint16_t exportedKeyLen;
22172217
uint8_t exportedKey[kWeaveFabricSecretSize];
22182218

2219-
err = secMgr->mKeyExport->ProcessKeyExportResponse(msgBuf->Start(), msgBuf->DataLength(), pktInfo, msgInfo,
2219+
err = secMgr->mKeyExport->ProcessKeyExportResponse(msgBuf->Start(), msgBuf->DataLength(), msgInfo,
22202220
exportedKey, sizeof(exportedKey), exportedKeyLen, exportedKeyId);
22212221
SuccessOrExit(err);
22222222

@@ -2364,7 +2364,7 @@ void WeaveSecurityManager::HandleKeyExportRequest(ExchangeContext *ec, const IPP
23642364
keyExport.SetAllowedConfigs(ResponderAllowedKeyExportConfigs);
23652365

23662366
// Process key export request message.
2367-
err = keyExport.ProcessKeyExportRequest(msgBuf->Start(), msgBuf->DataLength(), pktInfo, msgInfo);
2367+
err = keyExport.ProcessKeyExportRequest(msgBuf->Start(), msgBuf->DataLength(), msgInfo);
23682368

23692369
// Free the received message buffer so that it can be reused to send the outgoing message.
23702370
PacketBuffer::Free(msgBuf);
@@ -2373,11 +2373,11 @@ void WeaveSecurityManager::HandleKeyExportRequest(ExchangeContext *ec, const IPP
23732373
// Check if reconfiguration was requested.
23742374
if (err == WEAVE_ERROR_KEY_EXPORT_RECONFIGURE_REQUIRED)
23752375
{
2376-
err = SendKeyExportResponse(keyExport, kMsgType_KeyExportReconfigure);
2376+
err = SendKeyExportResponse(keyExport, kMsgType_KeyExportReconfigure, msgInfo);
23772377
}
23782378
else if (err == WEAVE_NO_ERROR)
23792379
{
2380-
err = SendKeyExportResponse(keyExport, kMsgType_KeyExportResponse);
2380+
err = SendKeyExportResponse(keyExport, kMsgType_KeyExportResponse, msgInfo);
23812381
}
23822382
SuccessOrExit(err);
23832383

@@ -2397,7 +2397,7 @@ void WeaveSecurityManager::HandleKeyExportRequest(ExchangeContext *ec, const IPP
23972397
}
23982398

23992399
__attribute__((noinline))
2400-
WEAVE_ERROR WeaveSecurityManager::SendKeyExportResponse(WeaveKeyExport& keyExport, uint8_t msgType)
2400+
WEAVE_ERROR WeaveSecurityManager::SendKeyExportResponse(WeaveKeyExport& keyExport, uint8_t msgType, const WeaveMessageInfo *msgInfo)
24012401
{
24022402
WEAVE_ERROR err = WEAVE_NO_ERROR;
24032403
PacketBuffer *msgBuf = NULL;
@@ -2412,7 +2412,7 @@ WEAVE_ERROR WeaveSecurityManager::SendKeyExportResponse(WeaveKeyExport& keyExpor
24122412
if (msgType == kMsgType_KeyExportReconfigure)
24132413
err = keyExport.GenerateKeyExportReconfigure(msgBuf->Start(), msgBuf->AvailableDataLength(), dataLen);
24142414
else if (msgType == kMsgType_KeyExportResponse)
2415-
err = keyExport.GenerateKeyExportResponse(msgBuf->Start(), msgBuf->AvailableDataLength(), dataLen);
2415+
err = keyExport.GenerateKeyExportResponse(msgBuf->Start(), msgBuf->AvailableDataLength(), dataLen, msgInfo);
24162416
else
24172417
err = WEAVE_ERROR_INVALID_MESSAGE_TYPE;
24182418
SuccessOrExit(err);

src/lib/core/WeaveSecurityMgr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ class NL_DLL_EXPORT WeaveSecurityManager
499499

500500
void HandleKeyExportRequest(ExchangeContext *ec, const IPPacketInfo *pktInfo, const WeaveMessageInfo *msgInfo, PacketBuffer *msgBuf);
501501
WEAVE_ERROR SendKeyExportRequest(uint8_t keyExportConfig, uint32_t keyId, bool signMessage);
502-
WEAVE_ERROR SendKeyExportResponse(WeaveKeyExport& keyExport, uint8_t msgType);
502+
WEAVE_ERROR SendKeyExportResponse(WeaveKeyExport& keyExport, uint8_t msgType, const WeaveMessageInfo *msgInfo);
503503
static void HandleKeyExportMessageInitiator(ExchangeContext *ec, const IPPacketInfo *pktInfo, const WeaveMessageInfo *msgInfo,
504504
uint32_t profileId, uint8_t msgType, PacketBuffer *msgBuf);
505505
void HandleKeyExportError(WEAVE_ERROR err, PacketBuffer *statusReportMsgBuf);

0 commit comments

Comments
 (0)