• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2021, The OpenThread Authors.
3  *  All rights reserved.
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions are met:
7  *  1. Redistributions of source code must retain the above copyright
8  *     notice, this list of conditions and the following disclaimer.
9  *  2. Redistributions in binary form must reproduce the above copyright
10  *     notice, this list of conditions and the following disclaimer in the
11  *     documentation and/or other materials provided with the distribution.
12  *  3. Neither the name of the copyright holder nor the
13  *     names of its contributors may be used to endorse or promote products
14  *     derived from this software without specific prior written permission.
15  *
16  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  *  POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef CONFIG_CRYPTO_H_
30 #define CONFIG_CRYPTO_H_
31 
32 /**
33  * @addtogroup config-crypto
34  *
35  * @brief
36  *   This module includes configuration variables for the Crypto Backend Library.
37  *
38  * @{
39  */
40 
41 /**
42  * @def OPENTHREAD_CONFIG_CRYPTO_LIB
43  *
44  * Selects the crypto backend library for OpenThread.
45  *
46  * There are several options available
47  * - @sa OPENTHREAD_CONFIG_CRYPTO_LIB_MBEDTLS
48  * - @sa OPENTHREAD_CONFIG_CRYPTO_LIB_PSA
49  * - @sa OPENTHREAD_CONFIG_CRYPTO_LIB_PLATFORM
50  */
51 #ifndef OPENTHREAD_CONFIG_CRYPTO_LIB
52 #define OPENTHREAD_CONFIG_CRYPTO_LIB OPENTHREAD_CONFIG_CRYPTO_LIB_MBEDTLS
53 #endif
54 
55 /** Use mbedtls as crypto library */
56 #define OPENTHREAD_CONFIG_CRYPTO_LIB_MBEDTLS 0
57 /** Use ARM Platform Security Library as crypto library */
58 #define OPENTHREAD_CONFIG_CRYPTO_LIB_PSA 1
59 /** Use platform provided crypto library */
60 #define OPENTHREAD_CONFIG_CRYPTO_LIB_PLATFORM 2
61 
62 #if OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_PLATFORM
63 
64 /**
65  * @def OPENTHREAD_CONFIG_AES_CONTEXT_SIZE
66  *
67  * The size of the AES context byte array. Only applicable with OPENTHREAD_CONFIG_CRYPTO_LIB_PLATFORM.
68  */
69 #ifndef OPENTHREAD_CONFIG_AES_CONTEXT_SIZE
70 #error "OPENTHREAD_CONFIG_AES_CONTEXT_SIZE is missing"
71 #endif
72 
73 /**
74  * @def OPENTHREAD_CONFIG_HMAC_SHA256_CONTEXT_SIZE
75  *
76  * The size of the HMAC_SHA256 context byte array. Only applicable with OPENTHREAD_CONFIG_CRYPTO_LIB_PLATFORM.
77  */
78 #ifndef OPENTHREAD_CONFIG_HMAC_SHA256_CONTEXT_SIZE
79 #error "OPENTHREAD_CONFIG_HMAC_SHA256_CONTEXT_SIZE is missing"
80 #endif
81 
82 /**
83  * @def OPENTHREAD_CONFIG_HKDF_CONTEXT_SIZE
84  *
85  * The size of the HKDF context byte array. Only applicable with OPENTHREAD_CONFIG_CRYPTO_LIB_PLATFORM.
86  */
87 #ifndef OPENTHREAD_CONFIG_HKDF_CONTEXT_SIZE
88 #error "OPENTHREAD_CONFIG_HKDF_CONTEXT_SIZE is missing"
89 #endif
90 
91 /**
92  * @def OPENTHREAD_CONFIG_SHA256_CONTEXT_SIZE
93  *
94  * The size of the SHA256 context byte array. Only applicable with OPENTHREAD_CONFIG_CRYPTO_LIB_PLATFORM.
95  */
96 #ifndef OPENTHREAD_CONFIG_SHA256_CONTEXT_SIZE
97 #error "OPENTHREAD_CONFIG_SHA256_CONTEXT_SIZE is missing"
98 #endif
99 
100 #endif // OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_PLATFORM
101 
102 /**
103  * @}
104  */
105 
106 #endif // CONFIG_CRYPTO_H_
107