Lines Matching refs:s

131 int dtls1_accept(SSL *s) {  in dtls1_accept()  argument
138 assert(s->handshake_func == dtls1_accept); in dtls1_accept()
139 assert(s->server); in dtls1_accept()
140 assert(SSL_IS_DTLS(s)); in dtls1_accept()
145 if (s->info_callback != NULL) { in dtls1_accept()
146 cb = s->info_callback; in dtls1_accept()
147 } else if (s->ctx->info_callback != NULL) { in dtls1_accept()
148 cb = s->ctx->info_callback; in dtls1_accept()
151 s->in_handshake++; in dtls1_accept()
153 if (s->cert == NULL) { in dtls1_accept()
159 state = s->state; in dtls1_accept()
161 switch (s->state) { in dtls1_accept()
164 cb(s, SSL_CB_HANDSHAKE_START, 1); in dtls1_accept()
167 if (s->init_buf == NULL) { in dtls1_accept()
173 s->init_buf = buf; in dtls1_accept()
177 s->init_num = 0; in dtls1_accept()
179 if (!ssl_init_wbio_buffer(s, 1)) { in dtls1_accept()
184 if (!ssl3_init_finished_mac(s)) { in dtls1_accept()
190 s->state = SSL3_ST_SR_CLNT_HELLO_A; in dtls1_accept()
197 s->shutdown = 0; in dtls1_accept()
198 ret = ssl3_get_client_hello(s); in dtls1_accept()
202 dtls1_stop_timer(s); in dtls1_accept()
203 s->state = SSL3_ST_SW_SRVR_HELLO_A; in dtls1_accept()
204 s->init_num = 0; in dtls1_accept()
209 dtls1_start_timer(s); in dtls1_accept()
210 ret = ssl3_send_server_hello(s); in dtls1_accept()
215 if (s->hit) { in dtls1_accept()
216 if (s->tlsext_ticket_expected) { in dtls1_accept()
217 s->state = SSL3_ST_SW_SESSION_TICKET_A; in dtls1_accept()
219 s->state = SSL3_ST_SW_CHANGE_A; in dtls1_accept()
222 s->state = SSL3_ST_SW_CERT_A; in dtls1_accept()
224 s->init_num = 0; in dtls1_accept()
229 if (ssl_cipher_has_server_public_key(s->s3->tmp.new_cipher)) { in dtls1_accept()
230 dtls1_start_timer(s); in dtls1_accept()
231 ret = ssl3_send_server_certificate(s); in dtls1_accept()
235 if (s->s3->tmp.certificate_status_expected) { in dtls1_accept()
236 s->state = SSL3_ST_SW_CERT_STATUS_A; in dtls1_accept()
238 s->state = SSL3_ST_SW_KEY_EXCH_A; in dtls1_accept()
242 s->state = SSL3_ST_SW_KEY_EXCH_A; in dtls1_accept()
244 s->init_num = 0; in dtls1_accept()
249 alg_a = s->s3->tmp.new_cipher->algorithm_auth; in dtls1_accept()
259 if (ssl_cipher_requires_server_key_exchange(s->s3->tmp.new_cipher) || in dtls1_accept()
260 ((alg_a & SSL_aPSK) && s->psk_identity_hint)) { in dtls1_accept()
261 dtls1_start_timer(s); in dtls1_accept()
262 ret = ssl3_send_server_key_exchange(s); in dtls1_accept()
270 s->state = SSL3_ST_SW_CERT_REQ_A; in dtls1_accept()
271 s->init_num = 0; in dtls1_accept()
276 if (s->s3->tmp.cert_request) { in dtls1_accept()
277 dtls1_start_timer(s); in dtls1_accept()
278 ret = ssl3_send_certificate_request(s); in dtls1_accept()
285 s->state = SSL3_ST_SW_SRVR_DONE_A; in dtls1_accept()
286 s->init_num = 0; in dtls1_accept()
291 dtls1_start_timer(s); in dtls1_accept()
292 ret = ssl3_send_server_done(s); in dtls1_accept()
296 s->s3->tmp.next_state = SSL3_ST_SR_CERT_A; in dtls1_accept()
297 s->state = SSL3_ST_SW_FLUSH; in dtls1_accept()
298 s->init_num = 0; in dtls1_accept()
302 s->rwstate = SSL_WRITING; in dtls1_accept()
303 if (BIO_flush(s->wbio) <= 0) { in dtls1_accept()
307 s->rwstate = SSL_NOTHING; in dtls1_accept()
308 s->state = s->s3->tmp.next_state; in dtls1_accept()
313 if (s->s3->tmp.cert_request) { in dtls1_accept()
314 ret = ssl3_get_client_certificate(s); in dtls1_accept()
319 s->init_num = 0; in dtls1_accept()
320 s->state = SSL3_ST_SR_KEY_EXCH_A; in dtls1_accept()
325 ret = ssl3_get_client_key_exchange(s); in dtls1_accept()
329 s->state = SSL3_ST_SR_CERT_VRFY_A; in dtls1_accept()
330 s->init_num = 0; in dtls1_accept()
335 ret = ssl3_get_cert_verify(s); in dtls1_accept()
339 s->state = SSL3_ST_SR_FINISHED_A; in dtls1_accept()
340 s->init_num = 0; in dtls1_accept()
345 s->d1->change_cipher_spec_ok = 1; in dtls1_accept()
347 ssl3_get_finished(s, SSL3_ST_SR_FINISHED_A, SSL3_ST_SR_FINISHED_B); in dtls1_accept()
351 dtls1_stop_timer(s); in dtls1_accept()
352 if (s->hit) { in dtls1_accept()
353 s->state = SSL_ST_OK; in dtls1_accept()
354 } else if (s->tlsext_ticket_expected) { in dtls1_accept()
355 s->state = SSL3_ST_SW_SESSION_TICKET_A; in dtls1_accept()
357 s->state = SSL3_ST_SW_CHANGE_A; in dtls1_accept()
359 s->init_num = 0; in dtls1_accept()
364 ret = ssl3_send_new_session_ticket(s); in dtls1_accept()
368 s->state = SSL3_ST_SW_CHANGE_A; in dtls1_accept()
369 s->init_num = 0; in dtls1_accept()
374 s->session->cipher = s->s3->tmp.new_cipher; in dtls1_accept()
375 if (!s->enc_method->setup_key_block(s)) { in dtls1_accept()
380 ret = dtls1_send_change_cipher_spec(s, SSL3_ST_SW_CHANGE_A, in dtls1_accept()
387 s->state = SSL3_ST_SW_FINISHED_A; in dtls1_accept()
388 s->init_num = 0; in dtls1_accept()
390 if (!s->enc_method->change_cipher_state( in dtls1_accept()
391 s, SSL3_CHANGE_CIPHER_SERVER_WRITE)) { in dtls1_accept()
396 dtls1_reset_seq_numbers(s, SSL3_CC_WRITE); in dtls1_accept()
402 ssl3_send_finished(s, SSL3_ST_SW_FINISHED_A, SSL3_ST_SW_FINISHED_B, in dtls1_accept()
403 s->enc_method->server_finished_label, in dtls1_accept()
404 s->enc_method->server_finished_label_len); in dtls1_accept()
408 s->state = SSL3_ST_SW_FLUSH; in dtls1_accept()
409 if (s->hit) { in dtls1_accept()
410 s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A; in dtls1_accept()
412 s->s3->tmp.next_state = SSL_ST_OK; in dtls1_accept()
414 s->init_num = 0; in dtls1_accept()
418 ssl3_cleanup_key_block(s); in dtls1_accept()
421 ssl_free_wbio_buffer(s); in dtls1_accept()
423 s->init_num = 0; in dtls1_accept()
424 s->s3->initial_handshake_complete = 1; in dtls1_accept()
426 ssl_update_cache(s, SSL_SESS_CACHE_SERVER); in dtls1_accept()
429 cb(s, SSL_CB_HANDSHAKE_DONE, 1); in dtls1_accept()
435 s->d1->handshake_read_seq = 0; in dtls1_accept()
437 s->d1->handshake_write_seq = 0; in dtls1_accept()
438 s->d1->next_handshake_write_seq = 0; in dtls1_accept()
447 if (!s->s3->tmp.reuse_message && !skip) { in dtls1_accept()
448 if (cb != NULL && s->state != state) { in dtls1_accept()
449 new_state = s->state; in dtls1_accept()
450 s->state = state; in dtls1_accept()
451 cb(s, SSL_CB_ACCEPT_LOOP, 1); in dtls1_accept()
452 s->state = new_state; in dtls1_accept()
459 s->in_handshake--; in dtls1_accept()
462 cb(s, SSL_CB_ACCEPT_EXIT, ret); in dtls1_accept()