Skip to content

Mika Protocol Spec

Chong Jiang edited this page Sep 12, 2016 · 1 revision

Requset

iv is random bytes generated by client.
Key used to encrypt data is gengerated by the first part of password.
--------------------
|   iv  | req data |
--------------------
| Fixed | Variable |
--------------------
First block of req data (at least 23 bytes):
Chunk id is a unix time when requst was going to be sent. Server must verify chunk id.
Protocol claims how to resolve user data.
Hmac use sha1 as hash func, [iv]+[key] as key, and request header expect hmac as message.
hmac = Hmac(sha1, [iv]+[key], [header])
------------------------------------------------------------------------
| ver | cmd | reverse | protocol | protocol related | chunck id | hmac |
------------------------------------------------------------------------
|  1  |  1  |    2    |    1     |      Variable    |    8      | 10   |
------------------------------------------------------------------------
ver: 0x01

cmd:
data forward 0x01
server control 0x02

reverse: 0x0000

protocols:
TCP data forward(0x01)
---------------------------
| atype | address  | port |
---------------------------
|   1   | Variable |   2  |
---------------------------
HTTP data forward(0x02)
--------------------
| protocol related |
--------------------
|        0         |
--------------------
UDP data forward(0x03)
---------------------------
| atype |  address | port |
---------------------------
|   1   | Variable |   2  |
---------------------------
admin(0x05)
Other chunks of req data (at least 12 bytes):
Chunk id should increase one after a chunk was sent/recevied successfully. 
Server and client should hold same chunk id for the same chunk.
Hmac use sha1 as hach func, [iv]+[chunk id] as key, and [user data] as message.
hmac = Hmac(sha1, [iv]+[chunk id], [user data])
------------------------------
| dataLen | hmac | user data |
------------------------------
|   2     | 10   | Variable  |
------------------------------

Response

iv is same as request.
Key used to encrypt data is gengerated by the last part of password.
-------------
| resp data |
-------------
|  Variable |
-------------
Clone this wiki locally