• 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 #include "hitls_build.h"
16 #ifdef HITLS_TLS_HOST_SERVER
17 #include "tls_binlog_id.h"
18 #include "bsl_log_internal.h"
19 #include "bsl_log.h"
20 #include "bsl_err_internal.h"
21 #include "hitls_error.h"
22 #include "tls.h"
23 #include "hs_ctx.h"
24 #include "hs_common.h"
25 #include "hs_dtls_timer.h"
26 #include "pack.h"
27 #include "send_process.h"
28 
29 #if defined(HITLS_TLS_PROTO_TLS_BASIC) || defined(HITLS_TLS_PROTO_DTLS12)
ServerSendServerHelloDoneProcess(TLS_Ctx * ctx)30 int32_t ServerSendServerHelloDoneProcess(TLS_Ctx *ctx)
31 {
32     int32_t ret;
33     /* get the server infomation */
34     HS_Ctx *hsCtx = (HS_Ctx *)ctx->hsCtx;
35 
36     /* determine whether to assemble a message */
37     if (hsCtx->msgLen == 0) {
38         /* assemble message */
39         ret = HS_PackMsg(ctx, SERVER_HELLO_DONE, hsCtx->msgBuf, hsCtx->bufferLen, &hsCtx->msgLen);
40         if (ret != HITLS_SUCCESS) {
41             BSL_LOG_BINLOG_FIXLEN(BINLOG_ID15879, BSL_LOG_LEVEL_ERR, BSL_LOG_BINLOG_TYPE_RUN,
42                 "server pack server hello done msg fail.", 0, 0, 0, 0);
43             return ret;
44         }
45     }
46 
47     /* writing Handshake message */
48     ret = HS_SendMsg(ctx);
49     if (ret != HITLS_SUCCESS) {
50         return ret;
51     }
52 
53     BSL_LOG_BINLOG_FIXLEN(BINLOG_ID15880, BSL_LOG_LEVEL_INFO, BSL_LOG_BINLOG_TYPE_RUN,
54         "server send server hello done msg success.", 0, 0, 0, 0);
55 
56 #if defined(HITLS_TLS_PROTO_DTLS12) && defined(HITLS_BSL_UIO_UDP)
57     ret = HS_StartTimer(ctx);
58     if (ret != HITLS_SUCCESS) {
59         return ret;
60     }
61 #endif /* HITLS_TLS_PROTO_DTLS12 && HITLS_BSL_UIO_UDP */
62 
63     if (hsCtx->isNeedClientCert) {
64         return HS_ChangeState(ctx, TRY_RECV_CERTIFICATE);
65     }
66     return HS_ChangeState(ctx, TRY_RECV_CLIENT_KEY_EXCHANGE);
67 }
68 #endif /* #if HITLS_TLS_PROTO_TLS_BASIC || HITLS_TLS_PROTO_DTLS12 */
69 #endif /* HITLS_TLS_HOST_SERVER */