1b0104773SPascal Brand /* 2b0104773SPascal Brand * Copyright (c) 2014, STMicroelectronics International N.V. 3b0104773SPascal Brand * All rights reserved. 4b0104773SPascal Brand * 5b0104773SPascal Brand * Redistribution and use in source and binary forms, with or without 6b0104773SPascal Brand * modification, are permitted provided that the following conditions are met: 7b0104773SPascal Brand * 8b0104773SPascal Brand * 1. Redistributions of source code must retain the above copyright notice, 9b0104773SPascal Brand * this list of conditions and the following disclaimer. 10b0104773SPascal Brand * 11b0104773SPascal Brand * 2. Redistributions in binary form must reproduce the above copyright notice, 12b0104773SPascal Brand * this list of conditions and the following disclaimer in the documentation 13b0104773SPascal Brand * and/or other materials provided with the distribution. 14b0104773SPascal Brand * 15b0104773SPascal Brand * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16b0104773SPascal Brand * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17b0104773SPascal Brand * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18b0104773SPascal Brand * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19b0104773SPascal Brand * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20b0104773SPascal Brand * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21b0104773SPascal Brand * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22b0104773SPascal Brand * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23b0104773SPascal Brand * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24b0104773SPascal Brand * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25b0104773SPascal Brand * POSSIBILITY OF SUCH DAMAGE. 26b0104773SPascal Brand */ 27b0104773SPascal Brand #ifndef GUARD_TEE_MATHAPI_H 28b0104773SPascal Brand #define GUARD_TEE_MATHAPI_H 29b0104773SPascal Brand 30b0104773SPascal Brand #include <stddef.h> /* for size_t */ 31b0104773SPascal Brand #include <stdint.h> /* for uint32_t and friends */ 32b0104773SPascal Brand #include <stdbool.h> /* for bool (!) */ 33b0104773SPascal Brand 34b0104773SPascal Brand /************************************************************* 35b0104773SPascal Brand * 36b0104773SPascal Brand * MACRO DEFINITIONS 37b0104773SPascal Brand * 38b0104773SPascal Brand *************************************************************/ 39b0104773SPascal Brand 40b0104773SPascal Brand /*------------------------------------------------------------ 41b0104773SPascal Brand * 42b0104773SPascal Brand * How functions are exported 43b0104773SPascal Brand * 44b0104773SPascal Brand */ 45b0104773SPascal Brand #define TEE_MATHAPI_EXPORT 46b0104773SPascal Brand 47b0104773SPascal Brand /* 48b0104773SPascal Brand * The modes for String Conversion 49b0104773SPascal Brand */ 50b0104773SPascal Brand #define TEE_STRING_MODE_HEX_UC MPA_STRING_MODE_HEX_UC 51b0104773SPascal Brand #define TEE_STRING_MODE_HEX_LC MPA_STRING_MODE_HEX_UC 52b0104773SPascal Brand 53b0104773SPascal Brand /*------------------------------------------------------------ 54b0104773SPascal Brand * 55b0104773SPascal Brand * Define IN, OUT, INBUF and OUTBUF to keep format from the spec. 56b0104773SPascal Brand * 57b0104773SPascal Brand */ 58b0104773SPascal Brand #define IN const 59b0104773SPascal Brand #define OUT 60b0104773SPascal Brand #define INOUT 61b0104773SPascal Brand #define INBUF const 62b0104773SPascal Brand #define OUTBUF 63b0104773SPascal Brand 64b0104773SPascal Brand /************************************************************* 65b0104773SPascal Brand * 66b0104773SPascal Brand * MEMORY ALLOCATION AND SIZE 67b0104773SPascal Brand * 68b0104773SPascal Brand *************************************************************/ 69b0104773SPascal Brand 70b0104773SPascal Brand /* 71b0104773SPascal Brand * THIS IS THE MAXIMUM NUMBER OF BITS THAT THE LIBRARY SUPPORTS. 72b0104773SPascal Brand * It defines the size of the scratch memory pool for the underlying 73b0104773SPascal Brand * mpa library. 74b0104773SPascal Brand */ 75b0104773SPascal Brand #define TEE_MAX_NUMBER_OF_SUPPORTED_BITS 2048 76b0104773SPascal Brand 77b0104773SPascal Brand /************************************************************* 78b0104773SPascal Brand * 79b0104773SPascal Brand * INITIALIZATION FUNCTIONS 80b0104773SPascal Brand * 81b0104773SPascal Brand *************************************************************/ 82b0104773SPascal Brand 83b0104773SPascal Brand /* 84b0104773SPascal Brand * !!! This function must be called before you do anything else !!! 85b0104773SPascal Brand * NOTE: Not part of the spec 86b0104773SPascal Brand */ 87*7018ae01SSY Chiu TEE_MATHAPI_EXPORT void _TEE_MathAPI_Init(void); 88*7018ae01SSY Chiu 89*7018ae01SSY Chiu /* this function generate a syscall to teecore for random number 90*7018ae01SSY Chiu * generation, this is supplied to libmpa. Thus libmpa linked with user 91*7018ae01SSY Chiu * TA can use this function to get random number. 92*7018ae01SSY Chiu */ 93*7018ae01SSY Chiu TEE_Result get_rng_array(void *buf, size_t blen); 94b0104773SPascal Brand 95b0104773SPascal Brand #endif 96