Skip to content

Commit dad402a

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 46773ea commit dad402a

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
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
@@ -49,6 +49,10 @@
4949
#include <openthread/tasklet.h>
5050
#include <openthread/platform/alarm-milli.h>
5151

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

@@ -227,10 +231,13 @@ void otSysInit(int argc, char *argv[])
227231
DieNow(OT_EXIT_FAILURE);
228232
}
229233

230-
#if OPENTHREAD_PSA_CRYPTO_NATIVE_ITS_FILE && (OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_PSA)
234+
#if (OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_PSA)
235+
psa_crypto_init();
236+
#if OPENTHREAD_PSA_CRYPTO_NATIVE_ITS_FILE
231237
snprintf(sNativeItsFileNamePrefix, sizeof(sNativeItsFileNamePrefix), "%s/%s_%d_",
232238
OPENTHREAD_CONFIG_POSIX_SETTINGS_PATH, getenv("PORT_OFFSET") ? getenv("PORT_OFFSET") : "0", gNodeId);
233239
gItsFileNamePrefix = sNativeItsFileNamePrefix;
240+
#endif
234241
#endif
235242

236243
socket_init();

include/openthread/platform/crypto.h

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

216-
/**
217-
* Initialize the Crypto module.
218-
*/
219-
void otPlatCryptoInit(void);
220-
221216
/**
222217
* Import a key into PSA ITS.
223218
*

src/core/crypto/crypto_platform_mbedtls.cpp

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

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

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)