infinet / xt_wgobfs

Iptables WireGuard obfuscation extension
GNU General Public License v2.0
232 stars 24 forks source link

Cant establish connection between little endian and big endian devices. #8

Closed alexburt closed 1 year ago

alexburt commented 1 year ago

I cant establish connection between my Openwrt router and Linux PC. Problem is in operations like "chacha_input = *p64 + 42;" which will give a different result on a different machines. https://github.com/infinet/xt_wgobfs/blob/main/src/xt_WGOBFS_main.c#L48

Very good project. Thank you! patch: wgobfs_big_endian.txt

infinet commented 1 year ago

Thank you so much!

Fixed in https://github.com/infinet/xt_wgobfs/commit/d246f3f85bbbf90f64dbe47c256e8189bd0992e0.

alexburt commented 1 year ago

cpu_to_le64( mem ) + 42 is not equal to cpu_to_le64( mem + 42 )

cpu_to_le64( *mem + 42 ) will have is different result on little endian and big endian devices

I think we have to do cpu_to_le64 first and add 42 after.

infinet commented 1 year ago

You are right, they are not the same. However, here it is used to generate pseudo-random bytes for padding. Its peer does not need to regenerate the same pseudo-random bytes.

alexburt commented 1 year ago

thank you!