MCPcopy Create free account
hub / github.com/XTLS/Go / marshal

Method marshal

handshake_messages.go:1219–1252  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1217}
1218
1219func (m *certificateMsg) marshal() (x []byte) {
1220 if m.raw != nil {
1221 return m.raw
1222 }
1223
1224 var i int
1225 for _, slice := range m.certificates {
1226 i += len(slice)
1227 }
1228
1229 length := 3 + 3*len(m.certificates) + i
1230 x = make([]byte, 4+length)
1231 x[0] = typeCertificate
1232 x[1] = uint8(length >> 16)
1233 x[2] = uint8(length >> 8)
1234 x[3] = uint8(length)
1235
1236 certificateOctets := length - 3
1237 x[4] = uint8(certificateOctets >> 16)
1238 x[5] = uint8(certificateOctets >> 8)
1239 x[6] = uint8(certificateOctets)
1240
1241 y := x[7:]
1242 for _, slice := range m.certificates {
1243 y[0] = uint8(len(slice) >> 16)
1244 y[1] = uint8(len(slice) >> 8)
1245 y[2] = uint8(len(slice))
1246 copy(y[3:], slice)
1247 y = y[3+len(slice):]
1248 }
1249
1250 m.raw = x
1251 return
1252}
1253
1254func (m *certificateMsg) unmarshal(data []byte) bool {
1255 if len(data) < 7 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected