1 /* 2 * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 /* 8 Common functions prototypes and definitions used in CRYS tests 9 */ 10 11 #ifndef __TST_COMMON_H__ 12 #define __TST_COMMON_H__ 13 14 #include <stdio.h> 15 #include <stdlib.h> 16 #include <pthread.h> 17 18 #if (!defined CC_SW) && (!defined CC_IOT) 19 #include "cc_fips.h" 20 #endif 21 #include "cc_lib.h" 22 23 /** 24 * The function copies src buffer to dst with reversed bytes order. 25 * 26 * Note: Overlapping is not allowed, besides reversing of the buffer in place. 27 * 28 * @param dst 29 * @param src 30 * @param sizeInBytes 31 */ 32 int TST_MemCpyReversed( void* dst, void* src, unsigned int sizeInBytes); 33 34 35 #ifndef CC_SW 36 #ifdef CC_IOT 37 #define TST_CC_LIB_INIT(rc, rndContext_ptr, rndWorkBuff_ptr) rc = CC_LibInit(rndContext_ptr, rndWorkBuff_ptr) 38 int tests_CC_libInit(CCRndContext_t* rndContext_ptr, CCRndWorkBuff_t * rndWorkBuff_ptr, unsigned long* stackAddress); 39 void* Test_LibInit(void *params ); 40 41 typedef struct LibInitArgs { 42 CCRndContext_t * rndContext_ptr; 43 CCRndWorkBuff_t * rndWorkBuff_ptr; 44 //RC - should also be a void* for entropy context (currently saved inside rndContext) 45 } LibInitArgs; 46 47 #else 48 CCFipsKatContext_t fipsCtx; 49 #ifdef CC_SUPPORT_FIPS 50 int testSetReeFipsError(uint32_t reeError, CCFipsState_t expfipsState); 51 // set REE error value to be REE ok, same value as CC_FIPS_SYNC_REE_STATUS|CC_FIPS_SYNC_MODULE_OK 52 #define TST_CC_LIB_INIT(rc, rndContext_ptr, rndWorkBuff_ptr) {\ 53 rc = CC_LibInit(rndContext_ptr, rndWorkBuff_ptr, false, &fipsCtx);\ 54 if (rc == 0) {\ 55 rc = testSetReeFipsError((0x4|0x0), CC_FIPS_STATE_NOT_SUPPORTED);\ 56 }\ 57 } 58 #else 59 #define TST_CC_LIB_INIT(rc, rndContext_ptr, rndWorkBuff_ptr) {\ 60 rc = CC_LibInit(rndContext_ptr, rndWorkBuff_ptr, false, &fipsCtx);\ 61 } 62 #endif 63 #endif 64 #endif 65 66 #endif 67