init
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package faketls
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
// WriteTLSApplicationData wraps payload in TLS 1.2 application records (type 0x17).
|
||||
func WriteTLSApplicationData(w io.Writer, p []byte) error {
|
||||
const maxChunk = 16384
|
||||
for off := 0; off < len(p); off += maxChunk {
|
||||
end := off + maxChunk
|
||||
if end > len(p) {
|
||||
end = len(p)
|
||||
}
|
||||
chunk := p[off:end]
|
||||
hdr := []byte{0x17, 0x03, 0x03, byte(len(chunk) >> 8), byte(len(chunk))}
|
||||
if _, err := w.Write(hdr); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := w.Write(chunk); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user