Skip to content

Commit

Permalink
[mbedtls] add default crypto port of PSA API
Browse files Browse the repository at this point in the history
This commit introduces support for PSA API and use it by default in
simulation.

Signed-off-by: Łukasz Duda <[email protected]>
  • Loading branch information
LuDuda committed Apr 22, 2024
1 parent 6d58c5c commit fbc48cf
Show file tree
Hide file tree
Showing 8 changed files with 917 additions and 195 deletions.
1 change: 0 additions & 1 deletion examples/platforms/simulation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ set(OT_PLATFORM_DEFINES ${OT_PLATFORM_DEFINES} PARENT_SCOPE)
add_library(openthread-simulation
alarm.c
ble.c
crypto.c
diag.c
dns.c
dnssd.c
Expand Down
121 changes: 0 additions & 121 deletions examples/platforms/simulation/crypto.c

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
#ifndef OPENTHREAD_CORE_SIMULATION_CONFIG_H_
#define OPENTHREAD_CORE_SIMULATION_CONFIG_H_

#ifndef OPENTHREAD_CONFIG_CRYPTO_LIB
#define OPENTHREAD_CONFIG_CRYPTO_LIB OPENTHREAD_CONFIG_CRYPTO_LIB_PSA
#endif

#ifndef OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE
#define OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE 1
#endif

#ifndef OPENTHREAD_RADIO
#define OPENTHREAD_RADIO 0
#endif
Expand Down
6 changes: 4 additions & 2 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ set(COMMON_SOURCES
common/uptime.cpp
crypto/aes_ccm.cpp
crypto/aes_ecb.cpp
crypto/crypto_platform.cpp
crypto/crypto_platform_mbedtls.cpp
crypto/crypto_platform_psa.cpp
crypto/hkdf_sha256.cpp
crypto/hmac_sha256.cpp
crypto/mbedtls.cpp
Expand Down Expand Up @@ -282,7 +283,8 @@ set(RADIO_COMMON_SOURCES
common/uptime.cpp
crypto/aes_ccm.cpp
crypto/aes_ecb.cpp
crypto/crypto_platform.cpp
crypto/crypto_platform_mbedtls.cpp
crypto/crypto_platform_psa.cpp
crypto/storage.cpp
diags/factory_diags.cpp
instance/instance.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -750,74 +750,4 @@ OT_TOOL_WEAK otError otPlatCryptoPbkdf2GenerateKey(const uint8_t *aPassword,

#endif // #if OPENTHREAD_FTD

#elif OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_PSA

#if !OPENTHREAD_RADIO
#if OPENTHREAD_CONFIG_ECDSA_ENABLE

OT_TOOL_WEAK otError otPlatCryptoEcdsaGenerateKey(otPlatCryptoEcdsaKeyPair *aKeyPair)
{
OT_UNUSED_VARIABLE(aKeyPair);

return OT_ERROR_NOT_CAPABLE;
}

OT_TOOL_WEAK otError otPlatCryptoEcdsaGetPublicKey(const otPlatCryptoEcdsaKeyPair *aKeyPair,
otPlatCryptoEcdsaPublicKey *aPublicKey)
{
OT_UNUSED_VARIABLE(aKeyPair);
OT_UNUSED_VARIABLE(aPublicKey);

return OT_ERROR_NOT_CAPABLE;
}

OT_TOOL_WEAK otError otPlatCryptoEcdsaSign(const otPlatCryptoEcdsaKeyPair *aKeyPair,
const otPlatCryptoSha256Hash *aHash,
otPlatCryptoEcdsaSignature *aSignature)
{
OT_UNUSED_VARIABLE(aKeyPair);
OT_UNUSED_VARIABLE(aHash);
OT_UNUSED_VARIABLE(aSignature);

return OT_ERROR_NOT_CAPABLE;
}

OT_TOOL_WEAK otError otPlatCryptoEcdsaVerify(const otPlatCryptoEcdsaPublicKey *aPublicKey,
const otPlatCryptoSha256Hash *aHash,
const otPlatCryptoEcdsaSignature *aSignature)

{
OT_UNUSED_VARIABLE(aPublicKey);
OT_UNUSED_VARIABLE(aHash);
OT_UNUSED_VARIABLE(aSignature);

return OT_ERROR_NOT_CAPABLE;
}
#endif // #if OPENTHREAD_CONFIG_ECDSA_ENABLE

#endif // #if !OPENTHREAD_RADIO

#if OPENTHREAD_FTD

OT_TOOL_WEAK otError otPlatCryptoPbkdf2GenerateKey(const uint8_t *aPassword,
uint16_t aPasswordLen,
const uint8_t *aSalt,
uint16_t aSaltLen,
uint32_t aIterationCounter,
uint16_t aKeyLen,
uint8_t *aKey)
{
OT_UNUSED_VARIABLE(aPassword);
OT_UNUSED_VARIABLE(aPasswordLen);
OT_UNUSED_VARIABLE(aSalt);
OT_UNUSED_VARIABLE(aSaltLen);
OT_UNUSED_VARIABLE(aIterationCounter);
OT_UNUSED_VARIABLE(aKeyLen);
OT_UNUSED_VARIABLE(aKey);

return OT_ERROR_NOT_CAPABLE;
}

#endif // #if OPENTHREAD_FTD

#endif // #if OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_MBEDTLS
Loading

0 comments on commit fbc48cf

Please sign in to comment.