Skip to content

Commit 8ae399d

Browse files
committed
WIP
Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
1 parent 57e23b2 commit 8ae399d

8 files changed

Lines changed: 49 additions & 61 deletions

File tree

subsys/nrf_security/CMakeLists.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ add_library(psa_crypto_config INTERFACE)
9494
# Add config files required for PSA crypto interface
9595
target_compile_definitions(psa_crypto_config
9696
INTERFACE
97-
-DMBEDTLS_CONFIG_FILE="${CONFIG_MBEDTLS_CONFIG_FILE}"
97+
# -DMBEDTLS_CONFIG_FILE="${CONFIG_MBEDTLS_CONFIG_FILE}"
9898
-DTF_PSA_CRYPTO_CONFIG_FILE="${CONFIG_TF_PSA_CRYPTO_CONFIG_FILE}"
9999
)
100100

@@ -105,7 +105,7 @@ add_library(psa_crypto_library_config INTERFACE)
105105
# Add config files required for PSA core
106106
target_compile_definitions(psa_crypto_library_config
107107
INTERFACE
108-
-DMBEDTLS_CONFIG_FILE="${CONFIG_MBEDTLS_CONFIG_FILE}"
108+
# -DMBEDTLS_CONFIG_FILE="${CONFIG_MBEDTLS_CONFIG_FILE}"
109109
-DTF_PSA_CRYPTO_CONFIG_FILE="${CONFIG_TF_PSA_CRYPTO_CONFIG_FILE}"
110110
-DTF_PSA_CRYPTO_USER_CONFIG_FILE="${CONFIG_TF_PSA_CRYPTO_USER_CONFIG_FILE}"
111111
)
@@ -122,9 +122,14 @@ target_include_directories(psa_interface
122122
${ZEPHYR_OBERON_PSA_CRYPTO_MODULE_DIR}/include
123123
${ZEPHYR_OBERON_PSA_CRYPTO_MODULE_DIR}/library
124124
# Mbed TLS (mbedcrypto) PSA headers
125-
${ZEPHYR_MBEDTLS_MODULE_DIR}/library
126-
${ZEPHYR_MBEDTLS_MODULE_DIR}/include
127-
${ZEPHYR_MBEDTLS_MODULE_DIR}/include/library
125+
# ${ZEPHYR_MBEDTLS_MODULE_DIR}/library
126+
# ${ZEPHYR_MBEDTLS_MODULE_DIR}/include
127+
# ${ZEPHYR_OBERON_PSA_CRYPTO_MODULE_DIR}/drivers/builtin/include/
128+
${ZEPHYR_OBERON_PSA_CRYPTO_MODULE_DIR}/core/
129+
${ZEPHYR_OBERON_PSA_CRYPTO_MODULE_DIR}/dispatch/
130+
${ZEPHYR_OBERON_PSA_CRYPTO_MODULE_DIR}/platform/
131+
132+
# ${ZEPHYR_TF_PSA_CRYPTO_MODULE_DIR}/include/library
128133
)
129134

130135
# Finally adding the crypto lib

subsys/nrf_security/Kconfig

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -234,19 +234,4 @@ config MBEDTLS_GENPRIME_ENABLED
234234

235235
endmenu # Zephyr legacy configurations
236236

237-
#
238-
# Provide a new choice to override the mbedtls_external library completely
239-
# and not have to provide a "dummy" path for the implementation
240-
#
241-
choice MBEDTLS_IMPLEMENTATION
242-
default MBEDTLS_LIBRARY_NRF_SECURITY
243-
244-
config MBEDTLS_LIBRARY_NRF_SECURITY
245-
bool "Use nRF Security mbedTLS version"
246-
depends on NRF_SECURITY
247-
help
248-
Use Mbed TLS library from Nordic provided security backend
249-
250-
endchoice
251-
252237
endmenu

subsys/nrf_security/include/psa/crypto_driver_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#ifndef PSA_CRYPTO_DRIVER_CONFIG_H
88
#define PSA_CRYPTO_DRIVER_CONFIG_H
9-
9+
// delete this if unused by new Oberon release
1010
#if defined(TF_PSA_CRYPTO_CONFIG_FILE)
1111
#include TF_PSA_CRYPTO_CONFIG_FILE
1212
#else

subsys/nrf_security/include/psa/crypto_driver_contexts_composites.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#ifndef PSA_CRYPTO_DRIVER_CONTEXTS_COMPOSITES_H
2626
#define PSA_CRYPTO_DRIVER_CONTEXTS_COMPOSITES_H
2727

28-
#include "oberon_psa_common.h"
28+
#include <tf_psa_crypto_common.h>
2929

3030
#include "psa/crypto_driver_common.h"
3131

@@ -86,8 +86,8 @@ typedef union {
8686
* them in order to avoid building errors. We don't use these at all
8787
* in the Oberon PSA core, the int type was chosen arbitrarily.
8888
*/
89-
typedef int psa_driver_sign_hash_interruptible_context_t;
90-
typedef int psa_driver_verify_hash_interruptible_context_t;
89+
typedef struct { int dummy; } psa_driver_sign_hash_interruptible_context_t;
90+
typedef struct { int dummy; } psa_driver_verify_hash_interruptible_context_t;
9191

9292
#endif /* PSA_CRYPTO_DRIVER_CONTEXTS_COMPOSITES_H */
9393
/* End of automatically generated file. */

subsys/nrf_security/include/psa/crypto_driver_contexts_primitives.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#ifndef PSA_CRYPTO_DRIVER_CONTEXTS_PRIMITIVES_H
2525
#define PSA_CRYPTO_DRIVER_CONTEXTS_PRIMITIVES_H
2626

27-
#include "oberon_psa_common.h"
27+
#include <tf_psa_crypto_common.h>
2828

2929
#include "psa/crypto_driver_common.h"
3030

subsys/nrf_security/src/CMakeLists.txt

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,20 @@ endif()
7171

7272
if(NOT CONFIG_MBEDTLS_PSA_CRYPTO_SPM AND NOT BUILD_INSIDE_TFM)
7373
append_with_prefix(src_crypto ${ZEPHYR_MBEDTLS_MODULE_DIR}/library
74-
pem.c
75-
pkcs12.c
76-
pkcs5.c
77-
pkparse.c
78-
pkwrite.c
79-
dhm.c
80-
cipher.c
81-
cipher_wrap.c
82-
md.c
83-
pk.c
84-
pk_ecc.c
85-
pk_wrap.c
86-
pkwrite.c
87-
psa_util.c
74+
# pem.c
75+
# pkcs12.c
76+
# pkcs5.c
77+
# pkparse.c
78+
# pkwrite.c
79+
# dhm.c
80+
# cipher.c
81+
# cipher_wrap.c
82+
# md.c
83+
# pk.c
84+
# pk_ecc.c
85+
# pk_wrap.c
86+
# pkwrite.c
87+
# psa_util.c
8888
)
8989

9090
endif()
@@ -111,23 +111,23 @@ endif()
111111
nrf_security_add_zephyr_options(${mbedcrypto_target})
112112

113113
# Base mbed TLS files (not in drivers or builtin's)
114-
append_with_prefix(src_crypto_base ${ZEPHYR_MBEDTLS_MODULE_DIR}/library
115-
asn1parse.c
116-
asn1write.c
117-
base64.c
118-
bignum.c
119-
bignum_core.c
120-
nist_kw.c
121-
oid.c
122-
padlock.c
123-
version.c
124-
constant_time.c
114+
append_with_prefix(src_crypto_base ${ZEPHYR_TF_PSA_CRYPTO_MODULE_DIR}/utilities
115+
# asn1parse.c
116+
# asn1write.c
117+
# base64.c
118+
# bignum.c
119+
# bignum_core.c
120+
# nist_kw.c
121+
# oid.c
122+
# padlock.c
123+
# version.c
124+
# constant_time.c
125125
)
126126

127127
# Legacy APIs were missing files added by Oberon PSA core (not built in
128128
# certain instances. This adds the same platform support as the Oberon PSA core)
129129
if(NOT CONFIG_MBEDTLS_PSA_CRYPTO_C)
130-
append_with_prefix(src_crypto_base ${ZEPHYR_OBERON_PSA_CRYPTO_MODULE_DIR}/library/
130+
append_with_prefix(src_crypto_base ${ZEPHYR_OBERON_PSA_CRYPTO_MODULE_DIR}/library/
131131
platform.c
132132
platform_util.c
133133
)

subsys/nrf_security/src/core/nrf_oberon/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
#
66

7-
append_with_prefix(src_crypto_core_oberon ${ZEPHYR_OBERON_PSA_CRYPTO_MODULE_DIR}/library/
7+
append_with_prefix(src_crypto_core_oberon ${ZEPHYR_OBERON_PSA_CRYPTO_MODULE_DIR}/platform/
88
platform.c
99
platform_util.c
1010
)
1111

12-
append_with_prefix(src_crypto_core_oberon ${ZEPHYR_OBERON_PSA_CRYPTO_MODULE_DIR}/library/
12+
append_with_prefix(src_crypto_core_oberon ${ZEPHYR_OBERON_PSA_CRYPTO_MODULE_DIR}/core/
1313
psa_crypto.c
1414
psa_crypto_client.c
1515
psa_crypto_slot_management.c

subsys/nrf_security/src/psa_crypto_driver_wrappers.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
* Warning: This file will be auto-generated in the future.
1111
*/
1212

13-
#include "common.h"
14-
#include "psa_crypto_core.h"
15-
#include "psa_crypto_driver_wrappers.h"
16-
#include <string.h>
13+
// #include <tf_psa_crypto_common.h>
14+
#include <tf_psa_crypto_common.h>
15+
#include <psa_crypto_core.h>
16+
#include <psa_crypto_driver_wrappers.h>
1717

1818
#if defined(MBEDTLS_PSA_CRYPTO_C)
1919

@@ -2573,8 +2573,7 @@ psa_status_t psa_driver_wrapper_encapsulate(const psa_key_attributes_t *attribut
25732573
size_t *output_key_length, uint8_t *ciphertext,
25742574
size_t ciphertext_size, size_t *ciphertext_length)
25752575
{
2576-
psa_status_t status;
2577-
(void)status;
2576+
psa_status_t status __maybe_unused;
25782577
psa_key_location_t location =
25792578
PSA_KEY_LIFETIME_GET_LOCATION(psa_get_key_lifetime(attributes));
25802579

@@ -2622,8 +2621,7 @@ psa_status_t psa_driver_wrapper_decapsulate(const psa_key_attributes_t *attribut
26222621
uint8_t *output_key, size_t output_key_size,
26232622
size_t *output_key_length)
26242623
{
2625-
psa_status_t status;
2626-
(void)status;
2624+
psa_status_t status __maybe_unused;
26272625
psa_key_location_t location =
26282626
PSA_KEY_LIFETIME_GET_LOCATION(psa_get_key_lifetime(attributes));
26292627

0 commit comments

Comments
 (0)