Go to the documentation of this file.
125 #include "../crypto/internal.h"
154 UniquePtr<hm_fragment> frag = MakeUnique<hm_fragment>();
158 frag->type = msg_hdr->
type;
159 frag->seq = msg_hdr->
seq;
160 frag->msg_len = msg_hdr->
msg_len;
165 if (frag->data == NULL) {
188 size_t bitmask_len = (msg_hdr->
msg_len + 7) / 8;
190 if (frag->reassembly == NULL) {
212 size_t msg_len = frag->
msg_len;
229 for (
size_t i = (
start >> 3) + 1;
i < (
end >> 3);
i++) {
232 if ((
end & 7) != 0) {
238 for (
size_t i = 0;
i < (msg_len >> 3);
i++) {
243 if ((msg_len & 7) != 0 &&
257 return frag != NULL && frag->
reassembly == NULL;
266 if (msg_hdr->
seq < ssl->
d1->handshake_read_seq ||
275 assert(frag->
seq == msg_hdr->
seq);
289 if (!ssl->
d1->incoming_messages[
idx]) {
293 return ssl->
d1->incoming_messages[
idx].get();
308 if (ssl->
s3->aead_read_ctx->is_null_cipher()) {
321 if (!ssl->
s3->aead_read_ctx->is_null_cipher()) {
334 ssl->
d1->has_change_cipher_spec =
true;
373 if (ssl->
d1->r_epoch == 1 && msg_hdr.
seq != ssl->
d1->handshake_read_seq) {
379 if (msg_hdr.
seq < ssl->
d1->handshake_read_seq ||
417 out->is_v2_hello =
false;
418 if (!ssl->
s3->has_message) {
420 ssl->
s3->has_message =
true;
426 assert(ssl->
s3->has_message);
429 ssl->
d1->incoming_messages[
index].reset();
430 ssl->
d1->handshake_read_seq++;
431 ssl->
s3->has_message =
false;
434 if (ssl->
d1->outgoing_messages_complete) {
435 ssl->
d1->flight_has_reply =
true;
443 if (ssl->
s3->has_message &&
i == current) {
447 if (ssl->
d1->incoming_messages[
i] !=
nullptr) {
473 if (!ssl->
d1->has_change_cipher_spec) {
480 if (ssl->
d1->has_change_cipher_spec) {
481 ssl->
d1->has_change_cipher_spec =
false;
496 for (
size_t i = 0;
i < ssl->
d1->outgoing_messages_len;
i++) {
497 ssl->
d1->outgoing_messages[
i].Clear();
499 ssl->
d1->outgoing_messages_len = 0;
500 ssl->
d1->outgoing_written = 0;
501 ssl->
d1->outgoing_offset = 0;
502 ssl->
d1->outgoing_messages_complete =
false;
503 ssl->
d1->flight_has_reply =
false;
539 #if defined(OPENSSL_64_BIT)
540 return v > 0xffffffff;
541 #elif defined(OPENSSL_32_BIT)
544 #error "Building for neither 32- nor 64-bits."
551 if (ssl->
d1->outgoing_messages_complete) {
559 (1 << 8 *
sizeof(ssl->
d1->outgoing_messages_len)),
560 "outgoing_messages_len is too small");
571 if (ssl->
s3->hs != NULL &&
572 !ssl->
s3->hs->transcript.Update(
data)) {
576 ssl->
d1->handshake_write_seq++;
580 &ssl->
d1->outgoing_messages[ssl->
d1->outgoing_messages_len];
584 msg->epoch = ssl->
d1->w_epoch;
585 msg->is_ccs = is_ccs;
587 ssl->
d1->outgoing_messages_len++;
608 if (mtu >= 0 && mtu <= (1 << 30) && (
unsigned)mtu >=
dtls1_min_mtu()) {
609 ssl->
d1->mtu = (unsigned)mtu;
631 size_t *out_len,
size_t max_out,
633 assert(ssl->
d1->outgoing_written < ssl->
d1->outgoing_messages_len);
634 assert(
msg == &ssl->
d1->outgoing_messages[ssl->
d1->outgoing_written]);
637 if (ssl->
d1->w_epoch >= 1 &&
msg->epoch == ssl->
d1->w_epoch - 1) {
639 }
else if (
msg->epoch != ssl->
d1->w_epoch) {
650 if (max_out <
sizeof(kChangeCipherSpec) +
overhead) {
656 sizeof(kChangeCipherSpec), use_epoch)) {
714 ssl->
d1->outgoing_offset = 0;
718 ssl->
d1->outgoing_offset +=
todo;
727 bool made_progress =
false;
729 assert(ssl->
d1->outgoing_written < ssl->
d1->outgoing_messages_len);
730 for (; ssl->
d1->outgoing_written < ssl->
d1->outgoing_messages_len;
731 ssl->
d1->outgoing_written++) {
733 &ssl->
d1->outgoing_messages[ssl->
d1->outgoing_written];
748 made_progress =
true;
759 if (!made_progress) {
774 if (ssl->
wbio ==
nullptr) {
782 if (!packet.
Init(ssl->
d1->mtu)) {
786 while (ssl->
d1->outgoing_written < ssl->
d1->outgoing_messages_len) {
787 uint8_t old_written = ssl->
d1->outgoing_written;
788 uint32_t old_offset = ssl->
d1->outgoing_offset;
798 ssl->
d1->outgoing_written = old_written;
799 ssl->
d1->outgoing_offset = old_offset;
814 ssl->
d1->outgoing_messages_complete =
true;
825 ssl->
d1->outgoing_written = 0;
826 ssl->
d1->outgoing_offset = 0;
void dtls1_start_timer(SSL *ssl)
#define SSL_R_BAD_HANDSHAKE_RECORD
#define SSL_AD_UNEXPECTED_MESSAGE
bool Init(size_t new_size)
static bool ssl_size_t_greater_than_32_bits(size_t v)
#define SSL_R_FRAGMENT_MISMATCH
ssl_open_record_t dtls1_open_change_cipher_spec(SSL *ssl, size_t *out_consumed, uint8_t *out_alert, Span< uint8_t > in)
bool dtls1_parse_fragment(CBS *cbs, struct hm_header_st *out_hdr, CBS *out_body)
bool dtls1_get_message(const SSL *ssl, SSLMessage *out)
#define SSL_R_BIO_NOT_SET
#define OPENSSL_PUT_ERROR(library, reason)
#define SSL_AD_INTERNAL_ERROR
static const BSSL_NAMESPACE_BEGIN unsigned int kMinMTU
#define BIO_CTRL_DGRAM_SET_MTU
OPENSSL_EXPORT pem_password_cb void * u
#define SSL_AD_ILLEGAL_PARAMETER
static void * OPENSSL_memset(void *dst, int c, size_t n)
size_t ssl_max_handshake_message_len(const SSL *ssl)
static enum seal_result_t seal_next_message(SSL *ssl, uint8_t *out, size_t *out_len, size_t max_out, const DTLS_OUTGOING_MESSAGE *msg)
static const unsigned int kDefaultMTU
void ssl_do_msg_callback(const SSL *ssl, int is_write, int content_type, Span< const uint8_t > in)
static hm_fragment * dtls1_get_incoming_message(SSL *ssl, uint8_t *out_alert, const struct hm_header_st *msg_hdr)
static bool add_outgoing(SSL *ssl, bool is_ccs, Array< uint8_t > data)
#define SSL_R_BAD_CHANGE_CIPHER_SPEC
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
@ ssl_open_record_discard
int dtls1_flush_flight(SSL *ssl)
bool dtls1_add_message(SSL *ssl, Array< uint8_t > data)
#define SSL_R_UNEXPECTED_RECORD
int dtls1_retransmit_outgoing_messages(SSL *ssl)
bssl::UniquePtr< BIO > wbio
static uint8_t bit_range(size_t start, size_t end)
static void dtls1_update_mtu(SSL *ssl)
static void * OPENSSL_memcpy(void *dst, const void *src, size_t n)
#define BSSL_NAMESPACE_END
#define ERR_R_INTERNAL_ERROR
static const size_t overhead
bool dtls_seal_record(SSL *ssl, uint8_t *out, size_t *out_len, size_t max_out, uint8_t type, const uint8_t *in, size_t in_len, enum dtls1_use_epoch_t use_epoch)
static int send_flight(SSL *ssl)
ssl_open_record_t dtls1_open_handshake(SSL *ssl, size_t *out_consumed, uint8_t *out_alert, Span< uint8_t > in)
#define SSL_ERROR_WANT_WRITE
#define SSL3_RT_HANDSHAKE
static bool seal_next_packet(SSL *ssl, uint8_t *out, size_t *out_len, size_t max_out)
static void dtls1_hm_fragment_mark(hm_fragment *frag, size_t start, size_t end)
OPENSSL_EXPORT bool CBBFinishArray(CBB *cbb, Array< uint8_t > *out)
#define SSL3_RT_CHANGE_CIPHER_SPEC
#define BIO_CTRL_DGRAM_QUERY_MTU
@ ssl_open_record_success
#define SSL_OP_NO_QUERY_MTU
#define SSL_AD_DECODE_ERROR
UniquePtr< SSL_SESSION > ret
size_t dtls_seal_prefix_len(const SSL *ssl, enum dtls1_use_epoch_t use_epoch)
#define SSL_R_MTU_TOO_SMALL
@ dtls1_use_current_epoch
static const char prefix[]
static bool dtls1_is_current_message_complete(const SSL *ssl)
void dtls_clear_outgoing_messages(SSL *ssl)
bool dtls1_add_change_cipher_spec(SSL *ssl)
enum ssl_open_record_t dtls_open_record(SSL *ssl, uint8_t *out_type, Span< uint8_t > *out, size_t *out_consumed, uint8_t *out_alert, Span< uint8_t > in)
bool dtls_has_unprocessed_handshake_data(const SSL *ssl)
@ dtls1_use_previous_epoch
bool dtls1_init_message(const SSL *ssl, CBB *cbb, CBB *body, uint8_t type)
void dtls1_stop_timer(SSL *ssl)
static UniquePtr< hm_fragment > dtls1_hm_fragment_new(const struct hm_header_st *msg_hdr)
#define SSL3_RT_APPLICATION_DATA
#define SSL_MAX_HANDSHAKE_FLIGHT
unsigned int dtls1_min_mtu(void)
size_t dtls_max_seal_overhead(const SSL *ssl, enum dtls1_use_epoch_t use_epoch)
constexpr Span< T > MakeSpan(T *ptr, size_t size) noexcept
#define DTLS1_HM_HEADER_LENGTH
#define ERR_R_MALLOC_FAILURE
#define SSL_R_EXCESSIVE_MESSAGE_SIZE
#define SSL_R_PROTOCOL_IS_SHUTDOWN
void dtls1_next_message(SSL *ssl)
#define CBB_add_u24_length_prefixed
bool dtls1_finish_message(const SSL *ssl, CBB *cbb, Array< uint8_t > *out_msg)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:08