From 86e2d5e29ba1dbe285e78ac4cdf421933da4a474 Mon Sep 17 00:00:00 2001 From: Amir Khan Date: Thu, 11 Jul 2024 14:32:43 -0400 Subject: [PATCH 1/4] Add setters for SessionState fields createdAt, UseBy, and AgeAdd --- u_public.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/u_public.go b/u_public.go index cdcd6eeb..bc0e8193 100644 --- a/u_public.go +++ b/u_public.go @@ -691,6 +691,12 @@ func (css *ClientSessionState) SetCipherSuite(CipherSuite uint16) { } css.session.cipherSuite = CipherSuite } +func (css *ClientSessionState) SetCreatedAt(createdAt uint64) { + if css.session == nil { + css.session = &SessionState{} + } + css.session.createdAt = createdAt +} func (css *ClientSessionState) SetMasterSecret(MasterSecret []byte) { if css.session == nil { css.session = &SessionState{} @@ -715,6 +721,18 @@ func (css *ClientSessionState) SetVerifiedChains(VerifiedChains [][]*x509.Certif } css.session.verifiedChains = VerifiedChains } +func (css *ClientSessionState) SetUseBy(useBy uint64) { + if css.session == nil { + css.session = &SessionState{} + } + css.session.useBy = useBy +} +func (css *ClientSessionState) SetAgeAdd(ageAdd uint32) { + if css.session == nil { + css.session = &SessionState{} + } + css.session.ageAdd = ageAdd +} // TicketKey is the internal representation of a session ticket key. type TicketKey struct { From f317de5eee26cc2fe740bdc0d644c75a6b7b6180 Mon Sep 17 00:00:00 2001 From: Amir Khan Date: Mon, 15 Jul 2024 12:33:42 -0400 Subject: [PATCH 2/4] chore: remove accidental comments from code --- u_public.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/u_public.go b/u_public.go index bc0e8193..fbb912fb 100644 --- a/u_public.go +++ b/u_public.go @@ -617,9 +617,6 @@ func (PSS PskIdentities) ToPrivate() []pskIdentity { // ClientSessionState is public, but all its fields are private. Let's add setters, getters and constructor -// TODO! can we change this enought (or export SessionState), -// such that we wouldn't need to fork crypto/tls? - // ClientSessionState contains the state needed by clients to resume TLS sessions. func MakeClientSessionState( SessionTicket []uint8, From e39486f81c8de075ff4c9a7f9869224dd57e47b9 Mon Sep 17 00:00:00 2001 From: Amir Khan Date: Mon, 15 Jul 2024 13:05:29 -0400 Subject: [PATCH 3/4] fix: incorrect clientHelloBuildStatus after BuildHandshakeStateWithoutSession --- u_conn.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/u_conn.go b/u_conn.go index f683c05c..49cc0f0e 100644 --- a/u_conn.go +++ b/u_conn.go @@ -154,9 +154,9 @@ func (uconn *UConn) buildHandshakeState(loadSession bool) error { if loadSession { uconn.uApplyPatch() uconn.sessionController.finalCheck() + uconn.clientHelloBuildStatus = BuildByUtls } - uconn.clientHelloBuildStatus = BuildByUtls } return nil } From 47ec1e900565e4432672ae5bd04630a782903d40 Mon Sep 17 00:00:00 2001 From: Gaukas Wang Date: Mon, 15 Jul 2024 21:45:33 -0600 Subject: [PATCH 4/4] chore: add empty lines between functions Signed-off-by: Gaukas Wang --- u_public.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/u_public.go b/u_public.go index fbb912fb..51265300 100644 --- a/u_public.go +++ b/u_public.go @@ -676,54 +676,63 @@ func (css *ClientSessionState) VerifiedChains() [][]*x509.Certificate { func (css *ClientSessionState) SetSessionTicket(SessionTicket []uint8) { css.ticket = SessionTicket } + func (css *ClientSessionState) SetVers(Vers uint16) { if css.session == nil { css.session = &SessionState{} } css.session.version = Vers } + func (css *ClientSessionState) SetCipherSuite(CipherSuite uint16) { if css.session == nil { css.session = &SessionState{} } css.session.cipherSuite = CipherSuite } + func (css *ClientSessionState) SetCreatedAt(createdAt uint64) { if css.session == nil { css.session = &SessionState{} } css.session.createdAt = createdAt } + func (css *ClientSessionState) SetMasterSecret(MasterSecret []byte) { if css.session == nil { css.session = &SessionState{} } css.session.secret = MasterSecret } + func (css *ClientSessionState) SetEMS(ems bool) { if css.session == nil { css.session = &SessionState{} } css.session.extMasterSecret = ems } + func (css *ClientSessionState) SetServerCertificates(ServerCertificates []*x509.Certificate) { if css.session == nil { css.session = &SessionState{} } css.session.peerCertificates = ServerCertificates } + func (css *ClientSessionState) SetVerifiedChains(VerifiedChains [][]*x509.Certificate) { if css.session == nil { css.session = &SessionState{} } css.session.verifiedChains = VerifiedChains } + func (css *ClientSessionState) SetUseBy(useBy uint64) { if css.session == nil { css.session = &SessionState{} } css.session.useBy = useBy } + func (css *ClientSessionState) SetAgeAdd(ageAdd uint32) { if css.session == nil { css.session = &SessionState{}