/* mbed Microcontroller Library * Copyright (c) 2006-2020 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /**************************************************************************** * * Copyright 2020 Samsung Electronics All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific * language governing permissions and limitations under the License. * ****************************************************************************/ #ifndef SSS_COMMON_H #define SSS_COMMON_H /*************** Include Files ********************************************/ #include "sss_oid.h" /*************** Assertions ***********************************************/ /*************** Definitions / Macros *************************************/ #define SUCCESS (0x00) #define FAIL (0x01) #define SSSR_SUCCESS (0x00) #define SSSR_FAIL (0x01) #define RSP_FAIL (0xF1) #define RSP_SUCCESS (0xA1) #ifndef NULL #define NULL ((void *) 0) #endif #define NULLPTR (void *)0 ///////////////////////////////////////////////////////// // MACRO //////////////////////////////////////////////// ///////////////////////////////////////////////////////// #define BIT(nbit) (0x1u << (nbit)) #define SFR_BIT_SET(val, bit) ((val) |= (bit)) ///> 0)); \ ((u08 *)(buf))[2] = ((u08)((dword) >> 8)); \ ((u08 *)(buf))[1] = ((u08)((dword) >> 16)); \ ((u08 *)(buf))[0] = ((u08)((dword) >> 24)); #define GET_DWORD_FROM_BBUF(buf) \ (u32)( \ ((((u08 *)(buf))[3]) << 0) | \ ((((u08 *)(buf))[2]) << 8) | \ ((((u08 *)(buf))[1]) << 16) | \ ((((u08 *)(buf))[0]) << 24)) #define SWAP32(val) \ (u32)( \ (((val) & 0xff) << 24) | \ (((val) & 0xff00) << 8) | \ (((val) & 0xff0000) >> 8) | \ (((val) & 0xff000000) >> 24) \ ) #define CEIL_16BYTE(val) (val&0xF) ? ((val&0xFFFFFFF0)+0x10) : (val) #define CEIL_BY_WORD(val) (((val)+3)>>2) #define CEIL_BY_16BYTE(val) (((val)+15)>>4) //#define CEIL_BY_BYTE(bitval) (((bitval)+7)>>3) /*************** New Data Types (Basic Data Types) ***********************/ /*************** New Data Types *******************************************/ //! 8bits unsigned data type typedef unsigned char u08; //! 16bits unsigned data type typedef unsigned short u16; //! 32bits unsigned data type typedef unsigned int u32; //! 64bits unsigned data type typedef unsigned long long u64; //! CPU size bits unsigned data type typedef unsigned int uwd; //! 8bits signed data type typedef char s08; //! 16bits signed data type typedef short s16; //! 32bits signed data type typedef int s32; //! 64bits signed data type typedef long long s64; //! CPU size bits signed data type typedef int swd; //! return error code typedef u32 SSS_RV; /** * @brief struct of OCTET String / length & data */ typedef struct _OS_st { //! byte length of Data u32 u32DataByteLen; //! byte array of Data u08 *pu08Data; } stOCTET_STRING; /** * @brief struct of BIGNUM String / length & data */ typedef stOCTET_STRING stBIG_NUM; /*************** Constants ************************************************/ /*************** Variable declarations ************************************/ /*************** Functions ***********************************************/ #endif /* SSS_COMMON_H */