Skip to content

Commit 6b167f1

Browse files
committed
[crypto] PSA API: remove otPlatCryptoInit API
This commit removes otPlatCryptoInit API and moves responsibility of initializing the Crypto subsystem to the platform. Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
1 parent 3ed9fa8 commit 6b167f1

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

examples/platforms/simulation/system.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@
5252
#include <openthread/platform/alarm-milli.h>
5353
#include <openthread/platform/radio.h>
5454

55+
#if (OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_PSA)
56+
#include <psa/crypto.h>
57+
#endif
58+
5559
#include "simul_utils.h"
5660

5761
uint32_t gNodeId = 1;
@@ -198,10 +202,13 @@ void otSysInit(int aArgCount, char *aArgVector[])
198202
signal(SIGTERM, &handleSignal);
199203
signal(SIGHUP, &handleSignal);
200204

201-
#if OPENTHREAD_PSA_CRYPTO_NATIVE_ITS_FILE && (OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_PSA)
205+
#if (OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_PSA)
206+
psa_crypto_init();
207+
#if OPENTHREAD_PSA_CRYPTO_NATIVE_ITS_FILE
202208
snprintf(sNativeItsFileNamePrefix, sizeof(sNativeItsFileNamePrefix), "%s/%s_%d_",
203209
OPENTHREAD_CONFIG_POSIX_SETTINGS_PATH, getenv("PORT_OFFSET") ? getenv("PORT_OFFSET") : "0", gNodeId);
204210
gItsFileNamePrefix = sNativeItsFileNamePrefix;
211+
#endif
205212
#endif
206213

207214
platformLoggingInit(basename(aArgVector[0]));

examples/platforms/simulation/virtual_time/platform-sim.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
#include <openthread/tasklet.h>
5151
#include <openthread/platform/alarm-milli.h>
5252

53+
#if (OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_PSA)
54+
#include <psa/crypto.h>
55+
#endif
56+
5357
#include "lib/platform/exit_code.h"
5458
#include "utils/uart.h"
5559

@@ -278,10 +282,13 @@ void otSysInit(int argc, char *argv[])
278282
DieNow(OT_EXIT_FAILURE);
279283
}
280284

281-
#if OPENTHREAD_PSA_CRYPTO_NATIVE_ITS_FILE && (OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_PSA)
285+
#if (OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_PSA)
286+
psa_crypto_init();
287+
#if OPENTHREAD_PSA_CRYPTO_NATIVE_ITS_FILE
282288
snprintf(sNativeItsFileNamePrefix, sizeof(sNativeItsFileNamePrefix), "%s/%s_%d_",
283289
OPENTHREAD_CONFIG_POSIX_SETTINGS_PATH, getenv("PORT_OFFSET") ? getenv("PORT_OFFSET") : "0", gNodeId);
284290
gItsFileNamePrefix = sNativeItsFileNamePrefix;
291+
#endif
285292
#endif
286293

287294
socket_init();

include/openthread/instance.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extern "C" {
5252
*
5353
* @note This number versions both OpenThread platform and user APIs.
5454
*/
55-
#define OPENTHREAD_API_VERSION (549)
55+
#define OPENTHREAD_API_VERSION (550)
5656

5757
/**
5858
* @addtogroup api-instance

include/openthread/platform/crypto.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,6 @@ typedef struct otPlatCryptoEcdsaSignature otPlatCryptoEcdsaSignature;
215215
*/
216216
#define OT_CRYPTO_PBDKF2_MAX_SALT_SIZE 30
217217

218-
/**
219-
* Initialize the Crypto module.
220-
*/
221-
void otPlatCryptoInit(void);
222-
223218
/**
224219
* Import a key into PSA ITS.
225220
*

src/core/crypto/crypto_platform_mbedtls.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,6 @@ static constexpr uint16_t kEntropyMinThreshold = 16;
7878
#endif
7979
#endif
8080

81-
OT_TOOL_WEAK void otPlatCryptoInit(void)
82-
{
83-
// Intentionally empty.
84-
}
85-
8681
// AES Implementation
8782
OT_TOOL_WEAK otError otPlatCryptoAesInit(otCryptoContext *aContext)
8883
{

src/core/crypto/crypto_platform_psa.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,6 @@ static otError extractPrivateKeyInfo(const uint8_t *aAsn1KeyPair,
200200
return error;
201201
}
202202

203-
OT_TOOL_WEAK void otPlatCryptoInit(void) { psa_crypto_init(); }
204-
205203
OT_TOOL_WEAK otError otPlatCryptoImportKey(otCryptoKeyRef *aKeyRef,
206204
otCryptoKeyType aKeyType,
207205
otCryptoKeyAlgorithm aKeyAlgorithm,

src/core/thread/key_manager.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,6 @@ KeyManager::KeyManager(Instance &aInstance)
176176
, mKekFrameCounter(0)
177177
, mIsPskcSet(false)
178178
{
179-
otPlatCryptoInit();
180-
181179
#if OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE
182180
{
183181
NetworkKey networkKey;

0 commit comments

Comments
 (0)