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 /** 43 * @def OPENTHREAD_CONFIG_CRYPTO_LIB 44 * 45 * Selects the crypto backend library for OpenThread. 46 * 47 * There are several options available 48 * - @sa OPENTHREAD_CONFIG_CRYPTO_LIB_MBEDTLS 49 * - @sa OPENTHREAD_CONFIG_CRYPTO_LIB_PSA 50 * - @sa OPENTHREAD_CONFIG_CRYPTO_LIB_PLATFORM 51 * 52 */ 53 #ifndef OPENTHREAD_CONFIG_CRYPTO_LIB 54 #define OPENTHREAD_CONFIG_CRYPTO_LIB OPENTHREAD_CONFIG_CRYPTO_LIB_MBEDTLS 55 #endif 56 57 /** Use mbedtls as crypto library */ 58 #define OPENTHREAD_CONFIG_CRYPTO_LIB_MBEDTLS 0 59 /** Use ARM Platform Security Library as crypto library */ 60 #define OPENTHREAD_CONFIG_CRYPTO_LIB_PSA 1 61 /** Use platform provided crypto library */ 62 #define OPENTHREAD_CONFIG_CRYPTO_LIB_PLATFORM 2 63 64 #if OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_PLATFORM 65 66 /** 67 * @def OPENTHREAD_CONFIG_AES_CONTEXT_SIZE 68 * 69 * The size of the AES context byte array. Only applicable with OPENTHREAD_CONFIG_CRYPTO_LIB_PLATFORM. 70 * 71 */ 72 #ifndef OPENTHREAD_CONFIG_AES_CONTEXT_SIZE 73 #error "OPENTHREAD_CONFIG_AES_CONTEXT_SIZE is missing" 74 #endif 75 76 /** 77 * @def OPENTHREAD_CONFIG_HMAC_SHA256_CONTEXT_SIZE 78 * 79 * The size of the HMAC_SHA256 context byte array. Only applicable with OPENTHREAD_CONFIG_CRYPTO_LIB_PLATFORM. 80 * 81 */ 82 #ifndef OPENTHREAD_CONFIG_HMAC_SHA256_CONTEXT_SIZE 83 #error "OPENTHREAD_CONFIG_HMAC_SHA256_CONTEXT_SIZE is missing" 84 #endif 85 86 /** 87 * @def OPENTHREAD_CONFIG_HKDF_CONTEXT_SIZE 88 * 89 * The size of the HKDF context byte array. Only applicable with OPENTHREAD_CONFIG_CRYPTO_LIB_PLATFORM. 90 * 91 */ 92 #ifndef OPENTHREAD_CONFIG_HKDF_CONTEXT_SIZE 93 #error "OPENTHREAD_CONFIG_HKDF_CONTEXT_SIZE is missing" 94 #endif 95 96 /** 97 * @def OPENTHREAD_CONFIG_SHA256_CONTEXT_SIZE 98 * 99 * The size of the SHA256 context byte array. Only applicable with OPENTHREAD_CONFIG_CRYPTO_LIB_PLATFORM. 100 * 101 */ 102 #ifndef OPENTHREAD_CONFIG_SHA256_CONTEXT_SIZE 103 #error "OPENTHREAD_CONFIG_SHA256_CONTEXT_SIZE is missing" 104 #endif 105 106 #endif // OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_PLATFORM 107 108 /** 109 * @} 110 * 111 */ 112 113 #endif // CONFIG_CRYPTO_H_ 114