• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This file is part of the openHiTLS project.
3  *
4  * openHiTLS is licensed under the Mulan PSL v2.
5  * You can use this software according to the terms and conditions of the Mulan PSL v2.
6  * You may obtain a copy of Mulan PSL v2 at:
7  *
8  *     http://license.coscl.org.cn/MulanPSL2
9  *
10  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11  * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12  * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13  * See the Mulan PSL v2 for more details.
14  */
15 
16 #include "hitls_build.h"
17 #ifdef HITLS_TLS_FEATURE_INDICATOR
18 #include <stddef.h>
19 #include "tls.h"
20 #include "hitls_error.h"
21 #include "bsl_err_internal.h"
22 #include "hitls_debug.h"
23 
HITLS_SetInfoCb(HITLS_Ctx * ctx,HITLS_InfoCb callback)24 int32_t HITLS_SetInfoCb(HITLS_Ctx *ctx, HITLS_InfoCb callback)
25 {
26     if (ctx == NULL) {
27         return HITLS_NULL_INPUT;
28     }
29 
30     ctx->config.tlsConfig.infoCb = callback;
31     return HITLS_SUCCESS;
32 }
33 
HITLS_GetInfoCb(const HITLS_Ctx * ctx)34 HITLS_InfoCb HITLS_GetInfoCb(const HITLS_Ctx *ctx)
35 {
36     if (ctx == NULL) {
37         return NULL;
38     }
39 
40     return ctx->config.tlsConfig.infoCb;
41 }
42 
HITLS_CFG_SetInfoCb(HITLS_Config * config,HITLS_InfoCb callback)43 int32_t HITLS_CFG_SetInfoCb(HITLS_Config *config, HITLS_InfoCb callback)
44 {
45     /* support NULL callback */
46     if (config == NULL) {
47         return HITLS_NULL_INPUT;
48     }
49 
50     config->infoCb = callback;
51     return HITLS_SUCCESS;
52 }
53 
HITLS_CFG_GetInfoCb(const HITLS_Config * config)54 HITLS_InfoCb HITLS_CFG_GetInfoCb(const HITLS_Config *config)
55 {
56     if (config == NULL) {
57         return NULL;
58     }
59     return config->infoCb;
60 }
61 
HITLS_SetMsgCb(HITLS_Ctx * ctx,HITLS_MsgCb callback)62 int32_t HITLS_SetMsgCb(HITLS_Ctx *ctx, HITLS_MsgCb callback)
63 {
64     if (ctx == NULL) {
65         return HITLS_NULL_INPUT;
66     }
67 
68     return HITLS_CFG_SetMsgCb(&(ctx->config.tlsConfig), callback);
69 }
70 
HITLS_CFG_SetMsgCb(HITLS_Config * config,HITLS_MsgCb callback)71 int32_t HITLS_CFG_SetMsgCb(HITLS_Config *config, HITLS_MsgCb callback)
72 {
73     /* support NULL callback */
74     if (config == NULL) {
75         return HITLS_NULL_INPUT;
76     }
77 
78     config->msgCb = callback;
79     return HITLS_SUCCESS;
80 }
81 
HITLS_CFG_SetMsgCbArg(HITLS_Config * config,void * arg)82 int32_t HITLS_CFG_SetMsgCbArg(HITLS_Config *config, void *arg)
83 {
84     if (config == NULL) {
85         return HITLS_NULL_INPUT;
86     }
87 
88     config->msgArg = arg;
89 
90     return HITLS_SUCCESS;
91 }
92 #endif