1# Copyright (c) 2022 Nordic Semiconductor ASA
2# SPDX-License-Identifier: Apache-2.0
3
4if (CONFIG_UOSCORE OR CONFIG_UEDHOC)
5
6  set(UOSCORE_UEDHOC_SRC_DIR ${ZEPHYR_CURRENT_MODULE_DIR}/src)
7  set(UOSCORE_UEDHOC_INCLUDE_DIR ${ZEPHYR_CURRENT_MODULE_DIR}/inc)
8
9  zephyr_include_directories(${UOSCORE_UEDHOC_INCLUDE_DIR})
10
11# Common part used by both libraries
12
13  zephyr_library_named(uoscore_uedhoc_common)
14
15  zephyr_library_compile_definitions(MBEDTLS)
16
17  if (CONFIG_UOSCORE_DEBUG OR CONFIG_UEDHOC_DEBUG)
18    zephyr_library_compile_definitions(DEBUG_PRINT)
19  endif()
20
21  zephyr_library_sources(
22    ${UOSCORE_UEDHOC_SRC_DIR}/common/byte_array.c
23    ${UOSCORE_UEDHOC_SRC_DIR}/common/crypto_wrapper.c
24    ${UOSCORE_UEDHOC_SRC_DIR}/common/memcpy_s.c
25    ${UOSCORE_UEDHOC_SRC_DIR}/common/print_util.c
26  )
27
28  zephyr_library_link_libraries(mbedTLS)
29
30  if (CONFIG_BUILD_WITH_TFM)
31    zephyr_library_include_directories(
32      $<TARGET_PROPERTY:tfm,TFM_BINARY_DIR>/install/interface/include
33    )
34  endif()
35
36# UOSCORE
37
38  if (CONFIG_UOSCORE)
39
40    zephyr_library_named(uoscore)
41
42    zephyr_library_compile_definitions(MBEDTLS)
43
44    if (CONFIG_UOSCORE_DEBUG)
45      zephyr_library_compile_definitions(DEBUG_PRINT)
46    endif()
47
48    zephyr_library_sources(
49      ${UOSCORE_UEDHOC_SRC_DIR}/oscore/aad.c
50      ${UOSCORE_UEDHOC_SRC_DIR}/oscore/coap2oscore.c
51      ${UOSCORE_UEDHOC_SRC_DIR}/oscore/nonce.c
52      ${UOSCORE_UEDHOC_SRC_DIR}/oscore/nvm.c
53      ${UOSCORE_UEDHOC_SRC_DIR}/oscore/option.c
54      ${UOSCORE_UEDHOC_SRC_DIR}/oscore/oscore_coap.c
55      ${UOSCORE_UEDHOC_SRC_DIR}/oscore/oscore_cose.c
56      ${UOSCORE_UEDHOC_SRC_DIR}/oscore/oscore_hkdf_info.c
57      ${UOSCORE_UEDHOC_SRC_DIR}/oscore/oscore_interactions.c
58      ${UOSCORE_UEDHOC_SRC_DIR}/oscore/oscore2coap.c
59      ${UOSCORE_UEDHOC_SRC_DIR}/oscore/replay_protection.c
60      ${UOSCORE_UEDHOC_SRC_DIR}/oscore/security_context.c
61      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/oscore_aad_array.c
62      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/oscore_enc_structure.c
63      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/oscore_info.c
64    )
65
66    zephyr_library_link_libraries(mbedTLS)
67
68  endif() # CONFIG_UOSCORE
69
70# UEDHOC
71
72  if (CONFIG_UEDHOC)
73
74    zephyr_library_named(uedhoc)
75
76    zephyr_library_compile_definitions(MBEDTLS)
77
78    if (CONFIG_UEDHOC_DEBUG)
79      zephyr_library_compile_definitions(DEBUG_PRINT)
80    endif()
81
82    zephyr_library_sources(
83      ${UOSCORE_UEDHOC_SRC_DIR}/edhoc/associated_data_encode.c
84      ${UOSCORE_UEDHOC_SRC_DIR}/edhoc/bstr_encode_decode.c
85      ${UOSCORE_UEDHOC_SRC_DIR}/edhoc/cert.c
86      ${UOSCORE_UEDHOC_SRC_DIR}/edhoc/ciphertext.c
87      ${UOSCORE_UEDHOC_SRC_DIR}/edhoc/edhoc_cose.c
88      ${UOSCORE_UEDHOC_SRC_DIR}/edhoc/edhoc_exporter.c
89      ${UOSCORE_UEDHOC_SRC_DIR}/edhoc/edhoc_method_type.c
90      ${UOSCORE_UEDHOC_SRC_DIR}/edhoc/hkdf_info.c
91      ${UOSCORE_UEDHOC_SRC_DIR}/edhoc/initiator.c
92      ${UOSCORE_UEDHOC_SRC_DIR}/edhoc/int_encode_decode.c
93      ${UOSCORE_UEDHOC_SRC_DIR}/edhoc/okm.c
94      ${UOSCORE_UEDHOC_SRC_DIR}/edhoc/plaintext_decode.c
95      ${UOSCORE_UEDHOC_SRC_DIR}/edhoc/plaintext_encode.c
96      ${UOSCORE_UEDHOC_SRC_DIR}/edhoc/prk.c
97      ${UOSCORE_UEDHOC_SRC_DIR}/edhoc/responder.c
98      ${UOSCORE_UEDHOC_SRC_DIR}/edhoc/retrieve_cred.c
99      ${UOSCORE_UEDHOC_SRC_DIR}/edhoc/runtime_context.c
100      ${UOSCORE_UEDHOC_SRC_DIR}/edhoc/signature_or_mac_msg.c
101      ${UOSCORE_UEDHOC_SRC_DIR}/edhoc/suites.c
102      ${UOSCORE_UEDHOC_SRC_DIR}/edhoc/th.c
103      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/edhoc_decode_bstr_type.c
104      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/edhoc_decode_cert.c
105      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/edhoc_decode_id_cred_x.c
106      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/edhoc_decode_int_type.c
107      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/edhoc_decode_message_1.c
108      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/edhoc_decode_message_2.c
109      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/edhoc_decode_message_3.c
110      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/edhoc_decode_plaintext.c
111      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/edhoc_encode_bstr_type.c
112      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/edhoc_encode_data_2.c
113      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/edhoc_encode_enc_structure.c
114      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/edhoc_encode_id_cred_x.c
115      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/edhoc_encode_info.c
116      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/edhoc_encode_int_type.c
117      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/edhoc_encode_message_1.c
118      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/edhoc_encode_message_2.c
119      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/edhoc_encode_message_3.c
120      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/edhoc_encode_message_error.c
121      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/edhoc_encode_sig_structure.c
122      ${UOSCORE_UEDHOC_SRC_DIR}/cbor/edhoc_encode_th2.c
123    )
124
125    zephyr_library_link_libraries(mbedTLS)
126
127  endif() # CONFIG_UEDHOC
128
129endif() # CONFIG_UOSCORE OR CONFIG_UEDHOC
130