Skip to content

Commit

Permalink
Add public getter/setter for SessionState.extMasterSecret
Browse files Browse the repository at this point in the history
  • Loading branch information
adotkhan committed Jun 19, 2024
1 parent ebe5d66 commit 01c746c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/old/examples.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ func HttpGetTicket(hostname string, addr string) (*http.Response, error) {
sessionState := tls.MakeClientSessionState(sessionTicket, uint16(tls.VersionTLS12),
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
masterSecret,
false,
nil, nil)

err = uTlsConn.SetSessionState(sessionState)
Expand Down Expand Up @@ -172,6 +173,7 @@ func HttpGetTicketHelloID(hostname string, addr string, helloID tls.ClientHelloI
sessionState := tls.MakeClientSessionState(sessionTicket, uint16(tls.VersionTLS12),
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
masterSecret,
false,
nil, nil)

uTlsConn.SetSessionState(sessionState)
Expand Down
12 changes: 12 additions & 0 deletions u_public.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ func MakeClientSessionState(
Vers uint16,
CipherSuite uint16,
MasterSecret []byte,
ExtMasterSecret bool,
ServerCertificates []*x509.Certificate,
VerifiedChains [][]*x509.Certificate) *ClientSessionState {
css := &ClientSessionState{
Expand All @@ -631,6 +632,7 @@ func MakeClientSessionState(
version: Vers,
cipherSuite: CipherSuite,
secret: MasterSecret,
extMasterSecret: ExtMasterSecret,
peerCertificates: ServerCertificates,
verifiedChains: VerifiedChains,
},
Expand Down Expand Up @@ -658,6 +660,10 @@ func (css *ClientSessionState) MasterSecret() []byte {
return css.session.secret
}

func (css *ClientSessionState) ExtMasterSecret() bool {
return css.session.extMasterSecret
}

// Certificate chain presented by the server
func (css *ClientSessionState) ServerCertificates() []*x509.Certificate {
return css.session.peerCertificates
Expand Down Expand Up @@ -689,6 +695,12 @@ func (css *ClientSessionState) SetMasterSecret(MasterSecret []byte) {
}
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{}
Expand Down

0 comments on commit 01c746c

Please sign in to comment.