int ossl_quic_channel_is_active(const QUIC_CHANNEL *ch);
int ossl_quic_channel_is_handshake_complete(const QUIC_CHANNEL *ch);
+SSL *ossl_quic_channel_get0_ssl(QUIC_CHANNEL *ch);
+
# endif
#endif
# include <openssl/ssl.h>
# include "internal/quic_stream.h"
# include "internal/quic_channel.h"
+# include "internal/statem.h"
# ifndef OPENSSL_NO_QUIC
void ossl_quic_tserver_free(QUIC_TSERVER *srv);
/* Set mutator callbacks for test framework support */
-int ossl_quic_tserver_set_mutator(QUIC_TSERVER *srv,
- ossl_mutate_packet_cb mutatecb,
- ossl_finish_mutate_cb finishmutatecb,
- void *mutatearg);
+int ossl_quic_tserver_set_plain_packet_mutator(QUIC_TSERVER *srv,
+ ossl_mutate_packet_cb mutatecb,
+ ossl_finish_mutate_cb finishmutatecb,
+ void *mutatearg);
+
+int ossl_quic_tserver_set_handshake_mutator(QUIC_TSERVER *srv,
+ ossl_statem_mutate_handshake_cb mutate_handshake_cb,
+ ossl_statem_finish_mutate_handshake_cb finish_mutate_handshake_cb,
+ void *mutatearg);
/* Advances the state machine. */
int ossl_quic_tserver_tick(QUIC_TSERVER *srv);
CON_FUNC_DONT_SEND
} CON_FUNC_RETURN;
+typedef int (*ossl_statem_mutate_handshake_cb)(unsigned char *msgin,
+ size_t inlen,
+ unsigned char **msgout,
+ size_t *outlen,
+ void *arg);
+
+typedef void (*ossl_statem_finish_mutate_handshake_cb)(void *arg);
+
/*****************************************************************************
* *
* This structure should be considered "opaque" to anything outside of the *
/* Should we skip the CertificateVerify message? */
unsigned int no_cert_verify;
int use_timer;
+
+ /* Test harness message mutator callbacks */
+ ossl_statem_mutate_handshake_cb mutate_handshake_cb;
+ ossl_statem_finish_mutate_handshake_cb finish_mutate_handshake_cb;
+ void *mutatearg;
+ unsigned int write_in_progress : 1;
};
typedef struct ossl_statem_st OSSL_STATEM;
* *
*****************************************************************************/
+typedef struct ssl_connection_st SSL_CONNECTION;
+
__owur int ossl_statem_accept(SSL *s);
__owur int ossl_statem_connect(SSL *s);
OSSL_HANDSHAKE_STATE ossl_statem_get_state(SSL_CONNECTION *s);
/* Flush the write BIO */
int statem_flush(SSL_CONNECTION *s);
+
+int ossl_statem_set_mutator(SSL *s,
+ ossl_statem_mutate_handshake_cb mutate_handshake_cb,
+ ossl_statem_finish_mutate_handshake_cb finish_mutate_handshake_cb,
+ void *mutatearg);
ch->doing_proactive_ver_neg = 0; /* not currently supported */
return 1;
}
+
+SSL *ossl_quic_channel_get0_ssl(QUIC_CHANNEL *ch)
+{
+ return ch->tls;
+}
}
/* Set mutator callbacks for test framework support */
-int ossl_quic_tserver_set_mutator(QUIC_TSERVER *srv,
- ossl_mutate_packet_cb mutatecb,
- ossl_finish_mutate_cb finishmutatecb,
- void *mutatearg)
+int ossl_quic_tserver_set_plain_packet_mutator(QUIC_TSERVER *srv,
+ ossl_mutate_packet_cb mutatecb,
+ ossl_finish_mutate_cb finishmutatecb,
+ void *mutatearg)
{
return ossl_quic_channel_set_mutator(srv->ch, mutatecb, finishmutatecb,
mutatearg);
}
+int ossl_quic_tserver_set_handshake_mutator(QUIC_TSERVER *srv,
+ ossl_statem_mutate_handshake_cb mutate_handshake_cb,
+ ossl_statem_finish_mutate_handshake_cb finish_mutate_handshake_cb,
+ void *mutatearg)
+{
+ return ossl_statem_set_mutator(ossl_quic_channel_get0_ssl(srv->ch),
+ mutate_handshake_cb,
+ finish_mutate_handshake_cb,
+ mutatearg);
+}
+
int ossl_quic_tserver_tick(QUIC_TSERVER *srv)
{
ossl_quic_reactor_tick(ossl_quic_channel_get_reactor(srv->ch));
# include <openssl/ct.h>
# include "record/record.h"
# include "internal/recordmethod.h"
-# include "statem/statem.h"
+# include "internal/statem.h"
# include "internal/packet.h"
# include "internal/dane.h"
# include "internal/refcount.h"
0x07, 0x9e, 0x09, 0xe2, 0xc8, 0xa8, 0x33, 0x9c
};
+int ossl_statem_set_mutator(SSL *s,
+ ossl_statem_mutate_handshake_cb mutate_handshake_cb,
+ ossl_statem_finish_mutate_handshake_cb finish_mutate_handshake_cb,
+ void *mutatearg)
+{
+ SSL_CONNECTION *sc = SSL_CONNECTION_FROM_SSL(s);
+
+ if (sc == NULL)
+ return 0;
+
+ sc->statem.mutate_handshake_cb = mutate_handshake_cb;
+ sc->statem.mutatearg = mutatearg;
+ sc->statem.finish_mutate_handshake_cb = finish_mutate_handshake_cb;
+
+ return 1;
+}
+
/*
* send s->init_buf in records of type 'type' (SSL3_RT_HANDSHAKE or
* SSL3_RT_CHANGE_CIPHER_SPEC)
size_t written = 0;
SSL *ssl = SSL_CONNECTION_GET_SSL(s);
+ /*
+ * If we're running the test suite then we may need to mutate the message
+ * we've been asked to write. Does not happen in normal operation.
+ */
+ if (s->statem.mutate_handshake_cb != NULL
+ && !s->statem.write_in_progress
+ && type == SSL3_RT_HANDSHAKE
+ && s->init_num >= SSL3_HM_HEADER_LENGTH) {
+ unsigned char *msg;
+ size_t msglen;
+
+ if (!s->statem.mutate_handshake_cb((unsigned char *)s->init_buf->data,
+ s->init_num,
+ &msg, &msglen,
+ s->statem.mutatearg))
+ return -1;
+ if (msglen < SSL3_HM_HEADER_LENGTH
+ || !BUF_MEM_grow(s->init_buf, msglen))
+ return -1;
+ memcpy(s->init_buf->data, msg, msglen);
+ s->init_num = msglen;
+ s->init_msg = s->init_buf->data + SSL3_HM_HEADER_LENGTH;
+ s->statem.finish_mutate_handshake_cb(s->statem.mutatearg);
+ s->statem.write_in_progress = 1;
+ }
+
ret = ssl3_write_bytes(ssl, type, &s->init_buf->data[s->init_off],
s->init_num, &written);
if (ret < 0)
written))
return -1;
if (written == s->init_num) {
+ s->statem.write_in_progress = 0;
if (s->msg_callback)
s->msg_callback(1, s->version, type, s->init_buf->data,
(size_t)(s->init_off + s->init_num), ssl,
fault->pplaincb = pplaincb;
fault->pplaincbarg = pplaincbarg;
- return ossl_quic_tserver_set_mutator(fault->qtserv, packet_plain_mutate,
- packet_plain_finish, fault);
+ return ossl_quic_tserver_set_plain_packet_mutator(fault->qtserv,
+ packet_plain_mutate,
+ packet_plain_finish,
+ fault);
}
/* To be called from a packet_plain_listener callback */