Skip to content

Commit

Permalink
Do not share the XOR key offset between the send and receive threads
Browse files Browse the repository at this point in the history
  • Loading branch information
osm committed Sep 6, 2024
1 parent 98ce74f commit 399701d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ Line wrap the file at 100 chars. Th
* **Fixed**: for any bug fixes.
* **Security**: in case of vulnerabilities.

## [1.1.1] - 2024-09-06
### Fixed
- Do not share the XOR key offset between the send and receive threads.


## [1.1.0] - 2024-09-05
### Added
- Add XOR v2.


## [1.0.4] - 2024-07-04
### Changed
- Upgrade to use Go 1.22.5
Expand Down
10 changes: 5 additions & 5 deletions proxy/xorv2/xorv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import (
)

type xor struct {
addrPort string
xorKey []byte
xorKeyOffset int
addrPort string
xorKey []byte
}

func New(ip net.IP) (*xor, error) {
Expand All @@ -33,6 +32,7 @@ func (x *xor) ToPeer(dst io.Writer, src io.Reader) { x.forward(dst, src) }

func (x *xor) forward(dst io.Writer, src io.Reader) {
buf := make([]byte, 1024*64)
offset := 0

for {
nr, err := src.Read(buf)
Expand All @@ -41,8 +41,8 @@ func (x *xor) forward(dst io.Writer, src io.Reader) {
}

for i := 0; i < nr; i++ {
buf[i] ^= x.xorKey[x.xorKeyOffset]
x.xorKeyOffset = (x.xorKeyOffset + 1) % len(x.xorKey)
buf[i] ^= x.xorKey[offset]
offset = (offset + 1) % len(x.xorKey)
}

nw, err := dst.Write(buf[0:nr])
Expand Down
10 changes: 5 additions & 5 deletions vendor/github.com/mullvad/proxy/xorv2/xorv2.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 399701d

Please sign in to comment.