}
}
- using_ktls = BIO_get_ktls_send(s->wbio);
+ using_ktls = BIO_get_ktls_send(rl->bio);
if (!ossl_assert(!using_ktls || !prefix)) {
SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
goto err;
continue;
}
clear_sys_error();
- if (s->wbio != NULL) {
+ if (rl->bio != NULL) {
s->rwstate = SSL_WRITING;
/*
* To prevent coalescing of control and data messages,
* such as in buffer_write, we flush the BIO
*/
- if (BIO_get_ktls_send(s->wbio)
+ if (BIO_get_ktls_send(rl->bio)
&& thiswb->type != SSL3_RT_APPLICATION_DATA) {
- i = BIO_flush(s->wbio);
+ i = BIO_flush(rl->bio);
if (i <= 0)
return i;
- BIO_set_ktls_ctrl_msg(s->wbio, thiswb->type);
+ BIO_set_ktls_ctrl_msg(rl->bio, thiswb->type);
}
- i = BIO_write(s->wbio, (char *)
+ i = BIO_write(rl->bio, (char *)
&(SSL3_BUFFER_get_buf(thiswb)
[SSL3_BUFFER_get_offset(thiswb)]),
(unsigned int)SSL3_BUFFER_get_left(thiswb));
{
OSSL_PARAM options[5], *opts = options;
OSSL_PARAM settings[6], *set = settings;
- const OSSL_RECORD_METHOD *origmeth = s->rlayer.rrlmethod;
const OSSL_RECORD_METHOD **thismethod;
- OSSL_RECORD_LAYER **thisrl;
+ OSSL_RECORD_LAYER **thisrl, *newrl = NULL;
BIO *thisbio;
SSL_CTX *sctx = SSL_CONNECTION_GET_CTX(s);
const OSSL_RECORD_METHOD *meth;
thisbio = s->wbio;
}
- if (*thismethod != NULL && !(*thismethod)->free(*thisrl)) {
- ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
- return 0;
- }
-
- *thisrl = NULL;
- if (meth != NULL)
- *thismethod = meth;
+ if (meth == NULL)
+ meth = *thismethod;
- if (!ossl_assert(*thismethod != NULL)) {
+ if (!ossl_assert(meth != NULL)) {
ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
return 0;
}
BIO *next = NULL;
unsigned int epoch = 0;;
-
if (direction == OSSL_RECORD_DIRECTION_READ) {
prev = s->rlayer.rrlnext;
if (SSL_CONNECTION_IS_DTLS(s)
s->rlayer.rrlnext = next;
}
- rlret = (*thismethod)->new_record_layer(sctx->libctx,
- sctx->propq,
- version, s->server,
- direction, level, epoch,
- key, keylen, iv, ivlen,
- mackey, mackeylen, ciph,
- taglen, mactype, md, comp,
- prev, thisbio,
- next, NULL,
- NULL, settings, options,
- rlayer_dispatch, s,
- thisrl);
+ rlret = meth->new_record_layer(sctx->libctx, sctx->propq, version,
+ s->server, direction, level, epoch,
+ key, keylen, iv, ivlen, mackey,
+ mackeylen, ciph, taglen, mactype, md,
+ comp, prev, thisbio, next, NULL, NULL,
+ settings, options, rlayer_dispatch, s,
+ &newrl);
BIO_free(prev);
switch (rlret) {
case OSSL_RECORD_RETURN_FATAL:
return 0;
case OSSL_RECORD_RETURN_NON_FATAL_ERR:
- if (*thismethod != origmeth && origmeth != NULL) {
+ if (*thismethod != meth && *thismethod != NULL) {
/*
* We tried a new record layer method, but it didn't work out,
* so we fallback to the original method and try again
*/
- *thismethod = origmeth;
+ meth = *thismethod;
continue;
}
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_R_NO_SUITABLE_RECORD_LAYER);
break;
}
+ if (*thismethod != NULL && !(*thismethod)->free(*thisrl)) {
+ SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
+ return 0;
+ }
+
+ *thisrl = newrl;
+ *thismethod = meth;
+
return ssl_post_record_layer_select(s, direction);
}
X509_VERIFY_PARAM_free(s->param);
dane_final(&s->dane);
- RECORD_LAYER_clear(&s->rlayer);
-
/* Ignore return value */
ssl_free_wbio_buffer(s);
BIO_free_all(s->rbio);
s->rbio = NULL;
+ RECORD_LAYER_clear(&s->rlayer);
+
BUF_MEM_free(s->init_buf);
/* add extra stuff */
/* Re-attach |bbio| to the new |wbio|. */
if (sc->bbio != NULL)
sc->wbio = BIO_push(sc->bbio, sc->wbio);
+
+ sc->rlayer.wrlmethod->set1_bio(sc->rlayer.wrl, sc->wbio);
}
void SSL_set_bio(SSL *s, BIO *rbio, BIO *wbio)
s->bbio = bbio;
s->wbio = BIO_push(bbio, s->wbio);
+ s->rlayer.wrlmethod->set1_bio(s->rlayer.wrl, s->wbio);
+
return 1;
}
return 1;
s->wbio = BIO_pop(s->wbio);
+ s->rlayer.wrlmethod->set1_bio(s->rlayer.wrl, s->wbio);
+
BIO_free(s->bbio);
s->bbio = NULL;