MCPcopy Index your code
hub / github.com/XTLS/REALITY / parseECHConfigList

Function parseECHConfigList

ech.go:139–164  ·  view source on GitHub ↗

parseECHConfigList parses a draft-ietf-tls-esni-18 ECHConfigList, returning a slice of parsed ECHConfigs, in the same order they were parsed, or an error if the list is malformed.

(data []byte)

Source from the content-addressed store, hash-verified

137// slice of parsed ECHConfigs, in the same order they were parsed, or an error
138// if the list is malformed.
139func parseECHConfigList(data []byte) ([]EchConfig, error) {
140 s := cryptobyte.String(data)
141 var length uint16
142 if !s.ReadUint16(&length) {
143 return nil, errMalformedECHConfigList
144 }
145 if length != uint16(len(data)-2) {
146 return nil, errMalformedECHConfigList
147 }
148 var configs []EchConfig
149 for len(s) > 0 {
150 if len(s) < 4 {
151 return nil, errors.New("tls: malformed ECHConfig")
152 }
153 configLen := uint16(s[2])<<8 | uint16(s[3])
154 skip, ec, err := parseECHConfig(s)
155 if err != nil {
156 return nil, err
157 }
158 s = s[configLen+4:]
159 if !skip {
160 configs = append(configs, ec)
161 }
162 }
163 return configs, nil
164}
165
166func pickECHConfig(list []EchConfig) *EchConfig {
167 for _, ec := range list {

Callers 1

makeClientHelloMethod · 0.85

Calls 2

parseECHConfigFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…