14

Netty 报文解析长度加密

 2 years ago
source link: https://www.v2ex.com/t/806056
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Netty 报文解析长度加密

V2EX  ›  Java

Netty 报文解析长度加密

  lslvxy · 1 天前 · 792 次点击

用 netty 解析 tcp 报文 格式是 固定 4 字节长度+消息体, 准备用 LengthFieldBasedFrameDecoder 解析的 但是这个消息头的 4 个字节也是加密的,要先解密一下才能获取到消息体的正确长度 这个要怎么搞呢

6 条回复    2021-10-07 16:35:12 +08:00

AlexRoot

AlexRoot   1 天前

固定长度的解析应该是提前在协议里确定好的吧。

lslvxy

lslvxy   1 天前

@AlexRoot 不是固定长度,是消息头前 4 个字节表示消息长度,但是这 4 个字节也是加密过了的

90xchun

90xchun   1 天前 via Android

把长度这个字段也加下密就可以了吧,有啥问题呢?

pmsg863

pmsg863   1 天前

加密后消息长度不会变吧?如果加密和解析后的 byte[]长度一致就比较简单,修改下 LengthFieldBasedFrameDecoder 源码,做个解密即可,对消息长度做个校验,超范围或解密失败跳过相关流数据或链路重置。

darkengine

darkengine   18 小时 15 分钟前

这个协议定的有问题吧。完整消息包的长度是加密的,那么就无法知道应该取多长的 byte[]下来进行解密,然后不解密又不知道前 4 个字节的里保存的消息体长度是多少。。。这个项目已经跑起来了吗?好奇插个眼。

lei2j

lei2j   16 小时 15 分钟前

长度也加密,那我挺好奇加密后的长度是多少呢?如果不是固定的,那怎么读取呢

关于   ·   帮助文档   ·   FAQ   ·   API   ·   我们的愿景   ·   广告投放   ·   感谢   ·   实用小工具   ·   1950 人在线   最高记录 5497   ·  

创意工作者们的社区

World is powered by solitude

VERSION: 3.9.8.5 · 26ms · UTC 00:50 · PVG 08:50 · LAX 17:50 · JFK 20:50
♥ Do have faith in what you're doing.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK