unsigned int len, int create_empty_fragment);
static int ssl3_get_record(SSL *s);
+/* If extend == 0, obtain new n-byte packet; if extend == 1, increase
+ * packet by another n bytes.
+ * The packet will be in the sub-array of s->s3->rbuf.buf specified
+ * by s->packet and s->packet_length.
+ * (If s->read_ahead is set, 'max' bytes may be stored in rbuf
+ * [plus s->packet_length bytes if extend == 1].)
+ */
int
ssl3_read_n(SSL *s, int n, int max, int extend)
{
- /* If extend == 0, obtain new n-byte packet; if extend == 1, increase
- * packet by another n bytes.
- * The packet will be in the sub-array of s->s3->rbuf.buf specified
- * by s->packet and s->packet_length.
- * (If s->read_ahead is set, 'max' bytes may be stored in rbuf
- * [plus s->packet_length bytes if extend == 1].)
- */
int i, len, left;
long align = 0;
unsigned char *pkt;
/* check if next packet length is large
* enough to justify payload alignment... */
pkt = rb->buf + rb->offset;
- if (pkt[0] == SSL3_RT_APPLICATION_DATA
- && (pkt[3]<<8|pkt[4]) >= 128) {
+ if (pkt[0] == SSL3_RT_APPLICATION_DATA &&
+ (pkt[3]<<8|pkt[4]) >= 128) {
/* Note that even if packet is corrupted
* and its length field is insane, we can
* only be led to wrong decision about
* Header values has no effect on memmove
* arguments and therefore no buffer
* overrun can be triggered. */
- memmove (rb->buf + align, pkt, left);
+ memmove(rb->buf + align, pkt, left);
rb->offset = align;
}
}
/* Move any available bytes to front of buffer:
* 'len' bytes already pointed to by 'packet',
* 'left' extra ones at the end */
- if (s->packet != pkt) /* len > 0 */
- {
+ if (s->packet != pkt) {
+ /* len > 0 */
memmove(pkt, s->packet, len + left);
s->packet = pkt;
rb->offset = len + align;
}
- if (n > (int)(rb->len - rb->offset)) /* does not happen */
- {
+ if (n > (int)(rb->len - rb->offset)) {
+ /* does not happen */
SSLerr(SSL_F_SSL3_READ_N, ERR_R_INTERNAL_ERROR);
return -1;
}
- if (!s->read_ahead)
+ if (!s->read_ahead) {
/* ignore max parameter */
max = n;
- else {
+ } else {
if (max < n)
max = n;
if (max > (int)(rb->len - rb->offset))
if (i <= 0) {
rb->left = left;
if (s->mode & SSL_MODE_RELEASE_BUFFERS &&
- SSL_version(s) != DTLS1_VERSION && SSL_version(s) != DTLS1_BAD_VER)
- if (len + left == 0)
- ssl3_release_read_buffer(s);
+ SSL_version(s) != DTLS1_VERSION &&
+ SSL_version(s) != DTLS1_BAD_VER)
+ if (len + left == 0)
+ ssl3_release_read_buffer(s);
return (i);
}
left += i;
/* reads should *never* span multiple packets for DTLS because
* the underlying transport protocol is message oriented as opposed
* to byte oriented as in the TLS case. */
- if (SSL_version(s) == DTLS1_VERSION || SSL_version(s) == DTLS1_BAD_VER) {
+ if (SSL_version(s) == DTLS1_VERSION ||
+ SSL_version(s) == DTLS1_BAD_VER) {
if (n > left)
n = left; /* makes the while condition false */
}
extra = SSL3_RT_MAX_EXTRA;
else
extra = 0;
+
if (extra && !s->s3->init_extra) {
/* An application error: SLS_OP_MICROSOFT_BIG_SSLV3_BUFFER
* set after ssl3_setup_buffers() was done */
if ((s->rstate != SSL_ST_READ_BODY) ||
(s->packet_length < SSL3_RT_HEADER_LENGTH)) {
n = ssl3_read_n(s, SSL3_RT_HEADER_LENGTH, s->s3->rbuf.len, 0);
- if (n <= 0) return(n); /* error or non-blocking */
- s->rstate = SSL_ST_READ_BODY;
+ if (n <= 0)
+ return(n); /* error or non-blocking */
+ s->rstate = SSL_ST_READ_BODY;
p = s->packet;
/* Lets check version */
if (!s->first_packet) {
if (version != s->version) {
- SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_WRONG_VERSION_NUMBER);
- if ((s->version & 0xFF00) == (version & 0xFF00) && !s->enc_write_ctx && !s->write_hash)
+ SSLerr(SSL_F_SSL3_GET_RECORD,
+ SSL_R_WRONG_VERSION_NUMBER);
+ if ((s->version & 0xFF00) == (version & 0xFF00) &&
+ !s->enc_write_ctx && !s->write_hash)
/* Send back error using their minor version number :-) */
- s->version = (unsigned short)version;
+ s->version = (unsigned short)version;
al = SSL_AD_PROTOCOL_VERSION;
goto f_err;
}
/* now s->packet_length == SSL3_RT_HEADER_LENGTH */
i = rr->length;
n = ssl3_read_n(s, i, i, 1);
- if (n <= 0) return(n); /* error or non-blocking io */
+ if (n <= 0)
+ return(n); /* error or non-blocking io */
/* now n == rr->length,
* and s->packet_length == SSL3_RT_HEADER_LENGTH + rr->length */
}
/* s->read_hash != NULL => mac_size != -1 */
unsigned char *mac = NULL;
unsigned char mac_tmp[EVP_MAX_MD_SIZE];
+
mac_size = EVP_MD_CTX_size(s->read_hash);
OPENSSL_assert(mac_size <= EVP_MAX_MD_SIZE);
mac = &rr->data[rr->length];
}
- i=s->method->ssl3_enc->mac(s,md,0 /* not send */);
- if (i < 0 || mac == NULL || CRYPTO_memcmp(md, mac, (size_t)mac_size) != 0)
+ i = s->method->ssl3_enc->mac(s,md,0 /* not send */);
+ if (i < 0 || mac == NULL ||
+ CRYPTO_memcmp(md, mac, (size_t)mac_size) != 0)
enc_err = -1;
if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH + extra + mac_size)
enc_err = -1;
}
rr->off = 0;
- /* So at this point the following is true
+ /*
+ * So at this point the following is true
+ *
* ssl->s3->rrec.type is the type of record
* ssl->s3->rrec.length == number of bytes in record
* ssl->s3->rrec.off == offset to first valid byte
rr = &(ssl->s3->rrec);
i = COMP_expand_block(ssl->expand, rr->comp,
- SSL3_RT_MAX_PLAIN_LENGTH, rr->data,(int)rr->length);
+ SSL3_RT_MAX_PLAIN_LENGTH, rr->data, (int)rr->length);
if (i < 0)
return (0);
else
wr = &(ssl->s3->wrec);
i = COMP_compress_block(ssl->compress, wr->data,
- SSL3_RT_MAX_COMPRESSED_LENGTH,
- wr->input,(int)wr->length);
+ SSL3_RT_MAX_COMPRESSED_LENGTH,
+ wr->input, (int)wr->length);
if (i < 0)
return (0);
else
wr->length = (int)len;
wr->input = (unsigned char *)buf;
- /* we now 'read' from wr->input, wr->length bytes into
- * wr->data */
+ /* we now 'read' from wr->input, wr->length bytes into wr->data */
/* first we compress */
if (s->compress != NULL) {
/* now let's set up wb */
wb->left = prefix_len + wr->length;
- /* memorize arguments so that ssl3_write_pending can detect bad write retries later */
+ /* memorize arguments so that ssl3_write_pending can detect
+ * bad write retries later */
s->s3->wpend_tot = len;
s->s3->wpend_buf = buf;
s->s3->wpend_type = type;
int i;
SSL3_BUFFER *wb = &(s->s3->wbuf);
-/* XXXX */
+ /* XXXX */
if ((s->s3->wpend_tot > (int)len) || ((s->s3->wpend_buf != buf) &&
!(s->mode & SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER)) ||
(s->s3->wpend_type != type)) {
return -1;
}
- if ((type == SSL3_RT_HANDSHAKE) && (s->s3->handshake_fragment_len > 0))
+ if ((type == SSL3_RT_HANDSHAKE) && (s->s3->handshake_fragment_len > 0)) {
/* (partially) satisfy request from storage */
- {
unsigned char *src = s->s3->handshake_fragment;
unsigned char *dst = buf;
unsigned int k;
start:
s->rwstate = SSL_NOTHING;
- /* s->s3->rrec.type - is the type of record
+ /*
+ * s->s3->rrec.type - is the type of record
* s->s3->rrec.data, - data
* s->s3->rrec.off, - offset into 'data' for next read
- * s->s3->rrec.length, - number of bytes. */
+ * s->s3->rrec.length, - number of bytes.
+ */
rr = &(s->s3->rrec);
/* get new packet if necessary */
}
- if (type == rr->type) /* SSL3_RT_APPLICATION_DATA or SSL3_RT_HANDSHAKE */
- {
+ if (type == rr->type) { /* SSL3_RT_APPLICATION_DATA or SSL3_RT_HANDSHAKE */
/* make sure that we are not getting application data when we
* are doing a handshake for the first time */
if (SSL_in_init(s) && (type == SSL3_RT_APPLICATION_DATA) &&
/* If we get here, then type != rr->type; if we have a handshake
* message, then it was unexpected (Hello Request or Client Hello). */
- /* In case of record types for which we have 'fragment' storage,
- * fill that so that we can process the data at a fixed place.
- */
{
+ /*
+ * In case of record types for which we have 'fragment'
+ * storage, * fill that so that we can process the data
+ * at a fixed place.
+ */
unsigned int dest_maxlen = 0;
unsigned char *dest = NULL;
unsigned int *dest_len = NULL;
}
if (s->msg_callback)
- s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, s->s3->handshake_fragment, 4, s, s->msg_callback_arg);
+ s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE,
+ s->s3->handshake_fragment, 4, s, s->msg_callback_arg);
if (SSL_is_init_finished(s) &&
!(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) &&
}
if (!(s->mode & SSL_MODE_AUTO_RETRY)) {
- if (s->s3->rbuf.left == 0) /* no read-ahead left? */
- {
+ if (s->s3->rbuf.left == 0) {
+ /* no read-ahead left? */
BIO *bio;
- /* In the case where we try to read application data,
- * but we trigger an SSL handshake, we return -1 with
- * the retry option set. Otherwise renegotiation may
- * cause nasty problems in the blocking world */
+ /* In the case where we try to read application data,
+ * but we trigger an SSL handshake, we return -1 with
+ * the retry option set. Otherwise renegotiation may
+ * cause nasty problems in the blocking world */
s->rwstate = SSL_READING;
bio = SSL_get_rbio(s);
BIO_clear_retry_flags(bio);
s->s3->alert_fragment_len = 0;
if (s->msg_callback)
- s->msg_callback(0, s->version, SSL3_RT_ALERT, s->s3->alert_fragment, 2, s, s->msg_callback_arg);
+ s->msg_callback(0, s->version, SSL3_RT_ALERT,
+ s->s3->alert_fragment, 2, s, s->msg_callback_arg);
if (s->info_callback != NULL)
cb = s->info_callback;
cb(s, SSL_CB_READ_ALERT, j);
}
- if (alert_level == 1) /* warning */
- {
+ if (alert_level == 1) {
+ /* warning */
s->s3->warn_alert = alert_descr;
if (alert_descr == SSL_AD_CLOSE_NOTIFY) {
s->shutdown |= SSL_RECEIVED_SHUTDOWN;
else if (alert_descr == SSL_AD_MISSING_SRP_USERNAME)
return (0);
#endif
- } else if (alert_level == 2) /* fatal */
- {
+ } else if (alert_level == 2) {
+ /* fatal */
char tmp[16];
s->rwstate = SSL_NOTHING;
goto start;
}
- if (s->shutdown & SSL_SENT_SHUTDOWN) /* but we have not received a shutdown */
- {
+ if (s->shutdown & SSL_SENT_SHUTDOWN) {
+ /* but we have not received a shutdown */
s->rwstate = SSL_NOTHING;
rr->length = 0;
return (0);
rr->length = 0;
- if (s->msg_callback)
- s->msg_callback(0, s->version, SSL3_RT_CHANGE_CIPHER_SPEC, rr->data, 1, s, s->msg_callback_arg);
+ if (s->msg_callback) {
+ s->msg_callback(0, s->version,
+ SSL3_RT_CHANGE_CIPHER_SPEC, rr->data, 1, s,
+ s->msg_callback_arg);
+ }
s->s3->change_cipher_spec = 1;
if (!ssl3_do_change_cipher_spec(s))
}
if (!(s->mode & SSL_MODE_AUTO_RETRY)) {
- if (s->s3->rbuf.left == 0) /* no read-ahead left? */
- {
+ if (s->s3->rbuf.left == 0) { /* no read-ahead left? */
BIO *bio;
/* In the case where we try to read application data,
* but we trigger an SSL handshake, we return -1 with
if (s->s3->tmp.key_block == NULL) {
if (s->session == NULL) {
/* might happen if dtls1_read_bytes() calls this */
- SSLerr(SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC, SSL_R_CCS_RECEIVED_EARLY);
+ SSLerr(SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC,
+ SSL_R_CCS_RECEIVED_EARLY);
return (0);
}
{
/* Map tls/ssl alert value to correct one */
desc = s->method->ssl3_enc->alert_value(desc);
- if (s->version == SSL3_VERSION && desc == SSL_AD_PROTOCOL_VERSION)
- desc = SSL_AD_HANDSHAKE_FAILURE; /* SSL 3.0 does not have protocol_version alerts */
+ if (s->version == SSL3_VERSION && desc == SSL_AD_PROTOCOL_VERSION) {
+ /* SSL 3.0 does not have protocol_version alerts */
+ desc = SSL_AD_HANDSHAKE_FAILURE;
+ }
if (desc < 0)
return -1;
/* If a fatal one, remove from cache */
s->s3->send_alert[1] = desc;
if (s->s3->wbuf.left == 0) /* data still being written out? */
return s->method->ssl_dispatch_alert(s);
+
/* else data is still being written out, we will get written
* some time in the future */
return -1;
(void)BIO_flush(s->wbio);
if (s->msg_callback)
- s->msg_callback(1, s->version, SSL3_RT_ALERT, s->s3->send_alert, 2, s, s->msg_callback_arg);
+ s->msg_callback(1, s->version, SSL3_RT_ALERT,
+ s->s3->send_alert, 2, s, s->msg_callback_arg);
if (s->info_callback != NULL)
cb = s->info_callback;
unsigned int len, int create_empty_fragment);
static int ssl3_get_record(SSL *s);
+/* If extend == 0, obtain new n-byte packet; if extend == 1, increase
+ * packet by another n bytes.
+ * The packet will be in the sub-array of s->s3->rbuf.buf specified
+ * by s->packet and s->packet_length.
+ * (If s->read_ahead is set, 'max' bytes may be stored in rbuf
+ * [plus s->packet_length bytes if extend == 1].)
+ */
int
ssl3_read_n(SSL *s, int n, int max, int extend)
{
- /* If extend == 0, obtain new n-byte packet; if extend == 1, increase
- * packet by another n bytes.
- * The packet will be in the sub-array of s->s3->rbuf.buf specified
- * by s->packet and s->packet_length.
- * (If s->read_ahead is set, 'max' bytes may be stored in rbuf
- * [plus s->packet_length bytes if extend == 1].)
- */
int i, len, left;
long align = 0;
unsigned char *pkt;
/* check if next packet length is large
* enough to justify payload alignment... */
pkt = rb->buf + rb->offset;
- if (pkt[0] == SSL3_RT_APPLICATION_DATA
- && (pkt[3]<<8|pkt[4]) >= 128) {
+ if (pkt[0] == SSL3_RT_APPLICATION_DATA &&
+ (pkt[3]<<8|pkt[4]) >= 128) {
/* Note that even if packet is corrupted
* and its length field is insane, we can
* only be led to wrong decision about
* Header values has no effect on memmove
* arguments and therefore no buffer
* overrun can be triggered. */
- memmove (rb->buf + align, pkt, left);
+ memmove(rb->buf + align, pkt, left);
rb->offset = align;
}
}
/* Move any available bytes to front of buffer:
* 'len' bytes already pointed to by 'packet',
* 'left' extra ones at the end */
- if (s->packet != pkt) /* len > 0 */
- {
+ if (s->packet != pkt) {
+ /* len > 0 */
memmove(pkt, s->packet, len + left);
s->packet = pkt;
rb->offset = len + align;
}
- if (n > (int)(rb->len - rb->offset)) /* does not happen */
- {
+ if (n > (int)(rb->len - rb->offset)) {
+ /* does not happen */
SSLerr(SSL_F_SSL3_READ_N, ERR_R_INTERNAL_ERROR);
return -1;
}
- if (!s->read_ahead)
+ if (!s->read_ahead) {
/* ignore max parameter */
max = n;
- else {
+ } else {
if (max < n)
max = n;
if (max > (int)(rb->len - rb->offset))
if (i <= 0) {
rb->left = left;
if (s->mode & SSL_MODE_RELEASE_BUFFERS &&
- SSL_version(s) != DTLS1_VERSION && SSL_version(s) != DTLS1_BAD_VER)
- if (len + left == 0)
- ssl3_release_read_buffer(s);
+ SSL_version(s) != DTLS1_VERSION &&
+ SSL_version(s) != DTLS1_BAD_VER)
+ if (len + left == 0)
+ ssl3_release_read_buffer(s);
return (i);
}
left += i;
/* reads should *never* span multiple packets for DTLS because
* the underlying transport protocol is message oriented as opposed
* to byte oriented as in the TLS case. */
- if (SSL_version(s) == DTLS1_VERSION || SSL_version(s) == DTLS1_BAD_VER) {
+ if (SSL_version(s) == DTLS1_VERSION ||
+ SSL_version(s) == DTLS1_BAD_VER) {
if (n > left)
n = left; /* makes the while condition false */
}
extra = SSL3_RT_MAX_EXTRA;
else
extra = 0;
+
if (extra && !s->s3->init_extra) {
/* An application error: SLS_OP_MICROSOFT_BIG_SSLV3_BUFFER
* set after ssl3_setup_buffers() was done */
if ((s->rstate != SSL_ST_READ_BODY) ||
(s->packet_length < SSL3_RT_HEADER_LENGTH)) {
n = ssl3_read_n(s, SSL3_RT_HEADER_LENGTH, s->s3->rbuf.len, 0);
- if (n <= 0) return(n); /* error or non-blocking */
- s->rstate = SSL_ST_READ_BODY;
+ if (n <= 0)
+ return(n); /* error or non-blocking */
+ s->rstate = SSL_ST_READ_BODY;
p = s->packet;
/* Lets check version */
if (!s->first_packet) {
if (version != s->version) {
- SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_WRONG_VERSION_NUMBER);
- if ((s->version & 0xFF00) == (version & 0xFF00) && !s->enc_write_ctx && !s->write_hash)
+ SSLerr(SSL_F_SSL3_GET_RECORD,
+ SSL_R_WRONG_VERSION_NUMBER);
+ if ((s->version & 0xFF00) == (version & 0xFF00) &&
+ !s->enc_write_ctx && !s->write_hash)
/* Send back error using their minor version number :-) */
- s->version = (unsigned short)version;
+ s->version = (unsigned short)version;
al = SSL_AD_PROTOCOL_VERSION;
goto f_err;
}
/* now s->packet_length == SSL3_RT_HEADER_LENGTH */
i = rr->length;
n = ssl3_read_n(s, i, i, 1);
- if (n <= 0) return(n); /* error or non-blocking io */
+ if (n <= 0)
+ return(n); /* error or non-blocking io */
/* now n == rr->length,
* and s->packet_length == SSL3_RT_HEADER_LENGTH + rr->length */
}
/* s->read_hash != NULL => mac_size != -1 */
unsigned char *mac = NULL;
unsigned char mac_tmp[EVP_MAX_MD_SIZE];
+
mac_size = EVP_MD_CTX_size(s->read_hash);
OPENSSL_assert(mac_size <= EVP_MAX_MD_SIZE);
mac = &rr->data[rr->length];
}
- i=s->method->ssl3_enc->mac(s,md,0 /* not send */);
- if (i < 0 || mac == NULL || CRYPTO_memcmp(md, mac, (size_t)mac_size) != 0)
+ i = s->method->ssl3_enc->mac(s,md,0 /* not send */);
+ if (i < 0 || mac == NULL ||
+ CRYPTO_memcmp(md, mac, (size_t)mac_size) != 0)
enc_err = -1;
if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH + extra + mac_size)
enc_err = -1;
}
rr->off = 0;
- /* So at this point the following is true
+ /*
+ * So at this point the following is true
+ *
* ssl->s3->rrec.type is the type of record
* ssl->s3->rrec.length == number of bytes in record
* ssl->s3->rrec.off == offset to first valid byte
rr = &(ssl->s3->rrec);
i = COMP_expand_block(ssl->expand, rr->comp,
- SSL3_RT_MAX_PLAIN_LENGTH, rr->data,(int)rr->length);
+ SSL3_RT_MAX_PLAIN_LENGTH, rr->data, (int)rr->length);
if (i < 0)
return (0);
else
wr = &(ssl->s3->wrec);
i = COMP_compress_block(ssl->compress, wr->data,
- SSL3_RT_MAX_COMPRESSED_LENGTH,
- wr->input,(int)wr->length);
+ SSL3_RT_MAX_COMPRESSED_LENGTH,
+ wr->input, (int)wr->length);
if (i < 0)
return (0);
else
wr->length = (int)len;
wr->input = (unsigned char *)buf;
- /* we now 'read' from wr->input, wr->length bytes into
- * wr->data */
+ /* we now 'read' from wr->input, wr->length bytes into wr->data */
/* first we compress */
if (s->compress != NULL) {
/* now let's set up wb */
wb->left = prefix_len + wr->length;
- /* memorize arguments so that ssl3_write_pending can detect bad write retries later */
+ /* memorize arguments so that ssl3_write_pending can detect
+ * bad write retries later */
s->s3->wpend_tot = len;
s->s3->wpend_buf = buf;
s->s3->wpend_type = type;
int i;
SSL3_BUFFER *wb = &(s->s3->wbuf);
-/* XXXX */
+ /* XXXX */
if ((s->s3->wpend_tot > (int)len) || ((s->s3->wpend_buf != buf) &&
!(s->mode & SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER)) ||
(s->s3->wpend_type != type)) {
return -1;
}
- if ((type == SSL3_RT_HANDSHAKE) && (s->s3->handshake_fragment_len > 0))
+ if ((type == SSL3_RT_HANDSHAKE) && (s->s3->handshake_fragment_len > 0)) {
/* (partially) satisfy request from storage */
- {
unsigned char *src = s->s3->handshake_fragment;
unsigned char *dst = buf;
unsigned int k;
start:
s->rwstate = SSL_NOTHING;
- /* s->s3->rrec.type - is the type of record
+ /*
+ * s->s3->rrec.type - is the type of record
* s->s3->rrec.data, - data
* s->s3->rrec.off, - offset into 'data' for next read
- * s->s3->rrec.length, - number of bytes. */
+ * s->s3->rrec.length, - number of bytes.
+ */
rr = &(s->s3->rrec);
/* get new packet if necessary */
}
- if (type == rr->type) /* SSL3_RT_APPLICATION_DATA or SSL3_RT_HANDSHAKE */
- {
+ if (type == rr->type) { /* SSL3_RT_APPLICATION_DATA or SSL3_RT_HANDSHAKE */
/* make sure that we are not getting application data when we
* are doing a handshake for the first time */
if (SSL_in_init(s) && (type == SSL3_RT_APPLICATION_DATA) &&
/* If we get here, then type != rr->type; if we have a handshake
* message, then it was unexpected (Hello Request or Client Hello). */
- /* In case of record types for which we have 'fragment' storage,
- * fill that so that we can process the data at a fixed place.
- */
{
+ /*
+ * In case of record types for which we have 'fragment'
+ * storage, * fill that so that we can process the data
+ * at a fixed place.
+ */
unsigned int dest_maxlen = 0;
unsigned char *dest = NULL;
unsigned int *dest_len = NULL;
}
if (s->msg_callback)
- s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, s->s3->handshake_fragment, 4, s, s->msg_callback_arg);
+ s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE,
+ s->s3->handshake_fragment, 4, s, s->msg_callback_arg);
if (SSL_is_init_finished(s) &&
!(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) &&
}
if (!(s->mode & SSL_MODE_AUTO_RETRY)) {
- if (s->s3->rbuf.left == 0) /* no read-ahead left? */
- {
+ if (s->s3->rbuf.left == 0) {
+ /* no read-ahead left? */
BIO *bio;
- /* In the case where we try to read application data,
- * but we trigger an SSL handshake, we return -1 with
- * the retry option set. Otherwise renegotiation may
- * cause nasty problems in the blocking world */
+ /* In the case where we try to read application data,
+ * but we trigger an SSL handshake, we return -1 with
+ * the retry option set. Otherwise renegotiation may
+ * cause nasty problems in the blocking world */
s->rwstate = SSL_READING;
bio = SSL_get_rbio(s);
BIO_clear_retry_flags(bio);
s->s3->alert_fragment_len = 0;
if (s->msg_callback)
- s->msg_callback(0, s->version, SSL3_RT_ALERT, s->s3->alert_fragment, 2, s, s->msg_callback_arg);
+ s->msg_callback(0, s->version, SSL3_RT_ALERT,
+ s->s3->alert_fragment, 2, s, s->msg_callback_arg);
if (s->info_callback != NULL)
cb = s->info_callback;
cb(s, SSL_CB_READ_ALERT, j);
}
- if (alert_level == 1) /* warning */
- {
+ if (alert_level == 1) {
+ /* warning */
s->s3->warn_alert = alert_descr;
if (alert_descr == SSL_AD_CLOSE_NOTIFY) {
s->shutdown |= SSL_RECEIVED_SHUTDOWN;
else if (alert_descr == SSL_AD_MISSING_SRP_USERNAME)
return (0);
#endif
- } else if (alert_level == 2) /* fatal */
- {
+ } else if (alert_level == 2) {
+ /* fatal */
char tmp[16];
s->rwstate = SSL_NOTHING;
goto start;
}
- if (s->shutdown & SSL_SENT_SHUTDOWN) /* but we have not received a shutdown */
- {
+ if (s->shutdown & SSL_SENT_SHUTDOWN) {
+ /* but we have not received a shutdown */
s->rwstate = SSL_NOTHING;
rr->length = 0;
return (0);
rr->length = 0;
- if (s->msg_callback)
- s->msg_callback(0, s->version, SSL3_RT_CHANGE_CIPHER_SPEC, rr->data, 1, s, s->msg_callback_arg);
+ if (s->msg_callback) {
+ s->msg_callback(0, s->version,
+ SSL3_RT_CHANGE_CIPHER_SPEC, rr->data, 1, s,
+ s->msg_callback_arg);
+ }
s->s3->change_cipher_spec = 1;
if (!ssl3_do_change_cipher_spec(s))
}
if (!(s->mode & SSL_MODE_AUTO_RETRY)) {
- if (s->s3->rbuf.left == 0) /* no read-ahead left? */
- {
+ if (s->s3->rbuf.left == 0) { /* no read-ahead left? */
BIO *bio;
/* In the case where we try to read application data,
* but we trigger an SSL handshake, we return -1 with
if (s->s3->tmp.key_block == NULL) {
if (s->session == NULL) {
/* might happen if dtls1_read_bytes() calls this */
- SSLerr(SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC, SSL_R_CCS_RECEIVED_EARLY);
+ SSLerr(SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC,
+ SSL_R_CCS_RECEIVED_EARLY);
return (0);
}
{
/* Map tls/ssl alert value to correct one */
desc = s->method->ssl3_enc->alert_value(desc);
- if (s->version == SSL3_VERSION && desc == SSL_AD_PROTOCOL_VERSION)
- desc = SSL_AD_HANDSHAKE_FAILURE; /* SSL 3.0 does not have protocol_version alerts */
+ if (s->version == SSL3_VERSION && desc == SSL_AD_PROTOCOL_VERSION) {
+ /* SSL 3.0 does not have protocol_version alerts */
+ desc = SSL_AD_HANDSHAKE_FAILURE;
+ }
if (desc < 0)
return -1;
/* If a fatal one, remove from cache */
s->s3->send_alert[1] = desc;
if (s->s3->wbuf.left == 0) /* data still being written out? */
return s->method->ssl_dispatch_alert(s);
+
/* else data is still being written out, we will get written
* some time in the future */
return -1;
(void)BIO_flush(s->wbio);
if (s->msg_callback)
- s->msg_callback(1, s->version, SSL3_RT_ALERT, s->s3->send_alert, 2, s, s->msg_callback_arg);
+ s->msg_callback(1, s->version, SSL3_RT_ALERT,
+ s->s3->send_alert, 2, s, s->msg_callback_arg);
if (s->info_callback != NULL)
cb = s->info_callback;