($INBOX_DIR/description missing)
 help / color / mirror / Atom feed
From: Andrew Zaborowski <andrew.zaborowski@intel.com>
To: ell@lists.linux.dev
Subject: [PATCH] tls: Add l_tls_get_session_resumed
Date: Fri, 30 Dec 2022 17:47:01 +0100	[thread overview]
Message-ID: <20221230164701.1095865-1-andrew.zaborowski@intel.com> (raw)

---
 ell/ell.sym       |  1 +
 ell/tls-private.h |  1 +
 ell/tls.c         | 10 ++++++++++
 ell/tls.h         |  1 +
 4 files changed, 13 insertions(+)

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);
 
-- 
2.34.1


             reply	other threads:[~2022-12-30 16:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-30 16:47 Andrew Zaborowski [this message]
2022-12-30 17:35 ` [PATCH] tls: Add l_tls_get_session_resumed Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221230164701.1095865-1-andrew.zaborowski@intel.com \
    --to=andrew.zaborowski@intel.com \
    --cc=ell@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).