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