int dtls1_set_handshake_header(SSL *ssl, int htype, unsigned long len) { uint8_t *message = (uint8_t *)ssl->init_buf->data; const struct hm_header_st *msg_hdr = &ssl->d1->w_msg_hdr; uint8_t serialised_header[DTLS1_HM_HEADER_LENGTH]; uint8_t *p = serialised_header; ssl->d1->handshake_write_seq = ssl->d1->next_handshake_write_seq; ssl->d1->next_handshake_write_seq++; dtls1_set_message_header(ssl, htype, len, ssl->d1->handshake_write_seq, 0, len); ssl->init_num = (int)len + DTLS1_HM_HEADER_LENGTH; ssl->init_off = 0; /* Buffer the message to handle re-xmits */ dtls1_buffer_message(ssl); /* Add the new message to the handshake hash. Serialize the message * header as if it were a single fragment. */ *p++ = msg_hdr->type; l2n3(msg_hdr->msg_len, p); s2n(msg_hdr->seq, p); l2n3(0, p); l2n3(msg_hdr->msg_len, p); return ssl3_update_handshake_hash(ssl, serialised_header, sizeof(serialised_header)) && ssl3_update_handshake_hash(ssl, message + DTLS1_HM_HEADER_LENGTH, len); }
int ssl3_hash_current_message(SSL *ssl) { /* The handshake header (different size between DTLS and TLS) is included in * the hash. */ size_t header_len = ssl->init_msg - (uint8_t *)ssl->init_buf->data; return ssl3_update_handshake_hash(ssl, (uint8_t *)ssl->init_buf->data, ssl->init_num + header_len); }
int ssl3_set_handshake_header(SSL *s, int htype, unsigned long len) { uint8_t *p = (uint8_t *)s->init_buf->data; *(p++) = htype; l2n3(len, p); s->init_num = (int)len + SSL3_HM_HEADER_LENGTH; s->init_off = 0; /* Add the message to the handshake hash. */ return ssl3_update_handshake_hash(s, (uint8_t *)s->init_buf->data, s->init_num); }