Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
Damian-Nordic committed Jan 19, 2023
1 parent ad3bfc5 commit 2fbda3f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/controller/java/AndroidDeviceControllerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew(
setupParams.operationalCredentialsDelegate = opCredsIssuer;
setupParams.defaultCommissioner = &wrapper->mAutoCommissioner;
initParams.fabricIndependentStorage = wrapperStorage;
initParams.sessionKeystore = &mSessionKeystore;
initParams.sessionKeystore = &wrapper->mSessionKeystore;

wrapper->mGroupDataProvider.SetStorageDelegate(wrapperStorage);
wrapper->mGroupDataProvider.SetSessionKeystore(initParams.sessionKeystore);
Expand Down
18 changes: 12 additions & 6 deletions src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ @interface MTRDeviceControllerFactory ()
@property (readonly) MTRPersistentStorageDelegateBridge * persistentStorageDelegateBridge;
@property (readonly) MTRAttestationTrustStoreBridge * attestationTrustStoreBridge;
@property (readonly) MTROTAProviderDelegateBridge * otaProviderDelegateBridge;
@property (readonly) Crypto::DefaultSessionKeystore * sessionKeystore;
// We use TestPersistentStorageDelegate just to get an in-memory store to back
// our group data provider impl. We initialize this store correctly on every
// controller startup, so don't need to actually persist it.
Expand Down Expand Up @@ -112,6 +113,11 @@ - (instancetype)init
_chipWorkQueue = DeviceLayer::PlatformMgrImpl().GetWorkQueue();
_controllerFactory = &DeviceControllerFactory::GetInstance();

_sessionKeystore = new chip::Crypto::DefaultSessionKeystore();
if ([self checkForInitError:(_sessionKeystore != nullptr) logMsg:kErrorSessionKeystoreInit]) {
return nil;
}

_groupStorageDelegate = new chip::TestPersistentStorageDelegate();
if ([self checkForInitError:(_groupStorageDelegate != nullptr) logMsg:kErrorGroupProviderInit]) {
return nil;
Expand All @@ -123,13 +129,8 @@ - (instancetype)init
return nil;
}

_sessionKeystore = new chip::Crypto::DefaultSessionKeystore();
if ([self checkForInitError:(_sessionKeystore != nullptr) logMsg:kErrorSessionKeystoreInit]) {
return nil;
}

_groupDataProvider->SetStorageDelegate(_groupStorageDelegate);
_groupDataProvider->SetStorageDelegate(_sessionKeystore);
_groupDataProvider->SetSessionKeystore(_sessionKeystore);
CHIP_ERROR errorCode = _groupDataProvider->Init();
if ([self checkForInitError:(CHIP_NO_ERROR == errorCode) logMsg:kErrorGroupProviderInit]) {
return nil;
Expand Down Expand Up @@ -189,6 +190,11 @@ - (void)cleanupInitObjects
delete _groupStorageDelegate;
_groupStorageDelegate = nullptr;
}

if (_sessionKeystore) {
delete _sessionKeystore;
_sessionKeystore = nullptr;
}
}

- (void)cleanupStartupObjects
Expand Down
4 changes: 2 additions & 2 deletions src/protocols/secure_channel/CASESession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1450,8 +1450,8 @@ CHIP_ERROR CASESession::ValidateSigmaResumeMIC(const ByteSpan & resumeMIC, const

AutoReleaseSessionKey srk(*mSessionManager->GetSessionKeystore());
ReturnErrorOnFailure(ConstructSigmaResumeKey(initiatorRandom, resumptionID, skInfo, nonce, srk));
ReturnErrorOnFailure(
AES_CCM_decrypt(nullptr, 0, nullptr, 0, resumeMIC.data(), resumeMIC.size(), srk.KeyHandle(), nonce.data(), nonce.size(), nullptr));
ReturnErrorOnFailure(AES_CCM_decrypt(nullptr, 0, nullptr, 0, resumeMIC.data(), resumeMIC.size(), srk.KeyHandle(), nonce.data(),
nonce.size(), nullptr));

return CHIP_NO_ERROR;
}
Expand Down
2 changes: 1 addition & 1 deletion src/transport/SessionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ class DLL_EXPORT SessionManager : public TransportMgrDelegate, public FabricTabl
* @param messageCounterManager The message counter manager
* @param storageDelegate Persistent storage implementation
* @param fabricTable Fabric table to hold information about joined fabrics
* @param keystore Session keystore for management of symmetric encryption keys
* @param sessionKeystore Session keystore for management of symmetric encryption keys
*/
CHIP_ERROR Init(System::Layer * systemLayer, TransportMgrBase * transportMgr,
Transport::MessageCounterManagerInterface * messageCounterManager,
Expand Down

0 comments on commit 2fbda3f

Please sign in to comment.