• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  * Description: mbedtls harden adapt internal header file.
15  *
16  * Create: 2023-05-10
17 */
18 
19 #include "mbedtls/ecp.h"
20 #include "mbedtls/platform.h"
21 
22 #define PRINT_LINE_LEN                     16
23 
24 #define mbedtls_harden_log_err(fmt, ...)   \
25     mbedtls_printf("[%s:%d]" "HARDEN MBED ERR! : " fmt, __func__, __LINE__, ##__VA_ARGS__)
26 
27 #define unused(x)                          (void)(x)
28 
29 #if defined(MBED_HARDEN_DEBUG)
30 #define mbedtls_harden_log_dbg             mbedtls_printf
31 #else
32 #define mbedtls_harden_log_dbg(...)        (void)0
33 #endif
34 
35 #define mbedtls_harden_log_func_enter()    mbedtls_harden_log_dbg("%s ===>Enter\n", __func__)
36 #define mbedtls_harden_log_func_exit()     mbedtls_harden_log_dbg("%s <===Exit\n", __func__)
37 
38 #define MBED_HARDEN_DEBUG_BREAKPOINT       1
39 
40 #if defined(MBED_HARDEN_DEBUG_BREAKPOINT)
41 #define mbedtls_harden_log_breakpoint()    \
42     mbedtls_harden_log_dbg("your code go here %s--> LINE = %d!\n", __func__,__LINE__)
43 #endif
44 
45 void mbedtls_dump_grp_id(mbedtls_ecp_group_id group_id);
46 
47 void mbedtls_dump_hex(const char* name, const unsigned char* buf, unsigned int buf_len);
48 
49 void mbedtls_dump_mpi(const char* name, const mbedtls_mpi *mpi);
50 
51 void mbedtls_dump_point(const char* name, const mbedtls_ecp_point *point);