Skip to content

Commit dc15e4e

Browse files
[crypto] Updated the macro definition according to crypto config specific instead of platform config
1 parent ee61113 commit dc15e4e

11 files changed

Lines changed: 22 additions & 22 deletions

File tree

include/openthread/platform/crypto.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ typedef struct otCryptoKey
124124
*
125125
* Stores the context object for platform APIs.
126126
*
127-
* If `OPENTHREAD_CONFIG_PLATFORM_ALLOCS_CRYPTO_CONTEXTS` is enabled, platform allocates and populates this.
127+
* If `OPENTHREAD_CONFIG_CRYPTO_PLATFORM_ALLOCS_CONTEXT` is enabled, platform allocates and populates this.
128128
* Otherwise it is input.
129129
*/
130130
typedef struct otCryptoContext
@@ -328,7 +328,7 @@ void otPlatCryptoFree(void *aPtr);
328328
* @retval OT_ERROR_FAILED Failed to initialize HMAC operation.
329329
* @retval OT_ERROR_INVALID_ARGS @p aContext was NULL
330330
*
331-
* @note If `OPENTHREAD_CONFIG_PLATFORM_ALLOCS_CRYPTO_CONTEXTS` is enabled, @p aContext is output and platform MUST
331+
* @note If `OPENTHREAD_CONFIG_CRYPTO_PLATFORM_ALLOCS_CONTEXT` is enabled, @p aContext is output and platform MUST
332332
* populate it. Otherwise @p aContext is input.
333333
*
334334
* @note The platform driver shall point the context to the correct object such as psa_mac_operation_t or
@@ -395,7 +395,7 @@ otError otPlatCryptoHmacSha256Finish(otCryptoContext *aContext, uint8_t *aBuf, s
395395
* @retval OT_ERROR_INVALID_ARGS @p aContext was NULL
396396
* @retval OT_ERROR_NO_BUFS Cannot allocate the context.
397397
*
398-
* @note If `OPENTHREAD_CONFIG_PLATFORM_ALLOCS_CRYPTO_CONTEXTS` is enabled, @p aContext is output and platform MUST
398+
* @note If `OPENTHREAD_CONFIG_CRYPTO_PLATFORM_ALLOCS_CONTEXT` is enabled, @p aContext is output and platform MUST
399399
* populate it. Otherwise @p aContext is input.
400400
*
401401
* @note The platform driver shall point the context to the correct object such as psa_key_id
@@ -448,7 +448,7 @@ otError otPlatCryptoAesFree(otCryptoContext *aContext);
448448
* @retval OT_ERROR_FAILED Failed to Initialise AES operation.
449449
* @retval OT_ERROR_INVALID_ARGS @p aContext was NULL
450450
*
451-
* @note If `OPENTHREAD_CONFIG_PLATFORM_ALLOCS_CRYPTO_CONTEXTS` is enabled, @p aContext is output and platform MUST
451+
* @note If `OPENTHREAD_CONFIG_CRYPTO_PLATFORM_ALLOCS_CONTEXT` is enabled, @p aContext is output and platform MUST
452452
* populate it. Otherwise @p aContext is input.
453453
*
454454
* @note The platform driver shall point the context to the correct object such as psa_key_derivation_operation_t
@@ -511,7 +511,7 @@ otError otPlatCryptoHkdfDeinit(otCryptoContext *aContext);
511511
* @retval OT_ERROR_FAILED Failed to initialise SHA-256 operation.
512512
* @retval OT_ERROR_INVALID_ARGS @p aContext was NULL
513513
*
514-
* @note If `OPENTHREAD_CONFIG_PLATFORM_ALLOCS_CRYPTO_CONTEXTS` is enabled, @p aContext is output and platform MUST
514+
* @note If `OPENTHREAD_CONFIG_CRYPTO_PLATFORM_ALLOCS_CONTEXT` is enabled, @p aContext is output and platform MUST
515515
* populate it. Otherwise @p aContext is input.
516516
*
517517
* @note The platform driver shall point the context to the correct object such as psa_hash_operation_t

src/core/config/crypto.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@
5959
/** Use platform provided crypto library */
6060
#define OPENTHREAD_CONFIG_CRYPTO_LIB_PLATFORM 2
6161

62+
/**
63+
* @def OPENTHREAD_CONFIG_CRYPTO_PLATFORM_ALLOCS_CONTEXT
64+
*
65+
* Define to 1 to enable the platform to allocate crypto operation context.
66+
*/
67+
#ifndef OPENTHREAD_CONFIG_CRYPTO_PLATFORM_ALLOCS_CONTEXT
68+
#define OPENTHREAD_CONFIG_CRYPTO_PLATFORM_ALLOCS_CONTEXT 0
69+
#endif
70+
6271
#if OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_PLATFORM
6372

6473
/**

src/core/config/platform.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,6 @@
177177
#define OPENTHREAD_CONFIG_PLATFORM_POWER_CALIBRATION_ENABLE 0
178178
#endif
179179

180-
/**
181-
* @def OPENTHREAD_CONFIG_PLATFORM_ALLOCS_CRYPTO_CONTEXTS
182-
*
183-
* Define to 1 to enable platform allocation of crypto contexts.
184-
*/
185-
#ifndef OPENTHREAD_CONFIG_PLATFORM_ALLOCS_CRYPTO_CONTEXTS
186-
#define OPENTHREAD_CONFIG_PLATFORM_ALLOCS_CRYPTO_CONTEXTS 0
187-
#endif
188-
189180
#if OPENTHREAD_CONFIG_PLATFORM_RADIO_PROPRIETARY_SUPPORT
190181
#if (!defined(OPENTHREAD_CONFIG_PLATFORM_RADIO_PROPRIETARY_CHANNEL_PAGE) || \
191182
!defined(OPENTHREAD_CONFIG_PLATFORM_RADIO_PROPRIETARY_CHANNEL_MIN) || \

src/core/crypto/aes_ecb.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace Crypto {
4040

4141
AesEcb::AesEcb(void)
4242
{
43-
#if OPENTHREAD_CONFIG_PLATFORM_ALLOCS_CRYPTO_CONTEXTS
43+
#if OPENTHREAD_CONFIG_CRYPTO_PLATFORM_ALLOCS_CONTEXT
4444
mContext.mContext = nullptr;
4545
mContext.mContextSize = 0;
4646
#else

src/core/crypto/aes_ecb.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class AesEcb
8686

8787
private:
8888
otCryptoContext mContext;
89-
#if !OPENTHREAD_CONFIG_PLATFORM_ALLOCS_CRYPTO_CONTEXTS
89+
#if !OPENTHREAD_CONFIG_CRYPTO_PLATFORM_ALLOCS_CONTEXT
9090
OT_DEFINE_ALIGNED_VAR(mContextStorage, kAesContextSize, uint64_t);
9191
#endif
9292
};

src/core/crypto/hkdf_sha256.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace Crypto {
4444

4545
HkdfSha256::HkdfSha256(void)
4646
{
47-
#if OPENTHREAD_CONFIG_PLATFORM_ALLOCS_CRYPTO_CONTEXTS
47+
#if OPENTHREAD_CONFIG_CRYPTO_PLATFORM_ALLOCS_CONTEXT
4848
mContext.mContext = nullptr;
4949
mContext.mContextSize = 0;
5050
#else

src/core/crypto/hkdf_sha256.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class HkdfSha256
9494

9595
private:
9696
otCryptoContext mContext;
97-
#if !OPENTHREAD_CONFIG_PLATFORM_ALLOCS_CRYPTO_CONTEXTS
97+
#if !OPENTHREAD_CONFIG_CRYPTO_PLATFORM_ALLOCS_CONTEXT
9898
OT_DEFINE_ALIGNED_VAR(mContextStorage, kHkdfContextSize, uint64_t);
9999
#endif
100100
};

src/core/crypto/hmac_sha256.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace Crypto {
4141

4242
HmacSha256::HmacSha256(void)
4343
{
44-
#if OPENTHREAD_CONFIG_PLATFORM_ALLOCS_CRYPTO_CONTEXTS
44+
#if OPENTHREAD_CONFIG_CRYPTO_PLATFORM_ALLOCS_CONTEXT
4545
mContext.mContext = nullptr;
4646
mContext.mContextSize = 0;
4747
#else

src/core/crypto/hmac_sha256.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class HmacSha256
124124

125125
private:
126126
otCryptoContext mContext;
127-
#if !OPENTHREAD_CONFIG_PLATFORM_ALLOCS_CRYPTO_CONTEXTS
127+
#if !OPENTHREAD_CONFIG_CRYPTO_PLATFORM_ALLOCS_CONTEXT
128128
OT_DEFINE_ALIGNED_VAR(mContextStorage, kHmacSha256ContextSize, uint64_t);
129129
#endif
130130
};

src/core/crypto/sha256.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace Crypto {
4242

4343
Sha256::Sha256(void)
4444
{
45-
#if OPENTHREAD_CONFIG_PLATFORM_ALLOCS_CRYPTO_CONTEXTS
45+
#if OPENTHREAD_CONFIG_CRYPTO_PLATFORM_ALLOCS_CONTEXT
4646
mContext.mContext = nullptr;
4747
mContext.mContextSize = 0;
4848
#else

0 commit comments

Comments
 (0)