MCPcopy
hub / github.com/XTLS/REALITY / cloneHash

Function cloneHash

handshake_server_tls13.go:568–591  ·  view source on GitHub ↗

cloneHash uses the encoding.BinaryMarshaler and encoding.BinaryUnmarshaler interfaces implemented by standard library hashes to clone the state of in to a new instance of h. It returns nil if the operation fails.

(in hash.Hash, h crypto.Hash)

Source from the content-addressed store, hash-verified

566// interfaces implemented by standard library hashes to clone the state of in
567// to a new instance of h. It returns nil if the operation fails.
568func cloneHash(in hash.Hash, h crypto.Hash) hash.Hash {
569 // Recreate the interface to avoid importing encoding.
570 type binaryMarshaler interface {
571 MarshalBinary() (data []byte, err error)
572 UnmarshalBinary(data []byte) error
573 }
574 marshaler, ok := in.(binaryMarshaler)
575 if !ok {
576 return nil
577 }
578 state, err := marshaler.MarshalBinary()
579 if err != nil {
580 return nil
581 }
582 out := h.New()
583 unmarshaler, ok := out.(binaryMarshaler)
584 if !ok {
585 return nil
586 }
587 if err := unmarshaler.UnmarshalBinary(state); err != nil {
588 return nil
589 }
590 return out
591}
592
593func (hs *serverHandshakeStateTLS13) pickCertificate() error {
594 c := hs.c

Callers 5

handshakeMethod · 0.85
checkForResumptionMethod · 0.85
doHelloRetryRequestMethod · 0.85
sendServerParametersMethod · 0.85

Calls 2

MarshalBinaryMethod · 0.80
UnmarshalBinaryMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…