diff options
author | doug <> | 2015-07-18 23:00:23 +0000 |
---|---|---|
committer | doug <> | 2015-07-18 23:00:23 +0000 |
commit | 310fa0ab1bf7e6d6f3f72822da4f9283d737ed97 (patch) | |
tree | f8a8a883ea90e1f11546a703f19d3a42b5d5ce4e /src/lib/libssl/d1_both.c | |
parent | 789262561876b2fff0d8151c2e3e70736009ff97 (diff) | |
download | openbsd-310fa0ab1bf7e6d6f3f72822da4f9283d737ed97.tar.gz openbsd-310fa0ab1bf7e6d6f3f72822da4f9283d737ed97.tar.bz2 openbsd-310fa0ab1bf7e6d6f3f72822da4f9283d737ed97.zip |
Convert dtls1_get_message_header to CBS and change to int.
Changed return value from void to int. It should never return an error
given that the input length is not checked yet.
ok miod@
Diffstat (limited to 'src/lib/libssl/d1_both.c')
-rw-r--r-- | src/lib/libssl/d1_both.c | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/src/lib/libssl/d1_both.c b/src/lib/libssl/d1_both.c index 534db59ee8..5c93af8bd9 100644 --- a/src/lib/libssl/d1_both.c +++ b/src/lib/libssl/d1_both.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: d1_both.c,v 1.32 2015/02/09 10:53:28 jsing Exp $ */ | 1 | /* $OpenBSD: d1_both.c,v 1.33 2015/07/18 23:00:23 doug Exp $ */ |
2 | /* | 2 | /* |
3 | * DTLS implementation written by Nagendra Modadugu | 3 | * DTLS implementation written by Nagendra Modadugu |
4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. | 4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. |
@@ -125,6 +125,7 @@ | |||
125 | #include <openssl/x509.h> | 125 | #include <openssl/x509.h> |
126 | 126 | ||
127 | #include "pqueue.h" | 127 | #include "pqueue.h" |
128 | #include "bytestring.h" | ||
128 | 129 | ||
129 | #define RSMBLY_BITMASK_SIZE(msg_len) (((msg_len) + 7) / 8) | 130 | #define RSMBLY_BITMASK_SIZE(msg_len) (((msg_len) + 7) / 8) |
130 | 131 | ||
@@ -798,16 +799,15 @@ again: | |||
798 | return i; | 799 | return i; |
799 | } | 800 | } |
800 | /* Handshake fails if message header is incomplete */ | 801 | /* Handshake fails if message header is incomplete */ |
801 | if (i != DTLS1_HM_HEADER_LENGTH) { | 802 | if (i != DTLS1_HM_HEADER_LENGTH || |
803 | /* parse the message fragment header */ | ||
804 | dtls1_get_message_header(wire, &msg_hdr) == 0) { | ||
802 | al = SSL_AD_UNEXPECTED_MESSAGE; | 805 | al = SSL_AD_UNEXPECTED_MESSAGE; |
803 | SSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT, | 806 | SSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT, |
804 | SSL_R_UNEXPECTED_MESSAGE); | 807 | SSL_R_UNEXPECTED_MESSAGE); |
805 | goto f_err; | 808 | goto f_err; |
806 | } | 809 | } |
807 | 810 | ||
808 | /* parse the message fragment header */ | ||
809 | dtls1_get_message_header(wire, &msg_hdr); | ||
810 | |||
811 | /* | 811 | /* |
812 | * if this is a future (or stale) message it gets buffered | 812 | * if this is a future (or stale) message it gets buffered |
813 | * (or dropped)--no further processing at this time | 813 | * (or dropped)--no further processing at this time |
@@ -1372,16 +1372,36 @@ dtls1_guess_mtu(unsigned int curr_mtu) | |||
1372 | return curr_mtu; | 1372 | return curr_mtu; |
1373 | } | 1373 | } |
1374 | 1374 | ||
1375 | void | 1375 | int |
1376 | dtls1_get_message_header(unsigned char *data, struct hm_header_st *msg_hdr) | 1376 | dtls1_get_message_header(unsigned char *data, struct hm_header_st *msg_hdr) |
1377 | { | 1377 | { |
1378 | memset(msg_hdr, 0x00, sizeof(struct hm_header_st)); | 1378 | CBS header; |
1379 | msg_hdr->type = *(data++); | 1379 | uint32_t msg_len, frag_off, frag_len; |
1380 | n2l3(data, msg_hdr->msg_len); | 1380 | uint16_t seq; |
1381 | uint8_t type; | ||
1382 | |||
1383 | CBS_init(&header, data, sizeof(*msg_hdr)); | ||
1384 | |||
1385 | memset(msg_hdr, 0, sizeof(*msg_hdr)); | ||
1386 | |||
1387 | if (!CBS_get_u8(&header, &type)) | ||
1388 | return 0; | ||
1389 | if (!CBS_get_u24(&header, &msg_len)) | ||
1390 | return 0; | ||
1391 | if (!CBS_get_u16(&header, &seq)) | ||
1392 | return 0; | ||
1393 | if (!CBS_get_u24(&header, &frag_off)) | ||
1394 | return 0; | ||
1395 | if (!CBS_get_u24(&header, &frag_len)) | ||
1396 | return 0; | ||
1381 | 1397 | ||
1382 | n2s(data, msg_hdr->seq); | 1398 | msg_hdr->type = type; |
1383 | n2l3(data, msg_hdr->frag_off); | 1399 | msg_hdr->msg_len = msg_len; |
1384 | n2l3(data, msg_hdr->frag_len); | 1400 | msg_hdr->seq = seq; |
1401 | msg_hdr->frag_off = frag_off; | ||
1402 | msg_hdr->frag_len = frag_len; | ||
1403 | |||
1404 | return 1; | ||
1385 | } | 1405 | } |
1386 | 1406 | ||
1387 | void | 1407 | void |