Add public getter/setter for SessionState.extMasterSecret

This commit is contained in:
Amir Khan 2024-06-19 13:45:00 -04:00
parent ebe5d664d2
commit 01c746c919
2 changed files with 14 additions and 0 deletions

View file

@ -138,6 +138,7 @@ func HttpGetTicket(hostname string, addr string) (*http.Response, error) {
sessionState := tls.MakeClientSessionState(sessionTicket, uint16(tls.VersionTLS12), sessionState := tls.MakeClientSessionState(sessionTicket, uint16(tls.VersionTLS12),
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
masterSecret, masterSecret,
false,
nil, nil) nil, nil)
err = uTlsConn.SetSessionState(sessionState) err = uTlsConn.SetSessionState(sessionState)
@ -172,6 +173,7 @@ func HttpGetTicketHelloID(hostname string, addr string, helloID tls.ClientHelloI
sessionState := tls.MakeClientSessionState(sessionTicket, uint16(tls.VersionTLS12), sessionState := tls.MakeClientSessionState(sessionTicket, uint16(tls.VersionTLS12),
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
masterSecret, masterSecret,
false,
nil, nil) nil, nil)
uTlsConn.SetSessionState(sessionState) uTlsConn.SetSessionState(sessionState)

View file

@ -623,6 +623,7 @@ func MakeClientSessionState(
Vers uint16, Vers uint16,
CipherSuite uint16, CipherSuite uint16,
MasterSecret []byte, MasterSecret []byte,
ExtMasterSecret bool,
ServerCertificates []*x509.Certificate, ServerCertificates []*x509.Certificate,
VerifiedChains [][]*x509.Certificate) *ClientSessionState { VerifiedChains [][]*x509.Certificate) *ClientSessionState {
css := &ClientSessionState{ css := &ClientSessionState{
@ -631,6 +632,7 @@ func MakeClientSessionState(
version: Vers, version: Vers,
cipherSuite: CipherSuite, cipherSuite: CipherSuite,
secret: MasterSecret, secret: MasterSecret,
extMasterSecret: ExtMasterSecret,
peerCertificates: ServerCertificates, peerCertificates: ServerCertificates,
verifiedChains: VerifiedChains, verifiedChains: VerifiedChains,
}, },
@ -658,6 +660,10 @@ func (css *ClientSessionState) MasterSecret() []byte {
return css.session.secret return css.session.secret
} }
func (css *ClientSessionState) ExtMasterSecret() bool {
return css.session.extMasterSecret
}
// Certificate chain presented by the server // Certificate chain presented by the server
func (css *ClientSessionState) ServerCertificates() []*x509.Certificate { func (css *ClientSessionState) ServerCertificates() []*x509.Certificate {
return css.session.peerCertificates return css.session.peerCertificates
@ -689,6 +695,12 @@ func (css *ClientSessionState) SetMasterSecret(MasterSecret []byte) {
} }
css.session.secret = MasterSecret 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) { func (css *ClientSessionState) SetServerCertificates(ServerCertificates []*x509.Certificate) {
if css.session == nil { if css.session == nil {
css.session = &SessionState{} css.session = &SessionState{}