Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Add Complete XOR Patch Functionality #255

Merged
merged 15 commits into from
Nov 6, 2022

Conversation

tmthecoder
Copy link
Contributor

@tmthecoder tmthecoder commented May 26, 2022

This PR adds complete XOR patch functionality (building on the existing single-byte scramble xormask statement).

This feature adds the following specifically:

  • scramble xormask [password]: Same as existing, but with added support for multibyte passwords
  • scramble xorptrpos: XORs the byte of each packet with its position in the array
  • scramble reverse: Keeps the first byte but reverses the remaining ('abcde' becomes 'aedcb')
  • scramble obfuscate [password]: Performs a combination of the three above with the given passphrase on the mask stage. For reading it goes in this order: xormask -> xorptrpos -> reverse -> xorptrpos. Writing is the opposite

All of these implementations are done following Tunnelblick's XOR patch and their small article on it here (Header titled "Scramble Option Syntax")

I've found myself needed the full extent of this functionality, specifically the scramble obfuscate option with a multu-byte password, hence my decision to write an implementation for it. I believe I've followed the guidelines outlined as well as the code structure already defined. Looking forward to hearing your insight!

@tmthecoder
Copy link
Contributor Author

Also, please note that this does change the xorMask type to a Data as opposed to a UInt8 since we've added support for multibyte values to be used as the xormask or obfuscate arguments

@keeshux keeshux added this to the 5.0.0 milestone May 26, 2022
@keeshux keeshux added the enhancement New feature or request label May 26, 2022
@keeshux keeshux self-assigned this May 26, 2022
@tmthecoder
Copy link
Contributor Author

@keeshux Just looking here again, should I add in a commit to update the README with the complete XOR functionality?

@keeshux
Copy link
Member

keeshux commented Aug 5, 2022

@keeshux Just looking here again, should I add in a commit to update the README with the complete XOR functionality?

Hey, yes you can go ahead with that. Sorry that I won't be able to review this until I release Passepartout 2.0

@keeshux keeshux modified the milestones: 5.0.0, 5.1.0 Sep 11, 2022
@keeshux
Copy link
Member

keeshux commented Sep 30, 2022

Okay, time has finally come to look into this.

@keeshux keeshux added the OpenVPN label Oct 4, 2022
- XOR is OpenVPN-specific, remove from common packages

- Convert method/mask pair to an associated enum

- Encapsulate XOR algorithms into ad hoc C/Swift modules

- Rename PacketStream methods to imply obfuscate in/out direction

- Use inline C where appropriate
@keeshux
Copy link
Member

keeshux commented Nov 4, 2022

@tmthecoder sorry for the long delay!

First of all, thanks again for your dedication, this is great work and I'm sincerely glad for your contribution.

I could finally take some time to review this and I refactored your code to fit it better into the library. It's all about simplifying and moving things around, but the purpose and algorithms should be 100% unaffected.

Since I understand you are using all these in your server, please do some stress tests with this updated code of mine. Meanwhile, I'll try to at least add some unit tests of the XOR processing routines, to make sure e.g. that packets are correctly reversible (p1 -> scramble -> p2 -> scramble -> p1).

Cheers

@tmthecoder
Copy link
Contributor Author

@keeshux Sounds good, I'll run some tests on my setups

@tmthecoder
Copy link
Contributor Author

@keeshux Couldn't find any issues in local tests against VPN servers

@keeshux
Copy link
Member

keeshux commented Nov 5, 2022

@keeshux Couldn't find any issues in local tests against VPN servers

Awesome. Have you also ensured continued operation in UDP/TCP without any XOR option enabled?

@keeshux keeshux merged commit 5ecd732 into passepartoutvpn:master Nov 6, 2022
@keeshux
Copy link
Member

keeshux commented Nov 6, 2022

Tested myself, and Passepartout beta will be another testbed. Merged!

@tmthecoder tmthecoder deleted the add-full-xor-patch branch November 9, 2022 02:54
@daaku
Copy link

daaku commented Jan 22, 2023

Wondering when this will be in TestFlight / Release?

@keeshux
Copy link
Member

keeshux commented Apr 1, 2023

Wondering when this will be in TestFlight / Release?

It's in TestFlight versions of Passepartout already.

@keeshux
Copy link
Member

keeshux commented Apr 7, 2023

@tmthecoder your work is now part of Passepartout 2.1.0 on the App Store. Thanks again!

@daaku FYI

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request OpenVPN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants