This document describes the wire format for securely encoding, decoding, encrypting, and decrypting messages sent over the wire. The wire format is designed to ensure data integrity, confidentiality, and authenticity. The data structures are encoded and decoded using MsgPack (message pack) to provide a compact and efficient binary representation.
The wire format is used to transmit secure messages between services. It includes mechanisms for signing, encrypting, and validating the integrity of the data. The format is designed to be stable and interoperable, allowing different versions of the protocol to coexist.
The Message structure represents the useful data that is sent over the wire. It
includes the payload, optional files, and an optional response.
Message ::= { "payload": Payload, "files": Files, "response": Response }
Payload ::= binary
Files ::= map<string, File>
Response ::= Encryption | nil
The File structure represents a file that is sent over the wire. It includes
the file data, mode, modification time, and owner.
File ::= { "data": FileData,
"size": Size,
"mode": FileMode,
"modtime": FileModTime,
"owner": Owner
"uid": ID
"group": Owner
"gid": ID
}
FileData ::= binary
Size ::= int64
FileMode ::= uint32 | nil
FileModTime ::= timestamp | nil
Owner ::= string | nil
ID ::= uint32 | nil
The Encryption structure contains instructions for how to encrypt the response.
Encryption ::= { "alg": EncryptionAlg, "key": EncryptionKey }
EncryptionAlg ::= string
EncryptionKey ::= string
The data structures are encoded and decoded using MsgPack. This ensures a compact and efficient binary representation of the data.
To encode a Message:
- Create a
Messageinstance with the desired payload, files, and response. - Encode the
Messageinstance using MsgPack. - Create a JWS that includes the
Message. - Compress the resulting JWS using Gzip.
To decode a Message:
- Uncompress the data using Gzip.
- Verify the JWS signature.
- Extract the payload of the JWS a
Messageinstance using MsgPack.
The encrypted form of the data structures are similar, but the compression steps happen at different points.
- Create a
Messageinstance with the desired payload, files, and response. - Encode the
Messageinstance using MsgPack. - Compress the resulting binary using Gzip.
- Create a JWE that includes the compressed data.
- Decrypt the data of the JWE.
- Decompress the resulting payload using Gzip.
- Convert the MsgPack encoded data into a
Message
- Data Integrity: The SHA of the data is included in the JWS to ensure that the data is not tampered with.
- Confidentiality: The
Encryptionstructure provides instructions for encrypting the response. - Authenticity: The JWS signature ensures that the data is from a trusted source.
This document describes the wire format for securely transmitting messages between services. The format ensures data integrity, confidentiality, and authenticity using MsgPack for encoding and decoding, and JWS for signing. The stable and interoperable design allows different versions of the protocol to coexist.