MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / Read

Method Read

crypto/etls/conn.go:71–100  ·  view source on GitHub ↗

Read iv and Encrypted data.

(b []byte)

Source from the content-addressed store, hash-verified

69
70// Read iv and Encrypted data.
71func (c *CryptoConn) Read(b []byte) (n int, err error) {
72 if c.decStream == nil {
73 buf := make([]byte, c.info.ivLen+MagicSize)
74 if _, err = io.ReadFull(c.Conn, buf); err != nil {
75 log.WithError(err).Info("read full failed")
76 return
77 }
78 iv := buf[:c.info.ivLen]
79 header := buf[c.info.ivLen:]
80 if err = c.initDecrypt(iv); err != nil {
81 return
82 }
83 c.decrypt(header, header)
84 if !bytes.Equal(header[:MagicSize], MagicBytes[:]) {
85 err = errors.New("bad stream ETLS header")
86 return
87 }
88 }
89
90 cipherData := make([]byte, len(b))
91
92 n, err = c.Conn.Read(cipherData)
93 if err != nil {
94 return
95 }
96 if n > 0 {
97 c.decrypt(b[0:n], cipherData[0:n])
98 }
99 return
100}
101
102// Write iv and Encrypted data.
103func (c *CryptoConn) Write(b []byte) (n int, err error) {

Callers

nothing calls this directly

Calls 6

WithErrorFunction · 0.92
InfoMethod · 0.80
initDecryptMethod · 0.80
decryptMethod · 0.80
NewMethod · 0.65
ReadMethod · 0.65

Tested by

no test coverage detected