MCPcopy
hub / github.com/MetaCubeX/mihomo / UnpackInplace

Function UnpackInplace

transport/shadowsocks/shadowstream/packet.go:35–42  ·  view source on GitHub ↗

UnpackInplace decrypts pkt using stream cipher s. Returns a slice of pkt containing decrypted plaintext. Note: The data in the input dst will be changed

(pkt []byte, s Cipher)

Source from the content-addressed store, hash-verified

33// Returns a slice of pkt containing decrypted plaintext.
34// Note: The data in the input dst will be changed
35func UnpackInplace(pkt []byte, s Cipher) ([]byte, error) {
36 if len(pkt) < s.IVSize() {
37 return nil, ErrShortPacket
38 }
39 iv, dst := pkt[:s.IVSize()], pkt[s.IVSize():]
40 s.Decrypter(iv).XORKeyStream(dst, dst)
41 return dst, nil
42}
43
44// Unpack decrypts pkt using stream cipher s.
45// Returns a slice of dst containing decrypted plaintext.

Callers 2

ReadFromMethod · 0.85
WaitReadFromMethod · 0.85

Calls 2

IVSizeMethod · 0.65
DecrypterMethod · 0.65

Tested by

no test coverage detected