Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REALITY protocol: Add ChaCha20-Poly1305 auth mode #2208

Merged
merged 2 commits into from
Jun 14, 2023

Conversation

H1JK
Copy link
Member

@H1JK H1JK commented Jun 14, 2023

This comes with other optimizations with current REALITY client implementation:

  1. Reuse existing sessionId slice instead of allocating a new one.
  2. Adjust sessionId processing order to eliminate bounds checks.
  3. Cache the offset of peerCertificates to avoid reflection overhead.

This commit comes with other optimizations with current REALITY client implementation:
1. Reuse existing sessionId slice instead of allocating a new one.
2. Adjust sessionId processing order to eliminate bounds checks.
3. Cache the offset of `peerCertificates` to avoid reflection overhead.
@RPRX
Copy link
Member

RPRX commented Jun 14, 2023

感谢 PR,Session ID 那段如果没有 new 一个 rawSessionID 就更好了,一个切片结构要占 24 字节

@RPRX
Copy link
Member

RPRX commented Jun 14, 2023

加上一个 point 到该切片的指针,又成 32 字节了,我看了一下可以借用 hello.Random,用完再把它改为引用 raw

@RPRX RPRX merged this pull request into XTLS:main Jun 14, 2023
@RPRX
Copy link
Member

RPRX commented Jun 14, 2023

我的那个 commit 是看着 WireShark 写的,改后没测过,麻烦大家测一下 f09c391 的 REALITY 是否正常

因为现在我用的是 XTLS/REALITY#2 (comment)

@RPRX
Copy link
Member

RPRX commented Jun 14, 2023

我又想了一下,这个对置零的优化其实不太好,因为它依赖于“SessionId 不是 Raw 的引用”,没写这个注释的话,别人看代码会一头雾水。并且它取决于 uTLS 的行为,不受我们控制,是一种隐式的 unsafe,应当避免。所以还是原来的写法更清晰、安全。

@RPRX
Copy link
Member

RPRX commented Jun 14, 2023

并且这个由于是客户端实现,linkname 应当改为针对 uTLS(且不用单独放一个文件),方便其它 Go 客户端参考

我会删掉 f09c391 ,麻烦开两个 PR,一个 Add Chacha20-Poly1305 auth mode,一个专门优化 reflect(包括 XTLS 那里)

@H1JK
Copy link
Member Author

H1JK commented Jun 15, 2023

加上一个 point 到该切片的指针

The slice variable does not store a pointer to slice header but slice header struct itself. This is a temporary variable and not being referred anywhere else, so it is expected to be allocated on stack, which is cheap enough.

@RPRX
Copy link
Member

RPRX commented Jun 15, 2023

加上一个 point 到该切片的指针

The slice variable does not store a pointer to slice header but slice header struct itself. This is a temporary variable and not being referred anywhere else, so it is expected to be allocated on stack, which is cheap enough.

是的,堆上的话是我说的情况,不是说切片变量不是结构体,我的意思是程序总要存它的首内存地址,栈上的话则你说的是合理的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants