aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorFrederik Wedel-Heinen <[email protected]>2024-02-22 08:09:38 +0100
committerMatt Caswell <[email protected]>2026-08-25 13:41:24 +0200
commita99dd7aec58f1e07d032fb19ff3e203b6ba1b2da (patch)
treeb3bbf608079d9a426a4927845d955a8122f5a696 /include
parentRevert changes to ssl_version_cmp() to avoid calling assert on non-sane inputs (diff)
downloadopenssl-a99dd7aec58f1e07d032fb19ff3e203b6ba1b2da.tar.gz
openssl-a99dd7aec58f1e07d032fb19ff3e203b6ba1b2da.zip
Adds DTLS 1.3 ACK message functionality
Reviewed-by: Matt Caswell <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> (Merged from https://github.com/openssl/openssl/pull/25119)
Diffstat (limited to 'include')
-rw-r--r--include/internal/packet.h33
-rw-r--r--include/internal/recordmethod.h4
-rw-r--r--include/internal/statem.h2
-rw-r--r--include/openssl/ssl.h.in6
-rw-r--r--include/openssl/ssl3.h4
5 files changed, 47 insertions, 2 deletions
diff --git a/include/internal/packet.h b/include/internal/packet.h
index 7defbde1f06..e15e0db83c0 100644
--- a/include/internal/packet.h
+++ b/include/internal/packet.h
@@ -244,6 +244,37 @@ __owur static ossl_inline int PACKET_peek_net_4(const PACKET *pkt,
}
/*
+ * Peek ahead at 6 bytes in network order from |pkt| and store the value in
+ * |*data|
+ */
+__owur static ossl_inline int PACKET_peek_net_6(const PACKET *pkt,
+ uint64_t *data)
+{
+ if (PACKET_remaining(pkt) < 6)
+ return 0;
+
+ *data = ((uint64_t)(*(pkt->curr))) << 40;
+ *data |= ((uint64_t)(*(pkt->curr + 1))) << 32;
+ *data |= ((uint64_t)(*(pkt->curr + 2))) << 24;
+ *data |= ((uint64_t)(*(pkt->curr + 3))) << 16;
+ *data |= ((uint64_t)(*(pkt->curr + 4))) << 8;
+ *data |= *(pkt->curr + 5);
+
+ return 1;
+}
+
+/* Get 6 bytes in network order from |pkt| and store the value in |*data| */
+__owur static ossl_inline int PACKET_get_net_6(PACKET *pkt, uint64_t *data)
+{
+ if (!PACKET_peek_net_6(pkt, data))
+ return 0;
+
+ packet_forward(pkt, 6);
+
+ return 1;
+}
+
+/*
* Peek ahead at 8 bytes in network order from |pkt| and store the value in
* |*data|
*/
@@ -925,6 +956,8 @@ int WPACKET_put_bytes__(WPACKET *pkt, uint64_t val, size_t bytes);
WPACKET_put_bytes__((pkt), (val), 3)
#define WPACKET_put_bytes_u32(pkt, val) \
WPACKET_put_bytes__((pkt), (val), 4)
+#define WPACKET_put_bytes_u48(pkt, val) \
+ WPACKET_put_bytes__((pkt), (val), 6)
#define WPACKET_put_bytes_u64(pkt, val) \
WPACKET_put_bytes__((pkt), (val), 8)
diff --git a/include/internal/recordmethod.h b/include/internal/recordmethod.h
index 1d2fe62709f..8f07f71512d 100644
--- a/include/internal/recordmethod.h
+++ b/include/internal/recordmethod.h
@@ -56,6 +56,8 @@ typedef struct ossl_record_layer_st OSSL_RECORD_LAYER;
struct ossl_record_template_st {
unsigned char type;
unsigned int version;
+ uint64_t sequence_number;
+ uint64_t epoch;
const unsigned char *buf;
size_t buflen;
};
@@ -225,7 +227,7 @@ struct ossl_record_method_st {
*/
int (*read_record)(OSSL_RECORD_LAYER *rl, void **rechandle, int *rversion,
uint8_t *type, const unsigned char **data, size_t *datalen,
- uint16_t *epoch, unsigned char *seq_num);
+ uint16_t *epoch, uint64_t *seq_num);
/*
* Release length bytes from a buffer associated with a record previously
* read with read_record. Once all the bytes from a record are released, the
diff --git a/include/internal/statem.h b/include/internal/statem.h
index 990100c4dc0..e39b497e040 100644
--- a/include/internal/statem.h
+++ b/include/internal/statem.h
@@ -117,6 +117,8 @@ struct ossl_statem_st {
OSSL_HANDSHAKE_STATE hand_state;
/* The handshake state requested by an API call (e.g. HelloRequest) */
OSSL_HANDSHAKE_STATE request_state;
+ /* The handshake state waiting for acknowledge */
+ OSSL_HANDSHAKE_STATE deferred_ack_state;
ERROR_STATE error_state;
int in_init;
int read_state_first_init;
diff --git a/include/openssl/ssl.h.in b/include/openssl/ssl.h.in
index 4aea50611fc..84655d316a5 100644
--- a/include/openssl/ssl.h.in
+++ b/include/openssl/ssl.h.in
@@ -1097,7 +1097,11 @@ typedef enum {
TLS_ST_EARLY_DATA,
TLS_ST_PENDING_EARLY_DATA_END,
TLS_ST_CW_END_OF_EARLY_DATA,
- TLS_ST_SR_END_OF_EARLY_DATA
+ TLS_ST_SR_END_OF_EARLY_DATA,
+ TLS_ST_CR_ACK,
+ TLS_ST_CW_ACK,
+ TLS_ST_SR_ACK,
+ TLS_ST_SW_ACK
} OSSL_HANDSHAKE_STATE;
/*
diff --git a/include/openssl/ssl3.h b/include/openssl/ssl3.h
index f35b6eadb0f..88eec3063c9 100644
--- a/include/openssl/ssl3.h
+++ b/include/openssl/ssl3.h
@@ -220,6 +220,7 @@ extern "C" {
#define SSL3_RT_ALERT 21
#define SSL3_RT_HANDSHAKE 22
#define SSL3_RT_APPLICATION_DATA 23
+#define SSL3_RT_ACK 26 /* RFC 9147 */
/* Pseudo content types to indicate additional parameters */
#define TLS1_RT_CRYPTO 0x1000
@@ -333,6 +334,9 @@ extern "C" {
#define SSL3_MT_MESSAGE_HASH 254
#define DTLS1_MT_HELLO_VERIFY_REQUEST 3
+/* Dummy message type for handling ACK like a normal handshake message */
+#define DTLS13_MT_ACK 0x0126
+
/* Dummy message type for handling CCS like a normal handshake message */
#define SSL3_MT_CHANGE_CIPHER_SPEC 0x0101