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