diff mbox series

tls: Add l_tls_get_session_resumed

Message ID 20221230164701.1095865-1-andrew.zaborowski@intel.com (mailing list archive)
State Accepted, archived
Headers show
Series tls: Add l_tls_get_session_resumed | expand

Commit Message

Andrew Zaborowski Dec. 30, 2022, 4:47 p.m. UTC
---
 ell/ell.sym       |  1 +
 ell/tls-private.h |  1 +
 ell/tls.c         | 10 ++++++++++
 ell/tls.h         |  1 +
 4 files changed, 13 insertions(+)

Comments

Denis Kenzior Dec. 30, 2022, 5:35 p.m. UTC | #1
Hi Andrew,

On 12/30/22 10:47, Andrew Zaborowski wrote:
> ---
>   ell/ell.sym       |  1 +
>   ell/tls-private.h |  1 +
>   ell/tls.c         | 10 ++++++++++
>   ell/tls.h         |  1 +
>   4 files changed, 13 insertions(+)
> 

Applied, thanks.

Regards,
-Denis
diff mbox series

Patch

diff --git a/ell/ell.sym b/ell/ell.sym
index 6c836e1..4d8596e 100644
--- a/ell/ell.sym
+++ b/ell/ell.sym
@@ -519,6 +519,7 @@  global:
 	l_tls_set_version_range;
 	l_tls_set_domain_mask;
 	l_tls_set_session_cache;
+	l_tls_get_session_resumed;
 	l_tls_alert_to_str;
 	l_tls_set_debug;
 	l_tls_set_cert_dump_path;
diff --git a/ell/tls-private.h b/ell/tls-private.h
index 6a9bd29..46889ad 100644
--- a/ell/tls-private.h
+++ b/ell/tls-private.h
@@ -266,6 +266,7 @@  struct l_tls {
 	uint8_t session_cipher_suite_id[2];
 	uint8_t session_compression_method_id;
 	char *session_peer_identity;
+	bool session_resumed;
 
 	struct {
 		bool secure_renegotiation;
diff --git a/ell/tls.c b/ell/tls.c
index d363765..72ff4d7 100644
--- a/ell/tls.c
+++ b/ell/tls.c
@@ -213,6 +213,7 @@  static void tls_reset_handshake(struct l_tls *tls)
 	tls->session_id_size_replaced = 0;
 	tls->session_id_new = false;
 	l_free(l_steal_ptr(tls->session_peer_identity));
+	tls->session_resumed = false;
 }
 
 static void tls_cleanup_handshake(struct l_tls *tls)
@@ -3058,6 +3059,7 @@  static void tls_finished(struct l_tls *tls)
 
 	TLS_SET_STATE(TLS_HANDSHAKE_DONE);
 	tls->ready = true;
+	tls->session_resumed = resuming;
 
 	if (session_update && tls->session_update_cb) {
 		tls->in_callback = true;
@@ -3841,6 +3843,14 @@  LIB_EXPORT void l_tls_set_session_cache(struct l_tls *tls,
 	tls->session_prefix = l_strdup(group_prefix);
 }
 
+LIB_EXPORT bool l_tls_get_session_resumed(struct l_tls *tls)
+{
+	if (unlikely(!tls || !tls->ready))
+		return false;
+
+	return tls->session_resumed;
+}
+
 LIB_EXPORT const char *l_tls_alert_to_str(enum l_tls_alert_desc desc)
 {
 	switch (desc) {
diff --git a/ell/tls.h b/ell/tls.h
index e688c7c..6964380 100644
--- a/ell/tls.h
+++ b/ell/tls.h
@@ -134,6 +134,7 @@  void l_tls_set_session_cache(struct l_tls *tls, struct l_settings *settings,
 				unsigned int max_sessions,
 				l_tls_session_update_cb_t update_cb,
 				void *user_data);
+bool l_tls_get_session_resumed(struct l_tls *tls);
 
 const char *l_tls_alert_to_str(enum l_tls_alert_desc desc);