-/* ssl/record/rec_layer_d1.c */
/*
* DTLS implementation written by Nagendra Modadugu
* (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
#include "../ssl_locl.h"
#include <openssl/evp.h>
#include <openssl/buffer.h>
-#include <openssl/pqueue.h>
#include <openssl/rand.h>
#include "record_locl.h"
d->processed_rcds.q = pqueue_new();
d->buffered_app_data.q = pqueue_new();
- if (!d->unprocessed_rcds.q || !d->processed_rcds.q
- || !d->buffered_app_data.q) {
+ if (d->unprocessed_rcds.q == NULL || d->processed_rcds.q == NULL
+ || d->buffered_app_data.q == NULL) {
pqueue_free(d->unprocessed_rcds.q);
pqueue_free(d->processed_rcds.q);
pqueue_free(d->buffered_app_data.q);
DTLS_RECORD_LAYER *d;
pitem *item = NULL;
DTLS1_RECORD_DATA *rdata;
- pqueue unprocessed_rcds;
- pqueue processed_rcds;
- pqueue buffered_app_data;
+ pqueue *unprocessed_rcds;
+ pqueue *processed_rcds;
+ pqueue *buffered_app_data;
d = rl->d;
}
static int have_handshake_fragment(SSL *s, int type, unsigned char *buf,
- int len, int peek);
+ int len);
/* copy buffered record into SSL structure */
static int dtls1_copy_record(SSL *s, pitem *item)
/*
* check whether there's a handshake message (client hello?) waiting
*/
- if ((ret = have_handshake_fragment(s, type, buf, len, peek)))
+ if ((ret = have_handshake_fragment(s, type, buf, len)))
return ret;
/*
* Continue handshake if it had to be interrupted to read app data with
* SCTP.
*/
- if ((!s->in_handshake && SSL_in_init(s)) ||
+ if ((!ossl_statem_get_in_handshake(s) && SSL_in_init(s)) ||
(BIO_dgram_is_sctp(SSL_get_rbio(s))
&& ossl_statem_in_sctp_read_sock(s)
&& s->s3->in_read_app_data != 2))
#else
- if (!s->in_handshake && SSL_in_init(s))
+ if (!ossl_statem_get_in_handshake(s) && SSL_in_init(s))
#endif
{
/* type == SSL3_RT_APPLICATION_DATA */
dest_len = &s->rlayer.d->alert_fragment_len;
}
#ifndef OPENSSL_NO_HEARTBEATS
- else if (SSL3_RECORD_get_type(rr) == TLS1_RT_HEARTBEAT) {
+ else if (SSL3_RECORD_get_type(rr) == DTLS1_RT_HEARTBEAT) {
/* We allow a 0 return */
if (dtls1_process_heartbeat(s, SSL3_RECORD_get_data(rr),
SSL3_RECORD_get_length(rr)) < 0) {
* Unexpected handshake message (Client Hello, or protocol violation)
*/
if ((s->rlayer.d->handshake_fragment_len >= DTLS1_HM_HEADER_LENGTH) &&
- !s->in_handshake) {
+ !ossl_statem_get_in_handshake(s)) {
struct hm_header_st msg_hdr;
/* this may just be a stale retransmit */
case SSL3_RT_HANDSHAKE:
/*
* we already handled all of these, with the possible exception of
- * SSL3_RT_HANDSHAKE when s->in_handshake is set, but that should not
- * happen when type != rr->type
+ * SSL3_RT_HANDSHAKE when ossl_statem_get_in_handshake(s) is true, but
+ * that should not happen when type != rr->type
*/
al = SSL_AD_UNEXPECTED_MESSAGE;
SSLerr(SSL_F_DTLS1_READ_BYTES, ERR_R_INTERNAL_ERROR);
* is started.
*/
static int have_handshake_fragment(SSL *s, int type, unsigned char *buf,
- int len, int peek)
+ int len)
{
if ((type == SSL3_RT_HANDSHAKE)
SSL3_BUFFER *wb;
SSL_SESSION *sess;
- wb = &s->rlayer.wbuf;
+ wb = &s->rlayer.wbuf[0];
/*
* first check if there is a SSL3_BUFFER still being written out. This
/* first we compress */
if (s->compress != NULL) {
- if (!ssl3_do_compress(s)) {
+ if (!ssl3_do_compress(s, wr)) {
SSLerr(SSL_F_DO_DTLS1_WRITE, SSL_R_COMPRESSION_FAILURE);
goto err;
}
*/
if (mac_size != 0) {
- if (s->method->ssl3_enc->mac(s,
+ if (s->method->ssl3_enc->mac(s, wr,
&(p[SSL3_RECORD_get_length(wr) + eivlen]), 1) < 0)
goto err;
SSL3_RECORD_add_length(wr, mac_size);
if (eivlen)
SSL3_RECORD_add_length(wr, eivlen);
- if (s->method->ssl3_enc->enc(s, 1) < 1)
+ if (s->method->ssl3_enc->enc(s, wr, 1, 1) < 1)
goto err;
/* record length after mac and block padding */