MCPcopy Create free account
hub / github.com/SenseUnit/dumbproxy / UnmarshalBinary

Method UnmarshalBinary

tlsutil/ccache.go:57–95  ·  view source on GitHub ↗
(data []byte)

Source from the content-addressed store, hash-verified

55}
56
57func (e *sessionCacheEntry) UnmarshalBinary(data []byte) error {
58 r := bytes.NewReader(data)
59
60 formatVerLen, err := binary.ReadUvarint(r)
61 if err != nil {
62 return fmt.Errorf("unable to read length of format version field: %w", err)
63 }
64 formatVerBytes := make([]byte, formatVerLen)
65 _, err = io.ReadFull(r, formatVerBytes)
66 if err != nil {
67 return fmt.Errorf("unable to read format version field: %w", err)
68 }
69
70 ticketLen, err := binary.ReadUvarint(r)
71 if err != nil {
72 return fmt.Errorf("unable to read length of ticket field: %w", err)
73 }
74 ticketBytes := make([]byte, ticketLen)
75 _, err = io.ReadFull(r, ticketBytes)
76 if err != nil {
77 return fmt.Errorf("unable to read ticket field: %w", err)
78 }
79
80 stateLen, err := binary.ReadUvarint(r)
81 if err != nil {
82 return fmt.Errorf("unable to read length of state field: %w", err)
83 }
84 stateBytes := make([]byte, stateLen)
85 _, err = io.ReadFull(r, stateBytes)
86 if err != nil {
87 return fmt.Errorf("unable to read state field: %w", err)
88 }
89
90 e.formatVersion = string(formatVerBytes)
91 e.ticket = ticketBytes
92 e.state = stateBytes
93
94 return nil
95}
96
97func clientSessionStateToBytes(cs *tls.ClientSessionState) ([]byte, error) {
98 ticket, state, err := cs.ResumptionState()

Callers 1

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected