Skip to content

Commit

Permalink
[instance] define key-ref manager only under MTD or FTD builds (opent…
Browse files Browse the repository at this point in the history
  • Loading branch information
abtink authored Jan 23, 2025
1 parent 648f1a9 commit 6694d5c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/core/crypto/storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ Error Key::ExtractKey(uint8_t *aKeyBuffer, uint16_t &aKeyLength) const
return error;
}

#if OPENTHREAD_FTD || OPENTHREAD_MTD

void Storage::KeyRefManager::DestroyPersistentKeys(void)
{
DestroyKey(KeyRefFor(kNetworkKey));
Expand All @@ -68,6 +70,8 @@ void Storage::KeyRefManager::DestroyPersistentKeys(void)
DestroyKey(KeyRefFor(kEcdsa));
}

#endif

#endif // OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE

LiteralKey::LiteralKey(const Key &aKey)
Expand Down
4 changes: 4 additions & 0 deletions src/core/crypto/storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ typedef otCryptoKeyRef KeyRef;

constexpr KeyRef kInvalidKeyRef = 0x80000000; ///< Invalid `KeyRef` value (PSA_KEY_ID_VENDOR_MAX + 1).

#if OPENTHREAD_FTD || OPENTHREAD_MTD

/**
* Manages and selects the `KeyRef` values.
*/
Expand Down Expand Up @@ -174,6 +176,8 @@ class KeyRefManager : public InstanceLocator
#endif
};

#endif // OPENTHREAD_FTD || OPENTHREAD_MTD

/**
* Determine if a given `KeyRef` is valid or not.
*
Expand Down
6 changes: 3 additions & 3 deletions src/core/instance/instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ Instance::Instance(void)
: mTimerMilliScheduler(*this)
#if OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
, mTimerMicroScheduler(*this)
#endif
#if OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE
, mCryptoStorageKeyRefManager(*this)
#endif
, mRadio(*this)
#if OPENTHREAD_CONFIG_UPTIME_ENABLE
Expand All @@ -93,6 +90,9 @@ Instance::Instance(void)
// DNS-SD (mDNS) platform is initialized early to
// allow other modules to use it.
, mDnssd(*this)
#endif
#if OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE
, mCryptoStorageKeyRefManager(*this)
#endif
, mIp6(*this)
, mThreadNetif(*this)
Expand Down
8 changes: 4 additions & 4 deletions src/core/instance/instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,6 @@ class Instance : public otInstance, private NonCopyable

Random::Manager mRandomManager;

#if OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE
Crypto::Storage::KeyRefManager mCryptoStorageKeyRefManager;
#endif

// Radio is initialized before other member variables
// (particularly, SubMac and Mac) to allow them to use its methods
// from their constructor.
Expand All @@ -494,6 +490,10 @@ class Instance : public otInstance, private NonCopyable
Dnssd mDnssd;
#endif

#if OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE
Crypto::Storage::KeyRefManager mCryptoStorageKeyRefManager;
#endif

Ip6::Ip6 mIp6;
ThreadNetif mThreadNetif;
Tmf::Agent mTmfAgent;
Expand Down

0 comments on commit 6694d5c

Please sign in to comment.