Skip to content

Commit

Permalink
WIP: Replace PSO Keystore with PSA
Browse files Browse the repository at this point in the history
FIXME: This should be defined at compile time.
Signed-off-by: Vincent Coubard <[email protected]>
  • Loading branch information
pan- authored and adbridge committed Jun 14, 2023
1 parent 6bd1b2d commit 1017184
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/app/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ void Server::ResumeSubscriptions()
Credentials::IgnoreCertificateValidityPeriodPolicy Server::sDefaultCertValidityPolicy;

KvsPersistentStorageDelegate CommonCaseDeviceServerInitParams::sKvsPersistenStorageDelegate;
PersistentStorageOperationalKeystore CommonCaseDeviceServerInitParams::sPersistentStorageOperationalKeystore;
Crypto::PSAOperationalKeystore CommonCaseDeviceServerInitParams::sPersistentStorageOperationalKeystore;
Credentials::PersistentStorageOpCertStore CommonCaseDeviceServerInitParams::sPersistentStorageOpCertStore;
Credentials::GroupDataProviderImpl CommonCaseDeviceServerInitParams::sGroupDataProvider;
#if CHIP_CONFIG_ENABLE_SESSION_RESUMPTION
Expand Down
6 changes: 3 additions & 3 deletions src/app/server/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include <credentials/PersistentStorageOpCertStore.h>
#include <crypto/DefaultSessionKeystore.h>
#include <crypto/OperationalKeystore.h>
#include <crypto/PersistentStorageOperationalKeystore.h>
#include <crypto/PSAOperationalKeystore.h>
#include <inet/InetConfig.h>
#include <lib/core/CHIPConfig.h>
#include <lib/support/SafeInt.h>
Expand Down Expand Up @@ -197,7 +197,7 @@ struct CommonCaseDeviceServerInitParams : public ServerInitParams
{
// WARNING: PersistentStorageOperationalKeystore::Finish() is never called. It's fine for
// for examples and for now.
ReturnErrorOnFailure(sPersistentStorageOperationalKeystore.Init(this->persistentStorageDelegate));
// ReturnErrorOnFailure(sPersistentStorageOperationalKeystore.Init(this->persistentStorageDelegate));
this->operationalKeystore = &sPersistentStorageOperationalKeystore;
}

Expand Down Expand Up @@ -246,7 +246,7 @@ struct CommonCaseDeviceServerInitParams : public ServerInitParams

private:
static KvsPersistentStorageDelegate sKvsPersistenStorageDelegate;
static PersistentStorageOperationalKeystore sPersistentStorageOperationalKeystore;
static Crypto::PSAOperationalKeystore sPersistentStorageOperationalKeystore;
static Credentials::PersistentStorageOpCertStore sPersistentStorageOpCertStore;
static Credentials::GroupDataProviderImpl sGroupDataProvider;
#if CHIP_CONFIG_ENABLE_SESSION_RESUMPTION
Expand Down
10 changes: 5 additions & 5 deletions src/app/tests/integration/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include <app/tests/integration/common.h>
#include <credentials/PersistentStorageOpCertStore.h>
#include <crypto/PersistentStorageOperationalKeystore.h>
#include <crypto/PSAOperationalKeystore.h>
#include <lib/core/CHIPCore.h>
#include <lib/core/TLVDebug.h>
#include <lib/support/CodeUtils.h>
Expand All @@ -41,7 +41,7 @@ chip::SessionManager gSessionManager;
chip::secure_channel::MessageCounterManager gMessageCounterManager;
chip::SessionHolder gSession;
chip::TestPersistentStorageDelegate gStorage;
chip::PersistentStorageOperationalKeystore gOperationalKeystore;
chip::Crypto::PSAOperationalKeystore gOperationalKeystore;
chip::Credentials::PersistentStorageOpCertStore gOpCertStore;
chip::Crypto::DefaultSessionKeystore gSessionKeystore;

Expand All @@ -64,8 +64,8 @@ void InitializeChip()
err = gOpCertStore.Init(&gStorage);
SuccessOrExit(err);

err = gOperationalKeystore.Init(&gStorage);
SuccessOrExit(err);
// err = gOperationalKeystore.Init(&gStorage);
// SuccessOrExit(err);

fabricTableInitParams.storage = &gStorage;
fabricTableInitParams.operationalKeystore = &gOperationalKeystore;
Expand All @@ -92,7 +92,7 @@ void ShutdownChip()
gSessionManager.Shutdown();

gFabricTable.Shutdown();
gOperationalKeystore.Finish();
// gOperationalKeystore.Finish();
gOpCertStore.Finish();

chip::DeviceLayer::PlatformMgr().Shutdown();
Expand Down
8 changes: 5 additions & 3 deletions src/credentials/tests/TestFabricTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <credentials/TestOnlyLocalCertificateAuthority.h>
#include <credentials/tests/CHIPCert_test_vectors.h>
#include <crypto/CHIPCryptoPAL.h>
#include <crypto/PSAOperationalKeystore.h>
#include <crypto/PersistentStorageOperationalKeystore.h>
#include <lib/asn1/ASN1.h>
#include <lib/support/CodeUtils.h>
Expand All @@ -57,7 +58,7 @@ class ScopedFabricTable
{
mFabricTable.Shutdown();
mOpCertStore.Finish();
mOpKeyStore.Finish();
// mOpKeyStore.Finish();
}

CHIP_ERROR Init(chip::TestPersistentStorageDelegate * storage)
Expand All @@ -67,7 +68,7 @@ class ScopedFabricTable
initParams.operationalKeystore = &mOpKeyStore;
initParams.opCertStore = &mOpCertStore;

ReturnErrorOnFailure(mOpKeyStore.Init(storage));
// ReturnErrorOnFailure(mOpKeyStore.Init(storage));
ReturnErrorOnFailure(mOpCertStore.Init(storage));
return mFabricTable.Init(initParams);
}
Expand All @@ -76,7 +77,8 @@ class ScopedFabricTable

private:
chip::FabricTable mFabricTable;
chip::PersistentStorageOperationalKeystore mOpKeyStore;
chip::Crypto::PSAOperationalKeystore mOpKeyStore;
// chip::PersistentStorageOperationalKeystore mOpKeyStore;
chip::Credentials::PersistentStorageOpCertStore mOpCertStore;
};

Expand Down
4 changes: 2 additions & 2 deletions src/messaging/tests/MessagingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ CHIP_ERROR MessagingContext::Init(TransportMgrBase * transport, IOContext * ioCo

ReturnErrorOnFailure(PlatformMemoryUser::Init());

ReturnErrorOnFailure(mOpKeyStore.Init(&mStorage));
// ReturnErrorOnFailure(mOpKeyStore.Init(&mStorage));
ReturnErrorOnFailure(mOpCertStore.Init(&mStorage));

chip::FabricTable::InitParams initParams;
Expand Down Expand Up @@ -80,7 +80,7 @@ void MessagingContext::Shutdown()
mSessionManager.Shutdown();
mFabricTable.Shutdown();
mOpCertStore.Finish();
mOpKeyStore.Finish();
// mOpKeyStore.Finish();
}

CHIP_ERROR MessagingContext::InitFromExisting(const MessagingContext & existing)
Expand Down
4 changes: 2 additions & 2 deletions src/messaging/tests/MessagingContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <credentials/PersistentStorageOpCertStore.h>
#include <crypto/DefaultSessionKeystore.h>
#include <crypto/PersistentStorageOperationalKeystore.h>
#include <crypto/PSAOperationalKeystore.h>
#include <lib/support/TestPersistentStorageDelegate.h>
#include <messaging/ExchangeContext.h>
#include <messaging/ExchangeMgr.h>
Expand Down Expand Up @@ -182,7 +182,7 @@ class MessagingContext : public PlatformMemoryUser
IOContext * mIOContext;
TransportMgrBase * mTransport; // Only needed for InitFromExisting.
chip::TestPersistentStorageDelegate mStorage; // for SessionManagerInit
chip::PersistentStorageOperationalKeystore mOpKeyStore;
chip::Crypto::PSAOperationalKeystore mOpKeyStore;
chip::Credentials::PersistentStorageOpCertStore mOpCertStore;
chip::Crypto::DefaultSessionKeystore mSessionKeystore;

Expand Down
8 changes: 4 additions & 4 deletions src/transport/tests/TestSessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <credentials/PersistentStorageOpCertStore.h>
#include <credentials/tests/CHIPCert_unit_test_vectors.h>
#include <crypto/DefaultSessionKeystore.h>
#include <crypto/PersistentStorageOperationalKeystore.h>
#include <crypto/PSAOperationalKeystore.h>
#include <lib/core/CHIPCore.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/TestPersistentStorageDelegate.h>
Expand Down Expand Up @@ -70,13 +70,13 @@ class FabricTableHolder
~FabricTableHolder()
{
mFabricTable.Shutdown();
mOpKeyStore.Finish();
// mOpKeyStore.Finish();
mOpCertStore.Finish();
}

CHIP_ERROR Init()
{
ReturnErrorOnFailure(mOpKeyStore.Init(&mStorage));
// ReturnErrorOnFailure(mOpKeyStore.Init(&mStorage));
ReturnErrorOnFailure(mOpCertStore.Init(&mStorage));

chip::FabricTable::InitParams initParams;
Expand All @@ -92,7 +92,7 @@ class FabricTableHolder
private:
chip::FabricTable mFabricTable;
chip::TestPersistentStorageDelegate mStorage;
chip::PersistentStorageOperationalKeystore mOpKeyStore;
chip::PSAOperationalKeystore mOpKeyStore;
chip::Credentials::PersistentStorageOpCertStore mOpCertStore;
};

Expand Down
8 changes: 4 additions & 4 deletions src/transport/tests/TestSessionManagerDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <credentials/GroupDataProviderImpl.h>
#include <credentials/PersistentStorageOpCertStore.h>
#include <crypto/DefaultSessionKeystore.h>
#include <crypto/PersistentStorageOperationalKeystore.h>
#include <crypto/PSAOperationalKeystore.h>
#include <lib/core/CHIPCore.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/TestPersistentStorageDelegate.h>
Expand Down Expand Up @@ -427,13 +427,13 @@ class FabricTableHolder
~FabricTableHolder()
{
mFabricTable.Shutdown();
mOpKeyStore.Finish();
// mOpKeyStore.Finish();
mOpCertStore.Finish();
}

CHIP_ERROR Init()
{
ReturnErrorOnFailure(mOpKeyStore.Init(&mStorage));
// ReturnErrorOnFailure(mOpKeyStore.Init(&mStorage));
ReturnErrorOnFailure(mOpCertStore.Init(&mStorage));

// Initialize Group Data Provider
Expand All @@ -457,7 +457,7 @@ class FabricTableHolder
private:
chip::FabricTable mFabricTable;
chip::TestPersistentStorageDelegate mStorage;
chip::PersistentStorageOperationalKeystore mOpKeyStore;
chip::Crypto::PSAOperationalKeystore mOpKeyStore;
chip::Credentials::PersistentStorageOpCertStore mOpCertStore;
};

Expand Down

0 comments on commit 1017184

Please sign in to comment.