Skip to content

Commit 4db4fcf

Browse files
committed
[crypto] introduce default OpenThread PSA crypto platform port
This commit adds a default implementation of the OpenThread crypto platform API for the PSA Crypto API. Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
1 parent b78b8c0 commit 4db4fcf

File tree

4 files changed

+770
-74
lines changed

4 files changed

+770
-74
lines changed

src/core/BUILD.gn

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,8 @@ openthread_core_files = [
464464
"crypto/aes_ecb.cpp",
465465
"crypto/aes_ecb.hpp",
466466
"crypto/context_size.hpp",
467-
"crypto/crypto_platform.cpp",
467+
"crypto/crypto_platform_mbedtls.cpp",
468+
"crypto/crypto_platform_psa.cpp",
468469
"crypto/ecdsa.hpp",
469470
"crypto/hkdf_sha256.cpp",
470471
"crypto/hkdf_sha256.hpp",
@@ -768,7 +769,8 @@ openthread_radio_sources = [
768769
"common/uptime.cpp",
769770
"crypto/aes_ccm.cpp",
770771
"crypto/aes_ecb.cpp",
771-
"crypto/crypto_platform.cpp",
772+
"crypto/crypto_platform_mbedtls.cpp",
773+
"crypto/crypto_platform_psa.cpp",
772774
"crypto/storage.cpp",
773775
"diags/factory_diags.cpp",
774776
"instance/instance.cpp",

src/core/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ set(COMMON_SOURCES
125125
common/uptime.cpp
126126
crypto/aes_ccm.cpp
127127
crypto/aes_ecb.cpp
128-
crypto/crypto_platform.cpp
128+
crypto/crypto_platform_mbedtls.cpp
129+
crypto/crypto_platform_psa.cpp
129130
crypto/hkdf_sha256.cpp
130131
crypto/hmac_sha256.cpp
131132
crypto/mbedtls.cpp
@@ -287,7 +288,8 @@ set(RADIO_COMMON_SOURCES
287288
common/uptime.cpp
288289
crypto/aes_ccm.cpp
289290
crypto/aes_ecb.cpp
290-
crypto/crypto_platform.cpp
291+
crypto/crypto_platform_mbedtls.cpp
292+
crypto/crypto_platform_psa.cpp
291293
crypto/storage.cpp
292294
diags/factory_diags.cpp
293295
instance/instance.cpp

src/core/crypto/crypto_platform.cpp renamed to src/core/crypto/crypto_platform_mbedtls.cpp

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -750,74 +750,4 @@ OT_TOOL_WEAK otError otPlatCryptoPbkdf2GenerateKey(const uint8_t *aPassword,
750750

751751
#endif // #if OPENTHREAD_FTD
752752

753-
#elif OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_PSA
754-
755-
#if OPENTHREAD_FTD || OPENTHREAD_MTD
756-
#if OPENTHREAD_CONFIG_ECDSA_ENABLE
757-
758-
OT_TOOL_WEAK otError otPlatCryptoEcdsaGenerateKey(otPlatCryptoEcdsaKeyPair *aKeyPair)
759-
{
760-
OT_UNUSED_VARIABLE(aKeyPair);
761-
762-
return OT_ERROR_NOT_CAPABLE;
763-
}
764-
765-
OT_TOOL_WEAK otError otPlatCryptoEcdsaGetPublicKey(const otPlatCryptoEcdsaKeyPair *aKeyPair,
766-
otPlatCryptoEcdsaPublicKey *aPublicKey)
767-
{
768-
OT_UNUSED_VARIABLE(aKeyPair);
769-
OT_UNUSED_VARIABLE(aPublicKey);
770-
771-
return OT_ERROR_NOT_CAPABLE;
772-
}
773-
774-
OT_TOOL_WEAK otError otPlatCryptoEcdsaSign(const otPlatCryptoEcdsaKeyPair *aKeyPair,
775-
const otPlatCryptoSha256Hash *aHash,
776-
otPlatCryptoEcdsaSignature *aSignature)
777-
{
778-
OT_UNUSED_VARIABLE(aKeyPair);
779-
OT_UNUSED_VARIABLE(aHash);
780-
OT_UNUSED_VARIABLE(aSignature);
781-
782-
return OT_ERROR_NOT_CAPABLE;
783-
}
784-
785-
OT_TOOL_WEAK otError otPlatCryptoEcdsaVerify(const otPlatCryptoEcdsaPublicKey *aPublicKey,
786-
const otPlatCryptoSha256Hash *aHash,
787-
const otPlatCryptoEcdsaSignature *aSignature)
788-
789-
{
790-
OT_UNUSED_VARIABLE(aPublicKey);
791-
OT_UNUSED_VARIABLE(aHash);
792-
OT_UNUSED_VARIABLE(aSignature);
793-
794-
return OT_ERROR_NOT_CAPABLE;
795-
}
796-
#endif // #if OPENTHREAD_CONFIG_ECDSA_ENABLE
797-
798-
#endif // #if OPENTHREAD_FTD || OPENTHREAD_MTD
799-
800-
#if OPENTHREAD_FTD
801-
802-
OT_TOOL_WEAK otError otPlatCryptoPbkdf2GenerateKey(const uint8_t *aPassword,
803-
uint16_t aPasswordLen,
804-
const uint8_t *aSalt,
805-
uint16_t aSaltLen,
806-
uint32_t aIterationCounter,
807-
uint16_t aKeyLen,
808-
uint8_t *aKey)
809-
{
810-
OT_UNUSED_VARIABLE(aPassword);
811-
OT_UNUSED_VARIABLE(aPasswordLen);
812-
OT_UNUSED_VARIABLE(aSalt);
813-
OT_UNUSED_VARIABLE(aSaltLen);
814-
OT_UNUSED_VARIABLE(aIterationCounter);
815-
OT_UNUSED_VARIABLE(aKeyLen);
816-
OT_UNUSED_VARIABLE(aKey);
817-
818-
return OT_ERROR_NOT_CAPABLE;
819-
}
820-
821-
#endif // #if OPENTHREAD_FTD
822-
823753
#endif // #if OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_MBEDTLS

0 commit comments

Comments
 (0)