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

关于解析时的解密和转义问题 #10

Open
LPH517 opened this issue Jun 5, 2024 · 9 comments
Open

关于解析时的解密和转义问题 #10

LPH517 opened this issue Jun 5, 2024 · 9 comments
Assignees
Labels
fixed The bug fixed

Comments

@LPH517
Copy link

LPH517 commented Jun 5, 2024

在解析报文时,如果消息体是经过加密的,且加密后的消息体刚好以5E01结尾,会出现解析异常。

异常报文如下:
5B000000540000000D10010000006601020F010000000000000000665F4D7A261313752221202726251313131313752221243D233D233D22131313131313131313131313131313131313131313131334 5E01 91E4 5D

将消息体结尾的5E01改为5D才能正常解析:
5B000000540000000D10010000006601020F010000000000000000665F4D7A261313752221202726251313131313752221243D233D233D22131313131313131313131313131313131313131313131334 5D 91E4 5D

可是正常的报文内容,按照协议描述是不能包含5D的

加密参数IA1 M1 IC1为20240604
期待您的解惑

@yedajiang44
Copy link
Collaborator

这报文发送还是接收? @LPH517

@yedajiang44
Copy link
Collaborator

发送方加密步骤:

  1. 创建实体
  2. 配置加密选项
  3. 序列化
  4. 加密
  5. 转义
  6. 发送

接收方解密步骤:

  1. 配置解密选项
  2. 转义报文
  3. 解密
  4. 得到实体并处理

另外可以使用我们提供的解析工具尝试下

@LPH517
Copy link
Author

LPH517 commented Jun 5, 2024

这个是发送的@yedajiang44

@LPH517
Copy link
Author

LPH517 commented Jun 5, 2024

就是上述的解析工具对这段报文无法正确解析😭

@yedajiang44 yedajiang44 added the bug Something isn't working label Jun 5, 2024
@yedajiang44
Copy link
Collaborator

@LPH517 看下解析的对吗?

{
    "BeginFlag": 91,
    "Header": {
        "MsgLength": 84,
        "MsgSN": 13,
        "BusinessType": 4097,
        "MsgGNSSCENTERID": 102,
        "Version": {
            "Buffer": "AQIP",
            "Major": 1,
            "Minor": 2,
            "Build": 15
        },
        "EncryptFlag": 1,
        "EncryptKey": 0,
        "Time": "2024-06-05T01:23:06"
    },
    "Bodies": {
        "UserId": 102,
        "Password": "123456",
        "MsgGNSSCENTERID": 102,
        "DownLinkIP": "127.0.0.1",
        "DownLinkPort": 10062,
        "MsgId": 4097,
        "Description": "主链路登录请求消息",
        "LinkType": 0,
        "SkipSerialization": false,
        "Version": 1,
        "ReplaceInternalMsgId": false
    },
    "CRCCode": 9747,
    "EndFlag": 19
}

@LPH517
Copy link
Author

LPH517 commented Jun 6, 2024

对的😆😆😆@yedajiang44

@LPH517
Copy link
Author

LPH517 commented Jun 6, 2024

看起来是解决这个bug了呀?能否告知一下大概是什么原因造成的呢?

@yedajiang44
Copy link
Collaborator

看起来是解决这个bug了呀?能否告知一下大概是什么原因造成的呢?

问题是转义引起的,详见提交 f86e943

@yedajiang44 yedajiang44 added fixed The bug fixed and removed bug Something isn't working labels Jun 6, 2024
@LPH517
Copy link
Author

LPH517 commented Jun 6, 2024

感谢^ω^

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

No branches or pull requests

2 participants