d1_srvr.c (238405) | d1_srvr.c (261037) |
---|---|
1/* ssl/d1_srvr.c */ 2/* 3 * DTLS implementation written by Nagendra Modadugu 4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. 5 */ 6/* ==================================================================== 7 * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. 8 * --- 262 unchanged lines hidden (view full) --- 271 } 272 273 break; 274 275 case SSL3_ST_SW_HELLO_REQ_A: 276 case SSL3_ST_SW_HELLO_REQ_B: 277 278 s->shutdown=0; | 1/* ssl/d1_srvr.c */ 2/* 3 * DTLS implementation written by Nagendra Modadugu 4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. 5 */ 6/* ==================================================================== 7 * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. 8 * --- 262 unchanged lines hidden (view full) --- 271 } 272 273 break; 274 275 case SSL3_ST_SW_HELLO_REQ_A: 276 case SSL3_ST_SW_HELLO_REQ_B: 277 278 s->shutdown=0; |
279 dtls1_clear_record_buffer(s); |
|
279 dtls1_start_timer(s); 280 ret=dtls1_send_hello_request(s); 281 if (ret <= 0) goto end; | 280 dtls1_start_timer(s); 281 ret=dtls1_send_hello_request(s); 282 if (ret <= 0) goto end; |
282 s->s3->tmp.next_state=SSL3_ST_SW_HELLO_REQ_C; | 283 s->s3->tmp.next_state=SSL3_ST_SR_CLNT_HELLO_A; |
283 s->state=SSL3_ST_SW_FLUSH; 284 s->init_num=0; 285 286 ssl3_init_finished_mac(s); 287 break; 288 289 case SSL3_ST_SW_HELLO_REQ_C: 290 s->state=SSL_ST_OK; --- 425 unchanged lines hidden (view full) --- 716 { ret= -1; goto end; } 717 718 ret=dtls1_send_change_cipher_spec(s, 719 SSL3_ST_SW_CHANGE_A,SSL3_ST_SW_CHANGE_B); 720 721 if (ret <= 0) goto end; 722 723#ifndef OPENSSL_NO_SCTP | 284 s->state=SSL3_ST_SW_FLUSH; 285 s->init_num=0; 286 287 ssl3_init_finished_mac(s); 288 break; 289 290 case SSL3_ST_SW_HELLO_REQ_C: 291 s->state=SSL_ST_OK; --- 425 unchanged lines hidden (view full) --- 717 { ret= -1; goto end; } 718 719 ret=dtls1_send_change_cipher_spec(s, 720 SSL3_ST_SW_CHANGE_A,SSL3_ST_SW_CHANGE_B); 721 722 if (ret <= 0) goto end; 723 724#ifndef OPENSSL_NO_SCTP |
724 /* Change to new shared key of SCTP-Auth, 725 * will be ignored if no SCTP used. 726 */ 727 BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, 0, NULL); | 725 if (!s->hit) 726 { 727 /* Change to new shared key of SCTP-Auth, 728 * will be ignored if no SCTP used. 729 */ 730 BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, 0, NULL); 731 } |
728#endif 729 730 s->state=SSL3_ST_SW_FINISHED_A; 731 s->init_num=0; 732 733 if (!s->method->ssl3_enc->change_cipher_state(s, 734 SSL3_CHANGE_CIPHER_SERVER_WRITE)) 735 { --- 8 unchanged lines hidden (view full) --- 744 case SSL3_ST_SW_FINISHED_B: 745 ret=dtls1_send_finished(s, 746 SSL3_ST_SW_FINISHED_A,SSL3_ST_SW_FINISHED_B, 747 s->method->ssl3_enc->server_finished_label, 748 s->method->ssl3_enc->server_finished_label_len); 749 if (ret <= 0) goto end; 750 s->state=SSL3_ST_SW_FLUSH; 751 if (s->hit) | 732#endif 733 734 s->state=SSL3_ST_SW_FINISHED_A; 735 s->init_num=0; 736 737 if (!s->method->ssl3_enc->change_cipher_state(s, 738 SSL3_CHANGE_CIPHER_SERVER_WRITE)) 739 { --- 8 unchanged lines hidden (view full) --- 748 case SSL3_ST_SW_FINISHED_B: 749 ret=dtls1_send_finished(s, 750 SSL3_ST_SW_FINISHED_A,SSL3_ST_SW_FINISHED_B, 751 s->method->ssl3_enc->server_finished_label, 752 s->method->ssl3_enc->server_finished_label_len); 753 if (ret <= 0) goto end; 754 s->state=SSL3_ST_SW_FLUSH; 755 if (s->hit) |
756 { |
|
752 s->s3->tmp.next_state=SSL3_ST_SR_FINISHED_A; | 757 s->s3->tmp.next_state=SSL3_ST_SR_FINISHED_A; |
758 759#ifndef OPENSSL_NO_SCTP 760 /* Change to new shared key of SCTP-Auth, 761 * will be ignored if no SCTP used. 762 */ 763 BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, 0, NULL); 764#endif 765 } |
|
753 else 754 { 755 s->s3->tmp.next_state=SSL_ST_OK; 756#ifndef OPENSSL_NO_SCTP 757 if (BIO_dgram_is_sctp(SSL_get_wbio(s))) 758 { 759 s->d1->next_state = s->s3->tmp.next_state; 760 s->s3->tmp.next_state=DTLS1_SCTP_ST_SW_WRITE_SOCK; --- 146 unchanged lines hidden (view full) --- 907 } 908 909int dtls1_send_server_hello(SSL *s) 910 { 911 unsigned char *buf; 912 unsigned char *p,*d; 913 int i; 914 unsigned int sl; | 766 else 767 { 768 s->s3->tmp.next_state=SSL_ST_OK; 769#ifndef OPENSSL_NO_SCTP 770 if (BIO_dgram_is_sctp(SSL_get_wbio(s))) 771 { 772 s->d1->next_state = s->s3->tmp.next_state; 773 s->s3->tmp.next_state=DTLS1_SCTP_ST_SW_WRITE_SOCK; --- 146 unchanged lines hidden (view full) --- 920 } 921 922int dtls1_send_server_hello(SSL *s) 923 { 924 unsigned char *buf; 925 unsigned char *p,*d; 926 int i; 927 unsigned int sl; |
915 unsigned long l,Time; | 928 unsigned long l; |
916 917 if (s->state == SSL3_ST_SW_SRVR_HELLO_A) 918 { 919 buf=(unsigned char *)s->init_buf->data; 920 p=s->s3->server_random; | 929 930 if (s->state == SSL3_ST_SW_SRVR_HELLO_A) 931 { 932 buf=(unsigned char *)s->init_buf->data; 933 p=s->s3->server_random; |
921 Time=(unsigned long)time(NULL); /* Time */ 922 l2n(Time,p); 923 RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE-4); | 934 ssl_fill_hello_random(s, 1, p, SSL3_RANDOM_SIZE); |
924 /* Do the message type and length last */ 925 d=p= &(buf[DTLS1_HM_HEADER_LENGTH]); 926 927 *(p++)=s->version>>8; 928 *(p++)=s->version&0xff; 929 930 /* Random stuff */ 931 memcpy(p,s->s3->server_random,SSL3_RANDOM_SIZE); --- 780 unchanged lines hidden --- | 935 /* Do the message type and length last */ 936 d=p= &(buf[DTLS1_HM_HEADER_LENGTH]); 937 938 *(p++)=s->version>>8; 939 *(p++)=s->version&0xff; 940 941 /* Random stuff */ 942 memcpy(p,s->s3->server_random,SSL3_RANDOM_SIZE); --- 780 unchanged lines hidden --- |