tls_get_max_records_default,
tls_write_records_default,
ktls_allocate_write_buffers,
- ktls_initialise_write_packets
+ ktls_initialise_write_packets,
+ NULL
};
const OSSL_RECORD_METHOD ossl_ktls_record_method = {
WPACKET *pkt,
SSL3_BUFFER *bufs,
size_t *wpinited);
+
+ /* Get the actual record type to be used for a given template */
+ unsigned int (*get_record_type)(OSSL_RECORD_LAYER *rl,
+ OSSL_RECORD_TEMPLATE *template);
};
struct ossl_record_layer_st
tls_write_records_default,
/* These 2 functions are defined in tls1_meth.c */
tls1_allocate_write_buffers,
- tls1_initialise_write_packets
+ tls1_initialise_write_packets,
+ NULL
};
return 1;
}
+static unsigned int tls13_get_record_type(OSSL_RECORD_LAYER *rl,
+ OSSL_RECORD_TEMPLATE *template)
+{
+ if (rl->allow_plain_alerts && template->type == SSL3_RT_ALERT)
+ return SSL3_RT_ALERT;
+
+ /*
+ * Aside from the above case we always use the application data record type
+ * when encrypting in TLSv1.3. The "inner" record type encodes the "real"
+ * record type from the template.
+ */
+ return SSL3_RT_APPLICATION_DATA;
+}
+
struct record_functions_st tls_1_3_funcs = {
tls13_set_crypto_state,
tls13_cipher,
tls_get_max_records_default,
tls_write_records_default,
tls_allocate_write_buffers_default,
- tls_initialise_write_packets_default
+ tls_initialise_write_packets_default,
+ tls13_get_record_type
};
tls_get_max_records_multiblock,
tls_write_records_multiblock, /* Defined in tls_multib.c */
tls1_allocate_write_buffers,
- tls1_initialise_write_packets
+ tls1_initialise_write_packets,
+ NULL
};
struct record_functions_st dtls_1_funcs = {
NULL,
NULL,
NULL,
+ NULL,
NULL
};
thistempl = (j < prefix) ? &prefixtempl : &templates[j - prefix];
/*
- * In TLSv1.3, once encrypting, we always use application data for the
- * record type
+ * Default to the record type as specified in the template unless the
+ * protocol implementation says differently.
*/
- if (rl->version == TLS1_3_VERSION
- && rl->enc_ctx != NULL
- && (!rl->allow_plain_alerts
- || thistempl->type != SSL3_RT_ALERT))
- rectype = SSL3_RT_APPLICATION_DATA;
+ if (rl->funcs->get_record_type != NULL)
+ rectype = rl->funcs->get_record_type(rl, thistempl);
else
rectype = thistempl->type;
tls_get_max_records_default,
tls_write_records_default,
tls_allocate_write_buffers_default,
- tls_initialise_write_packets_default
+ tls_initialise_write_packets_default,
+ NULL
};
static int dtls_any_set_protocol_version(OSSL_RECORD_LAYER *rl, int vers)
NULL,
NULL,
NULL,
+ NULL,
NULL
};