{"id":15103697,"url":"https://github.com/ppzxc/codec","last_synced_at":"2026-01-18T04:04:52.663Z","repository":{"id":225784603,"uuid":"766849627","full_name":"ppzxc/codec","owner":"ppzxc","description":"netty codec","archived":false,"fork":false,"pushed_at":"2025-11-06T01:36:38.000Z","size":311,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-06T03:22:19.112Z","etag":null,"topics":["java","netty","netty-codec"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ppzxc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-04T08:43:57.000Z","updated_at":"2025-11-06T01:33:47.000Z","dependencies_parsed_at":"2024-04-25T08:51:20.537Z","dependency_job_id":null,"html_url":"https://github.com/ppzxc/codec","commit_stats":{"total_commits":88,"total_committers":2,"mean_commits":44.0,"dds":"0.17045454545454541","last_synced_commit":"43bc3c8ee036c5d76fbb4ac97b5c9f00c78cdf19"},"previous_names":["ppzxc/codec"],"tags_count":41,"template":false,"template_full_name":null,"purl":"pkg:github/ppzxc/codec","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppzxc%2Fcodec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppzxc%2Fcodec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppzxc%2Fcodec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppzxc%2Fcodec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ppzxc","download_url":"https://codeload.github.com/ppzxc/codec/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppzxc%2Fcodec/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28529455,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"online","status_checked_at":"2026-01-18T02:00:07.578Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","netty","netty-codec"],"created_at":"2024-09-25T19:41:32.263Z","updated_at":"2026-01-18T04:04:52.647Z","avatar_url":"https://github.com/ppzxc.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Release](https://github.com/ppzxc/codec/actions/workflows/release.yml/badge.svg)](https://github.com/ppzxc/codec/actions/workflows/release.yml) [![Coverage](.github/badges/jacoco.svg)](https://github.com/ppzxc/codec/actions/workflows/main.yml)\n\n# netty tcp codecs\n\n- [netty](https://github.com/netty/netty) tcp codecs\n\n# codec flow, before handshake\n\n```text\n            \"Byte Array Stream\"                     \"Byte Array Stream\"\n                    |                                      /|\\\n                    |                                       |\n                   \\|/                                      |\nFixedConstructorLengthFieldBasedFrameDecoder                |\n                    |                                       |\n                    |                                       |\n                   \\|/                                      | \n                    -----------------------------------------\n                    |                                       |\n                    |  HandShakeSimpleChannelInboundHandler |\n                    |                                       |\n                    ----------------------------------------     \n```\n\n# codec inbound flow, after handshake\n\n```text\n            \"Byte Array Stream\"                            \"Byte Array Stream\"\n                    |                                             /|\\\n                    |                                              |\n                   \\|/                                             |\nFixedConstructorLengthFieldBasedFrameDecoder                       |\n                    |                                              |\n                    |                                              |\n                   \\|/                                             |\n      EncryptedInboundMessageDecoder                     OutboundMessageEncoder\n                    |                                              |\n                    |                                              |\n                   \\|/                                             |\n             \"InboundMessage\"                                      |\n   ( require next decoder or handler )                      \"InboundMessage\"\n                    |                                             /|\\\n                    |                                              |\n                   \\|/                                             |\n                    ------------------------------------------------\n                    |                                              |\n                    |         Some handler will handle it          |\n                    |                                              |\n                    ------------------------------------------------\n```\n\n# message structure\n\n## common rule\n\n### body end rule\n\n```text\nThe end of the body should always end with 'CrLf'.\n```\n\n- Server can verify that the Body Length is normal.\n- On the server side, the 'body length Delimiter' method and the 'CrLf Delimiter' method can be used interchangeably.\n\n## handShake\n\n1. HandshakeType\n\n- required 'RSA 1024', other failure\n\n| name     | hex  |\n|----------|------|\n| NONE     | 0x00 |\n| RSA 1024 | 0x01 |\n| RSA 2048 | 0x02 |\n| RSA 4096 | 0x03 |\n\n2. Type\n\n- encryption type\n- require 'AES', other failure\n\n| name | hex  |\n|------|------|\n| NONE | 0x00 |\n| AES  | 0x01 |\n\n2. Mode\n\n- encryption mode\n- require 'CBC', other failure\n\n| name | hex  |\n|------|------|\n| NONE | 0x00 |\n| ECB  | 0x01 |\n| CBC  | 0x02 |\n| CFB  | 0x03 |\n| OFB  | 0x04 |\n| CTR  | 0x05 |\n\n3. Padding\n\n- encryption Padding\n- require 'PKCS 7 PADDING', other failure\n\n| name   | hex  |\n|--------|------|\n| NONE   | 0x00 |\n| PKCS#5 | 0x01 |\n| PKCS#7 | 0x02 |\n\n4. IV Parameter\n\n- require 16 byte fixed length.\n\n5. Symmetric Key\n\n- 16 or 24 or 32 byte variable length.\n\n### before encrypt\n\n```text\n  0                   1                   2                   3\n  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n |                           Length                              |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | HandShakeType |      Type     |     Mode      |    Padding    |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n |                              ...                              |\n |                          IV Parameter                         |\n |                              ...                              |\n |                              ...                              |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n |                              ...                              |\n |                              ...                              |\n |                              ...                              |\n |                          Symmetric Key                        |\n |                              ...                              |\n |                              ...                              |\n |                              ...                              |\n |                              ...                              |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n  0                   1                   2                   3\n  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1\n```\n\n| type   | name           | length              | binary                        | range                          | hexadecimal             |\n|--------|----------------|---------------------|-------------------------------|--------------------------------|-------------------------|\n| Header | Length         | 4 byte              | 32 bit                        | -2,147,483,648 ~ 2,147,483,647 | 0x80000000 ~ 0x7fffffff |  \n| Header | HandShake Type | 1 byte              | 8 bit                         | -128 ~ 127                     | 0x80 ~ 0x7f             |\n| Header | Type           | 1 byte              | 8 bit                         | -128 ~ 127                     | 0x80 ~ 0x7f             |\n| Header | Mode           | 1 byte              | 8 bit                         | -128 ~ 127                     | 0x80 ~ 0x7f             |\n| Header | Padding        | 1 byte              | 8 bit                         | -128 ~ 127                     | 0x80 ~ 0x7f             |\n| Body   | IV Parameter   | 16 byte             | 128 bit                       | -                              | -                       |\n| Body   | Symmetric Key  | 16 or 24 or 32 byte | 128 bit or 192 bit or 256 bit | -                              | -                       |\n\n- iv parameter rule\n\n```text\nset 'default' if null padding. \n'default' value is server private.\n```\n\n### after encrypt\n\n- encrypt [body](#body) using [RSA](#encrypt-handshake-rule)\n\n```text\n  0                   1                   2                   3\n  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n |                           Length                              |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | HandShakeType |  EncryptType  |  EncryptMode  | EncryptPadding|\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n |                              ...                              |\n |                              ...                              |\n |                        Encrypted Body                         |\n |                              ...                              |\n |                              ...                              |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n  0                   1                   2                   3\n  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1\n```\n\n| type   | name           | length   | binary   | range                          | hexadecimal             |\n|--------|----------------|----------|----------|--------------------------------|-------------------------|\n| Header | Length         | 4 byte   | 32 bit   | -2,147,483,648 ~ 2,147,483,647 | 0x80000000 ~ 0x7fffffff |  \n| Header | HandShake Type | 1 byte   | 8 bit    | -128 ~ 127                     | 0x80 ~ 0x7f             |\n| Header | Type           | 1 byte   | 8 bit    | -128 ~ 127                     | 0x80 ~ 0x7f             |\n| Header | Mode           | 1 byte   | 8 bit    | -128 ~ 127                     | 0x80 ~ 0x7f             |\n| Header | Padding        | 1 byte   | 8 bit    | -128 ~ 127                     | 0x80 ~ 0x7f             |\n| Body   | Encrypted Body | variable | variable | variable                       | variable                |\n\n- encrypted body rule\n\n```text\n1. 'handshake' uses 'rsa' algorithm.\n2. Public key algorithm for 'AES' key exchange.\n3. The 'AES' key is provided by the client.\n```\n\n## message\n\n### before encrypt\n\n```text\n  0                   1                   2                   3\n  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n |                             Length                            |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n |                               ID                              |\n |                                                               |                            \n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n |     Type    |    Status     |   Encoding    |    Reserved     |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n |                              ...                              |\n |                              Body                             |\n |                              ...                              |                            \n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n  0                   1                   2                   3\n  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1\n```\n\n| type   | name     | length   | binary   | range                                                  | hexadecimal                             |\n|--------|----------|----------|----------|--------------------------------------------------------|-----------------------------------------|\n| Header | Length   | 4 byte   | 32 bit   | -2,147,483,648 ~ 2,147,483,647                         | 0x80000000 ~ 0x7fffffff                 |\n| Header | ID       | 8 byte   | 64 bit   | -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 | 0x8000000000000000 ~ 0x7fffffffffffffff |\n| Header | Type     | 1 byte   | 8 bit    | -128 ~ 127                                             | 0x80 ~ 0x7f                             |\n| Header | Status   | 1 byte   | 8 bit    | -128 ~ 127                                             | 0x80 ~ 0x7f                             |\n| Header | Encoding | 1 byte   | 8 bit    | -128 ~ 127                                             | 0x80 ~ 0x7f                             |\n| Header | Reserved | 1 byte   | 8 bit    | -128 ~ 127                                             | 0x80 ~ 0x7f                             |\n| Body   | Body     | variable | variable | -                                                      | -                                       |\n\n### after encrypt\n\n- encryption fields\n\n```text\nId, Type, Status, Encoding, Reserved, Body\n```\n\n```text\n  0                   1                   2                   3\n  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n |                             Length                            |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n |                              ...                              |\n |                         Encrypted Body                        |\n |                              ...                              |                            \n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n  0                   1                   2                   3\n  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1\n```\n\n| name   | length   | binary   | range                          | hexadecimal             |\n|--------|----------|----------|--------------------------------|-------------------------|\n| Length | 4 byte   | 32 bit   | -2,147,483,648 ~ 2,147,483,647 | 0x80000000 ~ 0x7fffffff |\n| Body   | variable | variable | variable                       | variable                |\n\n- encrypted body rule\n\n```text\nExcept for the length field, all headers and bodies are encrypted by 'AES'.\n```\n\n# usage\n\n- [sonatype](https://central.sonatype.com/artifact/io.github.ppzxc/codec)\n\n```\nimplementation(\"io.github.ppzxc:codec:X.X.X\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fppzxc%2Fcodec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fppzxc%2Fcodec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fppzxc%2Fcodec/lists"}