2020-10-10 21:47:17 +01:00
|
|
|
# Simplex messaging protocol (SMP)
|
|
|
|
|
|
|
|
|
|
## Table of contents
|
|
|
|
|
|
|
|
|
|
- [Abstract](#abstract)
|
|
|
|
|
- [Introduction](#introduction)
|
|
|
|
|
- [SMP Model](#smp-model)
|
|
|
|
|
- [Out-of-band messages](#out-of-band-messages)
|
2020-10-22 11:29:48 +01:00
|
|
|
- [Simplex queue](#simplex-queue)
|
2020-10-10 21:47:17 +01:00
|
|
|
- [SMP procedure](#smp-procedure)
|
|
|
|
|
- [SMP elements](#smp-elements)
|
|
|
|
|
- [SMP qualities and features](#smp-qualities-and-features)
|
|
|
|
|
- [Cryptographic algorithms](#cryptographic-algorithms)
|
2020-10-22 11:29:48 +01:00
|
|
|
- [Simplex queue IDs](#simplex-queue-ids)
|
2020-10-10 21:47:17 +01:00
|
|
|
- [Server privacy requirements](#server-privacy-requirements)
|
|
|
|
|
- [SMP commands](#smp-commands)
|
|
|
|
|
- [Correlating responses with commands](#correlating-responses-with-commands)
|
|
|
|
|
- [Command authentication](#command-authentication)
|
|
|
|
|
- [Recipient commands](#recipient-commands)
|
2020-10-22 11:29:48 +01:00
|
|
|
- [Create queue command](#create-queue-command)
|
|
|
|
|
- [Subscribe to queue](#subscribe-to-queue)
|
|
|
|
|
- [Secure queue command](#secure-queue-command)
|
2020-10-17 21:07:15 +01:00
|
|
|
- [Acknowledge message delivery](#acknowledge-message-delivery)
|
2020-10-22 11:29:48 +01:00
|
|
|
- [Suspend queue](#suspend-queue)
|
|
|
|
|
- [Delete queue](#delete-queue)
|
2020-10-10 21:47:17 +01:00
|
|
|
- [Sender commands](#sender-commands)
|
2020-10-22 11:29:48 +01:00
|
|
|
- [Send message](#send-message)
|
2020-10-10 21:47:17 +01:00
|
|
|
- [Server messages](#server-messages)
|
2020-10-22 11:29:48 +01:00
|
|
|
- [Queue IDs response](#queue-ids-response)
|
|
|
|
|
- [Deliver queue message](#deliver-queue-message)
|
2020-10-17 21:07:15 +01:00
|
|
|
- [Subscription END notification](#subscription-end-notification)
|
2020-10-10 21:47:17 +01:00
|
|
|
- [Error responses](#error-responses)
|
|
|
|
|
- [OK response](#ok-response)
|
|
|
|
|
- [Appendices](#appendices)
|
|
|
|
|
- [Appendix A. Transport connection with the SMP server](#appendix-a)
|
|
|
|
|
- [Appendix B. Sending out-of-band message](#appendix-b)
|
|
|
|
|
|
|
|
|
|
## Abstract
|
|
|
|
|
|
|
|
|
|
Simplex messaging protocol is a transport agnostic client-server protocol for
|
2020-10-22 11:29:48 +01:00
|
|
|
asynchronous distributed secure unidirectional message transmission via
|
|
|
|
|
persistent simplex message queues.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
It's designed with the focus on communication security and integrity, under the
|
|
|
|
|
assumption that any part of the message transmission network can be compromised.
|
|
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
It is designed as a low level protocol for other application protocols to solve
|
|
|
|
|
the problem of secure and private message transmission, making [MITM attack][1]
|
|
|
|
|
very difficult at any part of the message transmission system.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
## Introduction
|
|
|
|
|
|
|
|
|
|
The objective of Simplex Messaging Protocol (SMP) is to facilitate the secure
|
2020-10-22 11:29:48 +01:00
|
|
|
and private unidirectional transfer of messages from senders to recipients via
|
|
|
|
|
persistent simplex queues.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
SMP is independent of the particular transmission system and requires only a
|
|
|
|
|
reliable ordered data stream channel. While this document describes transport
|
|
|
|
|
over TCP, other transports are also possible.
|
|
|
|
|
|
|
|
|
|
The protocol describes the set of commands that recipient and sender can
|
2020-10-22 11:29:48 +01:00
|
|
|
exchange with the SMP server to create and to operate a unidirectional "queue"
|
|
|
|
|
(a data abstraction identifying one of many communication channels managed by
|
|
|
|
|
the server) and to send messages from the sender to the recipient via the SMP
|
|
|
|
|
server.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
More complex communication scenarios can be designed using multiple queues - for
|
|
|
|
|
example, a duplex communication channel can be made of 2 simplex queues.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
Protocol is designed with the focus on privacy and security, to some extent
|
|
|
|
|
deprioritizing reliability by requiring that SMP servers only store messages
|
|
|
|
|
until they are delivered to the recipients and, in any case, for a limited
|
|
|
|
|
period of time. For communication scenarios requiring more reliable transmission
|
|
|
|
|
the users should use several SMP servers to pass each message and implement some
|
2020-10-22 11:29:48 +01:00
|
|
|
additional protocol to ensure that messages are not removed, inserted or
|
|
|
|
|
re-ordered - this is out of scope of this document.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
SMP removes the need for participants' identities and provides [E2EE][2] without
|
2020-10-22 11:29:48 +01:00
|
|
|
the possibility of [MITM attack][1] relying on two pre-requisites:
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
- the users can establish a secure encrypted transport connection with the SMP
|
|
|
|
|
server. [Appendix A](#appendix-a) has a possible simple protocol of such
|
|
|
|
|
transport connection over TCP, but any other transport connection encryption
|
|
|
|
|
protocol can be used.
|
|
|
|
|
- the recipient can pass a single message to the sender via pre-existing secure
|
|
|
|
|
and private communication channel (out-of-band message) - the information in
|
2020-10-22 11:29:48 +01:00
|
|
|
this message is used to encrypt messages and to establish connection with SMP
|
|
|
|
|
server.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
## SMP Model
|
|
|
|
|
|
|
|
|
|
The SMP model has three communication participants: the recipient, the message
|
|
|
|
|
broker (SMP server) that is chosen and, possibly, controlled by the recipient,
|
|
|
|
|
and the sender.
|
|
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
SMP server manages multiple "simplex queues" - data records on the server that
|
|
|
|
|
identify communication channels from the senders to the recipients. The same
|
|
|
|
|
communicating party that is the sender in one queue, can be the recipient in
|
|
|
|
|
another - without exposing this fact to the server.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
The queue record consists of 2 unique random IDs generated by the server, one
|
|
|
|
|
for the recipient and another for the sender, and 2 keys to authenticate the
|
2020-10-10 21:47:17 +01:00
|
|
|
recipient and the sender respectively. The users of SMP protocol must use a
|
2020-10-22 11:29:48 +01:00
|
|
|
unique key for each queue, to avoid the possibility of aggregating and analysing
|
|
|
|
|
their queues in case SMP server is compromised.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
Creating and using the queue requires sending commands to the SMP server from
|
|
|
|
|
the recipient and the sender - they are described in detail in
|
2020-10-10 21:47:17 +01:00
|
|
|
[SMP commands](#smp-commands) section.
|
|
|
|
|
|
|
|
|
|
## Out-of-band messages
|
|
|
|
|
|
|
|
|
|
The out-of band invitation message is sent via some trusted alternative channel
|
2020-10-22 11:29:48 +01:00
|
|
|
from the recipient to the sender. This message is used to share the encryption
|
2020-10-10 21:47:17 +01:00
|
|
|
(a.k.a. "public") key that the sender will use to encrypt the messages (to be
|
2020-10-22 11:29:48 +01:00
|
|
|
decrypted by the recipient), sender queue ID, server address and any other
|
2020-10-10 21:47:17 +01:00
|
|
|
information necessary to establish secure encrypted connection with SMP server
|
|
|
|
|
(see [Appendix A](#appendix-a) for a simple transport protocol example).
|
|
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
The [ABNF][8] syntax of the message is:
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-10 22:16:36 +01:00
|
|
|
```abnf
|
2020-10-22 11:29:48 +01:00
|
|
|
outOfBandMsg = encryptionKey CRLF senderConnId CRLF server CRLF serverKeyHash
|
2020-10-10 22:16:36 +01:00
|
|
|
encryptionKey = encoded ; base64
|
|
|
|
|
senderConnId = encoded
|
|
|
|
|
server = hostname [":" port]
|
|
|
|
|
port = 1*DIGIT
|
|
|
|
|
serverKeyHash = encoded
|
2020-10-10 21:47:17 +01:00
|
|
|
```
|
2020-10-10 22:16:36 +01:00
|
|
|
|
2020-10-15 15:47:47 +01:00
|
|
|
`hostname` can be IP address or domain name, as defined in RFC 1123, section
|
|
|
|
|
2.1.
|
2020-10-10 22:16:36 +01:00
|
|
|
|
|
|
|
|
`port` is optional, the default TCP port for SMP protocol is 5223.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
Defining the approach to out-of-band message passing is out of scope of this
|
|
|
|
|
protocol. See [Appendix B](#appendix-b) for one of the possible practical
|
|
|
|
|
approaches.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
## Simplex queue
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
The simplex queue is the main unit of SMP protocol. It is used by:
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
- the sender of the queue (who received out-of-band message) to send messages to
|
|
|
|
|
the server using sender's queue ID, signed by sender's key.
|
|
|
|
|
- the recepient of the queue (who created the queue and who sent out-of-band
|
|
|
|
|
message) will use it to retrieve messages from the server, signing the
|
|
|
|
|
commands by the recepient key.
|
2020-10-10 21:47:17 +01:00
|
|
|
- participant identities are not shared with the server - new unique keys and
|
2020-10-22 11:29:48 +01:00
|
|
|
queue IDs are used for each queue.
|
|
|
|
|
|
|
|
|
|
This simplex queue can serve as a building block for more complex communication
|
|
|
|
|
network. For example, two (or more, for redundancy) simplex queues can be used
|
|
|
|
|
to create a duplex communication channel. Higher level primitives that are only
|
|
|
|
|
known to system participants in their client applications can be created as
|
|
|
|
|
well - contacts, conversations, groups and broadcasts. Simplex messaging servers
|
|
|
|
|
only have the information about the low-level simplex queues. In this way a high
|
|
|
|
|
level of privacy and security of the conversations is provided. Application
|
|
|
|
|
level primitives are not in scope of this protocol.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
This approach is based on the concept of [unidirectional networks][4] that are
|
|
|
|
|
used for applications with high level of information security.
|
|
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
Access to each queue is controlled with unique (not shared with other queues)
|
|
|
|
|
assymetric key pairs, separate for the sender and the recipient. The sender and
|
|
|
|
|
the receiver have private keys, and the server has associated public keys to
|
|
|
|
|
authenticate participants' commands by verifying cryptographic signatures.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
The messages sent into the queue are encrypted and decrypted using another key
|
|
|
|
|
pair that was shared via out-of-band message - the recepient has the private key
|
|
|
|
|
and the sender has the associated public key.
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
**Simplex queue diagram:**
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|

|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
Queue is defined by recipient ID `RID` unique for the server. It also has a
|
2020-10-10 21:47:17 +01:00
|
|
|
different unique sender ID `SID`. Sender key (`SK`) is used by the server to
|
|
|
|
|
verify sender's commands (identified by `SID`) to send messages. Recipient key
|
|
|
|
|
(`RK`) is used by the server to verify recipient's commands (identified by
|
|
|
|
|
`SID`) to retrieve messages.
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
The protocol uses different IDs for sender and recipient in order to provide an
|
2020-10-22 11:29:48 +01:00
|
|
|
additional privacy by complicating correlation of senders and recipients
|
|
|
|
|
commands sent over the network - even though they are encrypted using server's
|
|
|
|
|
public key, in case this key is compromised it would still be difficult to
|
|
|
|
|
correlate senders and recipients without access to queue records on the server.
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
## SMP procedure
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
The SMP procedure of creating a simplex queue on SMP server is explained using
|
|
|
|
|
participants Alice (the recipient) who wants to receive the messages from Bob
|
|
|
|
|
(the sender).
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
To create and start using a simpelex queue Alice and Bob follow these steps:
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
1. Alice creates a simplex queue on the server:
|
2020-10-10 21:47:17 +01:00
|
|
|
1. decides which SMP server to use (can be the same or different server that
|
2020-10-22 11:29:48 +01:00
|
|
|
Alice uses for other queues) and opens secure encrypted transport
|
2020-10-10 21:47:17 +01:00
|
|
|
connection to the chosen SMP server (see [Appendix A](#appendix-a)).
|
|
|
|
|
2. generates a new random public/private key pair (encryption key - `EK`)
|
|
|
|
|
that she did not use before for Bob to encrypt the messages.
|
|
|
|
|
3. generates another new random public/private key pair (recepient key -
|
|
|
|
|
`RK`) that she did not use before for her to sign commands and to decrypt
|
|
|
|
|
the transmissions received from the server.
|
2020-10-22 11:29:48 +01:00
|
|
|
4. sends `"CONN"` command to the server to create a simplex queue (see
|
|
|
|
|
`create` in [Create queue command](#create-queue-command)). This command
|
|
|
|
|
can either be anonymous or the server can be configured to use the
|
2020-10-10 21:47:17 +01:00
|
|
|
signature field to authenticate the users who are allowed to create
|
2020-10-22 11:29:48 +01:00
|
|
|
queues. This command contains previouisly generated uniqie "public" key
|
|
|
|
|
`RK` that will be used to sign the following commands related to the same
|
|
|
|
|
queue, for example to subscribe to the messages received to this queue or
|
|
|
|
|
to update the queue, e.g. by setting the key required to send the messages
|
|
|
|
|
(initially Alice creates the queue that accepts unsigned messages, so
|
|
|
|
|
anybody could send the message via this queue if they knew the queue
|
|
|
|
|
sender's ID and server address).
|
|
|
|
|
5. The server sends `"IDS"` response with queue IDs (`queueIds`):
|
|
|
|
|
- recipient ID `RID` for Alice to manage the queue and to receive the
|
2020-10-10 21:47:17 +01:00
|
|
|
messages.
|
2020-10-22 11:29:48 +01:00
|
|
|
- sender ID `SID` for Bob to send messages to the queue.
|
2020-10-10 21:47:17 +01:00
|
|
|
2. Alice sends an out-of-band message to Bob via the alternative channel that
|
|
|
|
|
both Alice and Bob trust (see
|
|
|
|
|
[Simplex messaging protocol abstract](#simplex-messaging-protocol-abstract)
|
|
|
|
|
and [Appendix B](#appendix-b)). The message must include:
|
|
|
|
|
- the unique "public" key (`EK`) that Bob must use to encrypt messages.
|
|
|
|
|
- SMP server address and information to open secure encrypted transport
|
|
|
|
|
connection (see [Appendix A](#appendix-a))
|
2020-10-22 11:29:48 +01:00
|
|
|
- the sender queue ID `SID` for Bob to use.
|
|
|
|
|
3. Bob, having received the out-of-band message from Alice, connects to the
|
|
|
|
|
queue:
|
2020-10-10 21:47:17 +01:00
|
|
|
1. generates a new random public/private key pair (sender key - `SK`) that he
|
2020-10-22 11:29:48 +01:00
|
|
|
did not use before for him to sign messages sent to Alice's server.
|
|
|
|
|
2. prepares the confirmation message for Alice to secure the queue. This
|
2020-10-10 21:47:17 +01:00
|
|
|
message includes:
|
|
|
|
|
- previously generated "public" key `SK` that will be used by Alice's
|
2020-10-22 11:29:48 +01:00
|
|
|
server to authenticate Bob's messages, once the queue is secured.
|
2020-10-10 21:47:17 +01:00
|
|
|
- optionally, any additional information (application specific, e.g. Bob's
|
|
|
|
|
profile name and details).
|
|
|
|
|
3. encrypts the confirmation body with the "public" key `EK` (that Alice
|
|
|
|
|
provided via the out-of-band message).
|
2020-10-22 11:29:48 +01:00
|
|
|
4. sends the encrypted message to the server with queue ID `SID` (see `send`
|
|
|
|
|
in [Send message](#send-message)). This initial message to the queue must
|
|
|
|
|
not be signed - signed messages will be rejected until Alice secures the
|
|
|
|
|
queue (below).
|
|
|
|
|
4. Alice receives Bob's message from the server using recipient queue ID `RID`
|
|
|
|
|
(possibly, via the same transport connection she already has opened - see
|
|
|
|
|
`message` in [Deliver queue message](#deliver-queue-message)):
|
2020-10-10 21:47:17 +01:00
|
|
|
1. she decrypts received message with "private" key `EK`.
|
2020-10-22 11:29:48 +01:00
|
|
|
2. even though anybody could have sent the message to the queue with ID `SID`
|
|
|
|
|
before it is secured (e.g. if communication is compromised), Alice would
|
|
|
|
|
ignore all messages until the decryption succeeds (i.e. the result
|
2020-10-10 21:47:17 +01:00
|
|
|
contains the expected message format). Optionally, in the client
|
|
|
|
|
application, she also may identify Bob using the information provided, but
|
|
|
|
|
it is out of scope of SMP protocol.
|
2020-10-22 11:29:48 +01:00
|
|
|
5. Alice secures the queue `RID` with `"KEY"` command so only Bob can send
|
|
|
|
|
messages to it (see [Secure queue command](#secure-queue-command)):
|
2020-10-10 21:47:17 +01:00
|
|
|
1. she sends the command with `RID` signed with "private" key `RK` to update
|
2020-10-22 11:29:48 +01:00
|
|
|
the queue to only accept requests signed by "private" key `SK` provided by
|
|
|
|
|
Bob.
|
2020-10-10 21:47:17 +01:00
|
|
|
2. From this moment the server will accept only signed commands to `SID`, so
|
2020-10-22 11:29:48 +01:00
|
|
|
only Bob will be able to send messages to the queue `SID` (corresponding
|
|
|
|
|
to `RID` that Alice has).
|
|
|
|
|
3. Once queue is secured, Alice deletes `SID` and `SK` - even if Alice's
|
|
|
|
|
client is compromised in the future, the attacker would not be able to
|
2020-10-10 21:47:17 +01:00
|
|
|
send messages pretending to be Bob.
|
2020-10-22 11:29:48 +01:00
|
|
|
6. The simplex queue `RID` is now ready to use.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
This flow is shown on the sequence diagram below.
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
**Creating simplex queue from Bob to Alice:**
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|

|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
Bob now can securely send messages to Alice:
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
1. Bob sends the message:
|
|
|
|
|
1. he encrypts the message to Alice with "public" key `EK` (provided by
|
2020-10-22 11:29:48 +01:00
|
|
|
Alice, only known to Alice and Bob, used only for one simplex queue).
|
|
|
|
|
2. he signs `"SEND"` command to the server queue `SID` using the "private"
|
|
|
|
|
key `SK` (that only he knows, used only for this queue).
|
|
|
|
|
3. he sends the command to the server (see `send` in
|
|
|
|
|
[Send message](#send-message)), that the server will authenticate using
|
|
|
|
|
the "public" key `SK` (that Alice earlier provided to the server).
|
2020-10-10 21:47:17 +01:00
|
|
|
2. Alice receives the message(s):
|
2020-10-22 11:29:48 +01:00
|
|
|
1. she signs `"SUB"` command to the server to subscribe to the queue `RID`
|
|
|
|
|
with the "private" key `RK` (see `subscribe` in
|
|
|
|
|
[Subscribe to queue](#subscribe-to-queue)).
|
2020-10-10 21:47:17 +01:00
|
|
|
2. the server, having authenticated Alice's command with the "public" key
|
|
|
|
|
`RK` that she provided, delivers Bob's message(s) (see `message` in
|
2020-10-22 11:29:48 +01:00
|
|
|
[Deliver queue message](#deliver-queue-message)).
|
2020-10-10 21:47:17 +01:00
|
|
|
3. she decrypts Bob's message(s) with the "private" key `EK` (that only she
|
|
|
|
|
has).
|
2020-10-17 21:58:03 +01:00
|
|
|
4. she acknowledges the message reception to the server with `"ACK"` so that
|
|
|
|
|
the server can delete the message and deliver the next messages.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
This flow is show on sequence diagram below.
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
**Sending messages from Bob to Alice via simplex queue:**
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|

|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
**Simplex queue operation:**
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|

|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
Sequence diagram does not show E2EE - server knows nothing about encryption
|
|
|
|
|
between sender and receiver.
|
2020-01-22 15:09:07 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
A higher level protocol application protocol should define the semantics that
|
2020-10-22 11:29:48 +01:00
|
|
|
allow to use two simplex queues (or two sets of queues for redundancy) for the
|
|
|
|
|
bi-directional chat and for any other communication scenarios.
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
The SMP is intentionally unidirectional - it provides no answer to how Bob will
|
|
|
|
|
know that the transmission succeeded, and whether Alice received any messages.
|
2020-10-22 11:29:48 +01:00
|
|
|
There may be a scenario when Alice wants to securely receive the messages from
|
2020-10-10 21:47:17 +01:00
|
|
|
Bob, but she does not want Bob to have any proof that she received any
|
|
|
|
|
messages - this low-level simplex messaging protocol can be used in this
|
|
|
|
|
scenario, as all Bob knows as a fact is that he was able to send one unsigned
|
|
|
|
|
message to the server that Alice provided, and now can only send messages signed
|
|
|
|
|
with the key `SK` that he sent to the server - it does not prove that any
|
|
|
|
|
message was received by Alice.
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
For practical purposes of bi-directional conversation, now that Bob can securely
|
2020-10-22 11:29:48 +01:00
|
|
|
send encrypted messages to Alice, Bob can create the second simplex queue that
|
|
|
|
|
will allow Alice to send messages to Bob in the same way, sending the second
|
|
|
|
|
queue details via the first queue. If both Alice and Bob have their respective
|
|
|
|
|
uniqie "public" keys (Alice's and Bob's `EK`s of two separate queues), the
|
|
|
|
|
conversation can be both encrypted and signed.
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
The established queues can also be used to change the encryption keys providing
|
|
|
|
|
[forward secrecy][5].
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
This protocol also can be used for off-the-record messaging, as Alice and Bob
|
2020-10-22 11:29:48 +01:00
|
|
|
can use multiple queues between them and only information they pass to each
|
|
|
|
|
other allows proving their identity, so if they want to share anything
|
|
|
|
|
off-the-record they can initiate a new queue without linking it to any other
|
|
|
|
|
information they exchanged. As a result, this protocol provides better anonymity
|
|
|
|
|
and better protection from [MITM][1] than [OTR][6] protocol.
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
## SMP qualities and features
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
The simplex messaging protocol:
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
- defines only message-passing protocol:
|
|
|
|
|
- transport agnostic - the protocol does not define how clients connect to the
|
2020-10-17 21:58:03 +01:00
|
|
|
servers. It can be implemented over any ordered data stream channel: TCP
|
|
|
|
|
connection, HTTP with long polling, websockets, etc..
|
2020-10-22 11:29:48 +01:00
|
|
|
- not semantic - the protocol does not assign any meaning to queues and
|
|
|
|
|
messages. While on the application level the queues and messages can have
|
|
|
|
|
different meaning (e.g., for messages: text or image chat message, message
|
|
|
|
|
acknowledgement, participant profile information, status updates, changing
|
|
|
|
|
"public" key to encrypt messages, changing servers, etc.), on the simplex
|
|
|
|
|
messaging protocol level all the messages are binary and their meaning can
|
|
|
|
|
only be interpreted by client applications and not by the servers - this
|
|
|
|
|
interpretation is out of scope of this simplex messaging protocol.
|
2020-10-10 21:47:17 +01:00
|
|
|
- client-server architecture:
|
|
|
|
|
- multiple servers, that can be deployed by the system users, can be used to
|
|
|
|
|
send and retrieve messages.
|
2020-10-17 21:58:03 +01:00
|
|
|
- servers do not communicate with each other and do not "know" about other
|
|
|
|
|
servers.
|
2020-10-10 21:47:17 +01:00
|
|
|
- clients only communicate with servers (excluding the initial out-of-band
|
|
|
|
|
message), so the message passing is asynchronous.
|
2020-10-22 11:29:48 +01:00
|
|
|
- for each queue, the message recipient defines the server through which the
|
|
|
|
|
sender should send messages.
|
|
|
|
|
- while multiple servers and multiple queues can be used to pass each message,
|
|
|
|
|
it is in scope of application level protocol(s), and out of scope of this
|
|
|
|
|
simplex messaging protocol.
|
2020-10-10 21:47:17 +01:00
|
|
|
- servers store messages only until they are retrieved by the recipients, and
|
|
|
|
|
in any case, for a limited time.
|
|
|
|
|
- servers are required to NOT store any message history or delivery log, but
|
|
|
|
|
even if the server is compromised, it does not allow to decrypt the messages
|
2020-10-22 11:29:48 +01:00
|
|
|
or to determine the list of queues established by any participant - this
|
|
|
|
|
information is only stored on client devices.
|
|
|
|
|
- the only element provided by SMP servers is simplex queues:
|
|
|
|
|
- each queue is created and managed by the queue recipient.
|
2020-10-10 21:47:17 +01:00
|
|
|
- assymetric encryption is used to sign and verify the requests to send and
|
|
|
|
|
receive the messages.
|
|
|
|
|
- one unique "public" key is used for the servers to authenticate requests to
|
2020-10-22 11:29:48 +01:00
|
|
|
send the messages into the queue, and another unique "public" key - to
|
|
|
|
|
retrieve the messages from the queue. "Unique" here means that each "public"
|
|
|
|
|
key is used only for one queue and is not used for any other context -
|
|
|
|
|
effectively, this key is not public and does not represent any participant
|
|
|
|
|
identity.
|
|
|
|
|
- both "public" keys are provided to the server by the queue recepient when
|
|
|
|
|
the queue is created.
|
2020-10-10 21:47:17 +01:00
|
|
|
- the "public" keys known to the server and used to authenticate commands from
|
|
|
|
|
the participants are unrelated to the keys used to encrypt and decrypt the
|
2020-10-22 11:29:48 +01:00
|
|
|
messages - the latter keys are also unique per each queue but they are only
|
|
|
|
|
known to participants, not to the servers.
|
2020-10-10 21:47:17 +01:00
|
|
|
- messaging graph can be asymmetric: Bob's ability to send messages to Alice
|
|
|
|
|
does not automatically lead to the Alice's ability to send messages to Bob.
|
|
|
|
|
|
|
|
|
|
## Cryptographic algorithms
|
|
|
|
|
|
|
|
|
|
Simplex messaging clients need to cryptographically sign commands:
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
- with the recipient's key `RK` (server to verify):
|
2020-10-22 11:29:48 +01:00
|
|
|
- to subscribe to queue.
|
|
|
|
|
- to secure the queue.
|
2020-10-15 15:47:47 +01:00
|
|
|
- to acknowledge received messages.
|
2020-10-22 11:29:48 +01:00
|
|
|
- to suspend the queue.
|
|
|
|
|
- to delete the queue.
|
2020-10-10 21:47:17 +01:00
|
|
|
- with the sender's key `SK`:
|
|
|
|
|
- to send messages (server to verify).
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
To sign and verify commands, clients and servers MUST use RSA-PSS algorythm
|
|
|
|
|
defined in [RFC3447][2].
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
To optinally sign and verify messages, clients SHOULD use RSA-PSS algorythm.
|
|
|
|
|
|
|
|
|
|
To encrypt and decrypt messages, clients and servers SHOULD use RSA-OAEP
|
|
|
|
|
algorythm defined in [RFC3447][2].
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
The reasons to use these algorithms:
|
|
|
|
|
|
|
|
|
|
- they are supported by WebCrypto API.
|
|
|
|
|
- they are newer versions than RSA-PKCS1-v1_5 encryption and signature schemes.
|
|
|
|
|
- they are more widely supported than ECC algorithms
|
|
|
|
|
|
|
|
|
|
Future versions of the protocol may allow different algorithms.
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
## Simplex queue IDs
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
Simplex messaging servers MUST generate 2 different IDs for each new queue - for
|
|
|
|
|
recipient (that created the queue) and for sender. It is REQUIRED that:
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
- these IDs are different and unique within the server.
|
2020-10-17 21:58:03 +01:00
|
|
|
- based on 64-128-bit integers generated with cryptographically strong
|
2020-10-10 21:47:17 +01:00
|
|
|
pseudo-random number generator.
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
## Server privacy requirements
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
Simplex messaging server implementations MUST NOT create, store or send to any
|
|
|
|
|
other servers:
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
- logs of the client commands and transport connections in the production
|
|
|
|
|
environment.
|
2020-10-22 11:29:48 +01:00
|
|
|
- history of deleted queues, retrieved or acknowledged messages.
|
|
|
|
|
- snapshots of the database they use to store queues and messages (instead
|
2020-10-10 21:47:17 +01:00
|
|
|
simplex messaging clients must manage redundancy by using more than one
|
2020-10-22 11:29:48 +01:00
|
|
|
simplex messaging server).
|
2020-10-10 21:47:17 +01:00
|
|
|
- any other information that may compromise privacy or [forward secrecy][4] of
|
|
|
|
|
communication between clients using simplex messaging servers.
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
## SMP commands
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
Commands syntax below is provided using [ABNF][8].
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
Each transmission between the client and the server must have this format/syntax
|
|
|
|
|
(after the decryption):
|
|
|
|
|
|
|
|
|
|
```abnf
|
2020-10-18 12:50:14 +01:00
|
|
|
transmission = [signature] CRLF signed CRLF
|
2020-10-22 11:29:48 +01:00
|
|
|
signed = [queueId] CRLF msg
|
2020-10-10 21:47:17 +01:00
|
|
|
msg = recipientCmd / send / serverMsg
|
2020-10-15 15:47:47 +01:00
|
|
|
recipientCmd = create / subscribe / secure / acknowledge / suspend / delete
|
2020-10-22 11:29:48 +01:00
|
|
|
serverMsg = queueIds / message / unsubscribed / ok / error
|
|
|
|
|
queueId = encoded ; empty queue ID is used with "create" command
|
2020-10-10 22:16:36 +01:00
|
|
|
signature = encoded ; empty signature can be used with "create" and "send" commands
|
2020-10-10 21:47:17 +01:00
|
|
|
encoded = base64
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
`base64` encoding should be used with padding, as defined in section 4 of [RFC
|
|
|
|
|
4648][9]
|
|
|
|
|
|
|
|
|
|
The syntax of specific commands and responses is defined below.
|
|
|
|
|
|
|
|
|
|
### Correlating responses with commands
|
|
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
The server must send `queueIds`, `error` and `ok` responses in the same order
|
|
|
|
|
within each queue ID as the commands received in the transport connection, so
|
|
|
|
|
that they can be correlated by the clients.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
If the transport connection is closed before some responses are sent, these
|
|
|
|
|
responses should be discarded.
|
|
|
|
|
|
|
|
|
|
### Command authentication
|
|
|
|
|
|
|
|
|
|
The SMP servers must athenticate all transmissions (excluding `create` and
|
|
|
|
|
`send` commands sent with empty signatures) by verifying the provided
|
|
|
|
|
signatures. Signature should be the hash of the first part `signed` (including
|
|
|
|
|
CRLF characters) of `transmission`, encrypted with the key associated with the
|
2020-10-22 11:29:48 +01:00
|
|
|
queue ID (sender's or recepient's, depending on which queue ID is used).
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
### Recipient commands
|
|
|
|
|
|
|
|
|
|
Sending any of the commands in this section (other than `create`, that is sent
|
2020-10-22 11:29:48 +01:00
|
|
|
without queue ID) is only allowed with recipient's ID (`RID`). If sender's ID is
|
|
|
|
|
used the server must respond with `"ERR AUTH"` response (see
|
2020-10-10 21:47:17 +01:00
|
|
|
[Error responses](#error-responses)).
|
|
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
#### Create queue command
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
This command is sent by the recipient to the SMP server to create the new queue.
|
|
|
|
|
The syntax is:
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
```abnf
|
2020-10-22 11:29:48 +01:00
|
|
|
create = %s"NEW" SP recipientKey
|
2020-10-10 21:47:17 +01:00
|
|
|
recipientKey = encoded
|
|
|
|
|
```
|
|
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
If the queue is created successfully, the server must send `queueIds` response
|
|
|
|
|
with the recipient's and sender's queue IDs:
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
```abnf
|
2020-10-22 11:29:48 +01:00
|
|
|
queueIds = %s"IDS" SP recipientId SP senderId
|
2020-10-10 21:47:17 +01:00
|
|
|
recipientId = encoded
|
|
|
|
|
senderId = encoded
|
|
|
|
|
```
|
|
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
This response should be sent with empty queue ID (the second part of the
|
2020-10-17 21:07:15 +01:00
|
|
|
transmission).
|
|
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
Once the queue is created, the recipient gets automatically subscribed to
|
|
|
|
|
receive the messages from that queue, until the transport connection is closed.
|
|
|
|
|
The `subscribe` command is needed only to start receiving the messages from the
|
|
|
|
|
existing queue when the new transport queue is opened.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
`signature` part of NEW `transmission` should an empty string; SMP servers can
|
|
|
|
|
also use it to authenticate users who are allowed to create simplex queues on
|
|
|
|
|
the server.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
#### Subscribe to queue
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
When the simplex queue was not created in the current transport connection, the
|
|
|
|
|
recipient must use this command to start receiving messages from it:
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
```abnf
|
|
|
|
|
subscribe = %s"SUB"
|
|
|
|
|
```
|
|
|
|
|
|
2020-10-17 21:07:15 +01:00
|
|
|
If subscription is successful the server should respond with the first available
|
|
|
|
|
message or with `ok` response if no messages are available. The recipient will
|
2020-10-22 11:29:48 +01:00
|
|
|
continue receiving the messages from this queue until the transport connection
|
|
|
|
|
is closed or until another transport connection subscribes to the same simplex
|
|
|
|
|
queue - in this case the first subscription should be cancelled and
|
|
|
|
|
[subscription END notification](#subscription-end-notification) delivered.
|
2020-10-17 21:07:15 +01:00
|
|
|
|
|
|
|
|
The first message will be delivered either immediately or as soon as it is
|
|
|
|
|
available; to receive the following message the recipient must acknoledge the
|
|
|
|
|
reception of the message (see
|
|
|
|
|
[Acknowledge message delivery](#acknowledge-message-delivery)).
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
#### Secure queue command
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
This command is sent by the recipient to the server to add sender's key to the
|
2020-10-22 11:29:48 +01:00
|
|
|
queue:
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
```
|
2020-10-15 15:47:47 +01:00
|
|
|
secure = %s"KEY" SP senderKey
|
2020-10-10 21:47:17 +01:00
|
|
|
senderKey = encoded
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
`senderKey` is received from the sender as part of the first message - see
|
|
|
|
|
[Send Message Command](#send-message-command).
|
|
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
Once the queue is secured only signed messages can be sent to it.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-17 21:07:15 +01:00
|
|
|
#### Acknowledge message delivery
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-17 21:07:15 +01:00
|
|
|
The recipient should send the acknowledgement of message delivery once the
|
|
|
|
|
message was stored in the client, to notify the server that the message should
|
|
|
|
|
be deleted:
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
```abnf
|
2020-10-15 15:47:47 +01:00
|
|
|
acknowledge = %s"ACK"
|
2020-10-10 21:47:17 +01:00
|
|
|
```
|
|
|
|
|
|
2020-10-17 21:07:15 +01:00
|
|
|
Even if acknowledgement is not sent by the recipient, the server should limit
|
|
|
|
|
the time of message storage, whether it was delivered to the recipient or not.
|
|
|
|
|
|
2020-10-17 21:58:03 +01:00
|
|
|
Having received the acknowledgement, SMP server should immediately delete the
|
|
|
|
|
sent message and then send the next available message or respond with `ok` if
|
2020-10-22 11:29:48 +01:00
|
|
|
there are no more messages stored in this simplex queue.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
#### Suspend queue
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
The recipient can suspend queue prior to deleting it to make sure that no
|
2020-10-10 21:47:17 +01:00
|
|
|
messages are lost:
|
|
|
|
|
|
|
|
|
|
```abnf
|
2020-10-17 21:07:15 +01:00
|
|
|
suspend = %s"OFF"
|
2020-10-10 21:47:17 +01:00
|
|
|
```
|
|
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
The server must respond with `"ERR AUTH"` to any messages sent after the queue
|
|
|
|
|
was suspended (see [Error responses](#error-responses)).
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-17 21:58:03 +01:00
|
|
|
The server must respond `ok` to this command if it was successful.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
This command can be sent multiple times (in case transport connection was
|
|
|
|
|
interrupted and the response was not delivered), the server should still respond
|
2020-10-22 11:29:48 +01:00
|
|
|
`ok` even if the queue is already suspended.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
There is no command to resume the queue. Servers must delete suspended queues
|
|
|
|
|
that were not deleted after some period of time.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
#### Delete queue
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
The recipient can delete the queue, whether it was suspended or not.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
All undelivered messages will not be delivered - they should be deleted as soon
|
|
|
|
|
as command is received, before the response is sent.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
```abnf
|
2020-10-15 15:47:47 +01:00
|
|
|
delete = %s"DEL"
|
2020-10-10 21:47:17 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Sender commands
|
|
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
Currently SMP defines only one command that can be used by senders - `send`
|
2020-10-10 21:47:17 +01:00
|
|
|
message. This command must be used with sender's ID, if recipient's ID is used
|
2020-10-15 15:47:47 +01:00
|
|
|
the server must respond with `"ERR AUTH"` response (see
|
2020-10-10 21:47:17 +01:00
|
|
|
[Error responses](#error-responses)).
|
|
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
#### Send message
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
This command is sent to the server by the sender both to confirm the queue after
|
|
|
|
|
the sender received out-of-band message from the recipient and to send messages
|
|
|
|
|
after the queue is secured:
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
```abnf
|
2020-10-10 22:16:36 +01:00
|
|
|
send = %s"SEND" SP msgBody
|
2020-10-10 21:47:17 +01:00
|
|
|
msgBody = stringMsg | binaryMsg
|
2020-10-18 12:50:14 +01:00
|
|
|
stringMsg = ":" string ; until CRLF in the transmission
|
2020-10-10 21:47:17 +01:00
|
|
|
string = *(%x01-09 / %x0B-0C / %x0E-FF %) ; any characters other than NUL, CR and LF
|
2020-10-18 12:50:14 +01:00
|
|
|
binaryMsg = size CRLF msgBody CRLF ; the last CRLF is in addition to CRLF in the transmission
|
2020-10-10 21:47:17 +01:00
|
|
|
size = 1*DIGIT ; size in bytes
|
|
|
|
|
msgBody = *OCTET ; any content of specified size - safe for binary
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
`stringMsg` is allowed primarily to test SMP servers, e.g. via telnet.
|
|
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
The first message is sent to confirm the queue - it should contain sender's
|
2020-10-17 21:58:03 +01:00
|
|
|
server key (see decrypted message syntax below) - this first message must be
|
|
|
|
|
sent without signature.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
Once queue is secured (see [Secure queue command](#secure-queue-command)),
|
|
|
|
|
messages must be sent with the signature.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-15 15:47:47 +01:00
|
|
|
The server must respond with `"ERR AUTH"` response in the following cases:
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
- queue does not exist or suspended,
|
|
|
|
|
- queue is secured but the transmission does NOT have a signature,
|
|
|
|
|
- queue is NOT secured but the transmission has a signature.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
Until the queue is secured, the server should accept any number of unsigned
|
2020-10-10 21:47:17 +01:00
|
|
|
messages - it both enables the legimate sender to resend the confirmation in
|
|
|
|
|
case of failure and also allows the simplex messaging client to ignore any
|
|
|
|
|
confirmation messages that may be sent by the attackers (assuming they could
|
2020-10-22 11:29:48 +01:00
|
|
|
have intercepted the queue ID in the server response, but do not have a correct
|
|
|
|
|
encryption key passed to sender in out-of-band message).
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
The body should be encrypted with the recipient's "public" key (`EK`); once
|
|
|
|
|
decrypted it must have this format:
|
|
|
|
|
|
|
|
|
|
```abnf
|
2020-10-15 15:47:47 +01:00
|
|
|
decryptedBody = reserved LF clientBody LF
|
2020-10-10 21:47:17 +01:00
|
|
|
reserved = senderKeyMsg / *VCHAR
|
2020-10-10 22:16:36 +01:00
|
|
|
senderKeyMsg = %s"KEY" SP senderKey
|
2020-10-10 21:47:17 +01:00
|
|
|
senderKey = encoded
|
|
|
|
|
clientBody = *OCTET
|
|
|
|
|
```
|
|
|
|
|
|
2020-10-17 21:07:15 +01:00
|
|
|
`reserved` in the initial unsigned message is used to transmit sender's server
|
|
|
|
|
key and can be used in the future revisions of SMP protocol for other purposes.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
### Server messages
|
|
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
#### Queue IDs response
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
Server must respond with this message when the new queue is created.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
See its syntax in [Create queue command](#create-queue-command)
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
#### Deliver queue message
|
2020-10-10 21:47:17 +01:00
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
The server must deliver messages to all subscribed simplex queues on the
|
2020-10-10 21:47:17 +01:00
|
|
|
currently open transport connection. The syntax for the message delivery is:
|
|
|
|
|
|
|
|
|
|
```abnf
|
2020-10-17 21:58:03 +01:00
|
|
|
message = %s"MSG" SP msgId SP timestamp SP binaryMsg
|
|
|
|
|
msgId = encoded
|
2020-10-10 21:47:17 +01:00
|
|
|
timestamp = date-time; RFC3339
|
|
|
|
|
```
|
|
|
|
|
|
2020-10-17 21:58:03 +01:00
|
|
|
`msgId` - unique message ID generated by the server based on 32-64 bits
|
2020-10-22 11:29:48 +01:00
|
|
|
cryptographically strong random number. It should be used by the clients to
|
|
|
|
|
detect messages that were delivered more than once (in case the transport
|
|
|
|
|
connection was interrupted and the server did not receive the message delivery
|
2020-10-17 21:58:03 +01:00
|
|
|
acknowledgement).
|
|
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
`timestamp` - the UTC time when the server received the message from the sender,
|
|
|
|
|
must be in date-time format defined by [RFC 3339][10]
|
|
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
`binaryMsg` - see syntax in [Send message](#send-message)
|
2020-10-17 21:07:15 +01:00
|
|
|
|
|
|
|
|
#### Subscription END notification
|
|
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
When another transport connection is subscribed to the same simplex queue, the
|
|
|
|
|
server should unsubscribe and to send the notification to the previously
|
2020-10-17 21:07:15 +01:00
|
|
|
subscribed transport connection:
|
|
|
|
|
|
|
|
|
|
```abnf
|
|
|
|
|
unsubscribed = %s"END"
|
|
|
|
|
```
|
|
|
|
|
|
2020-10-17 21:58:03 +01:00
|
|
|
No further messages should be delivered to unsubscribed transport connection.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
#### Error responses
|
|
|
|
|
|
|
|
|
|
The server can respond with an error response in the following cases:
|
|
|
|
|
|
2020-10-15 15:47:47 +01:00
|
|
|
- unknown command name (`"UNKNOWN"`),
|
2020-10-22 11:29:48 +01:00
|
|
|
- prohibited command (`"PROHIBITED"`) - any server response sent from client or
|
|
|
|
|
`ACK` sent without active subscription or without message delivery,
|
2020-10-15 15:47:47 +01:00
|
|
|
- incorrect command or transmission syntax (`"SYNTAX"`) - see error codes below
|
|
|
|
|
- incorrect message body size (`"SIZE"`)
|
|
|
|
|
- authentication error (`"AUTH"`) - incorrect signature, unknown (or suspended)
|
2020-10-22 11:29:48 +01:00
|
|
|
queue, sender's ID is used in place of recipient's and vice versa, and some
|
|
|
|
|
other cases (see [Send message command](#send-message-command))
|
2020-10-10 21:47:17 +01:00
|
|
|
- internal server error (`"INTERNAL"`).
|
|
|
|
|
|
|
|
|
|
The syntax for error responses:
|
|
|
|
|
|
|
|
|
|
```abnf
|
2020-10-15 15:47:47 +01:00
|
|
|
error = %s"ERR " errorType
|
|
|
|
|
errorType = %s"UNKNOWN" / %s"PROHIBITED" / %s"SYNTAX " code / %s"SIZE" / %s"AUTH" / %s"INTERNAL"
|
2020-10-17 21:07:15 +01:00
|
|
|
code = badTransmission / badParameters / noCredentials / hasCredentials / noConnId / msgBody
|
2020-10-22 11:29:48 +01:00
|
|
|
badTransmission = "1" ; signature or queue ID are not valid base64 encoded string
|
2020-10-15 15:47:47 +01:00
|
|
|
badParameters = "2" ; incorrect number or format of parameters
|
2020-10-22 11:29:48 +01:00
|
|
|
noCredentials = "3" ; queue ID and/or signature are required but absent
|
|
|
|
|
hasCredentials = "4" ; queue ID and/or signature are not allowed but present
|
|
|
|
|
noConnId = "5" ; queue ID is required and absent - only used in SEND command atm
|
2020-10-15 15:47:47 +01:00
|
|
|
msgBody = "6" ; message body has incorrect format, it is neither a number nor starts from ":"
|
2020-10-10 21:47:17 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Server implementations must aim to respond within the same time for each command
|
2020-10-15 15:47:47 +01:00
|
|
|
in all cases when `"ERR AUTH"` response is required to prevent timing attacks
|
2020-10-22 11:29:48 +01:00
|
|
|
(e.g., the server should execute signature verification even when the queue does
|
|
|
|
|
not exist on the server).
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
### OK response
|
|
|
|
|
|
|
|
|
|
When the command is successfully executed by the server, it should respond with
|
|
|
|
|
OK response:
|
|
|
|
|
|
|
|
|
|
```abnf
|
|
|
|
|
ok = %s"OK"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Appendices
|
|
|
|
|
|
|
|
|
|
### Appendix A.
|
|
|
|
|
|
|
|
|
|
Secure encrypted transport connection with the SMP server.
|
|
|
|
|
|
|
|
|
|
Both the recipient and the sender can use TCP or some other (possibly higher
|
|
|
|
|
level) transport protocol to communicate with the server.
|
|
|
|
|
|
|
|
|
|
Some protocol should be used to ecrypt the connection traffic - one simple
|
|
|
|
|
option that does not require any cetralized certificate authority is below.
|
|
|
|
|
|
2020-10-22 11:29:48 +01:00
|
|
|
When the transport connection is established, the server sends the binary
|
|
|
|
|
encryption key that the client should match with key or fingerprint available to
|
|
|
|
|
them - if they do not match, they should terminate the connection.
|
2020-10-10 21:47:17 +01:00
|
|
|
|
|
|
|
|
The client should respond with the symmetric key that will be used by both the
|
|
|
|
|
client and the server to encrypt all traffic in the connection - this key should
|
|
|
|
|
be encrypted with the public key initially sent by the server.
|
|
|
|
|
|
|
|
|
|
After the symmetric key is sent to the server, all communication should happen
|
2020-10-22 11:29:48 +01:00
|
|
|
in encrypted binary chunks having a fixed size (e.g. 4096 bytes) irrespective of
|
|
|
|
|
the size of the command/message that should be sent. Smaller messages should be
|
2020-10-10 21:47:17 +01:00
|
|
|
padded, multiple commands/messages can be packed into a single chunk. If the
|
|
|
|
|
application using SMP needs to transmit a file or a larger message, it should be
|
|
|
|
|
broken down into fragments. The format of application level messages within SMP
|
|
|
|
|
commands is out of scope of this protocol.
|
|
|
|
|
|
|
|
|
|
### Appendix B.
|
|
|
|
|
|
|
|
|
|
Sending out-of-band message.
|
|
|
|
|
|
|
|
|
|
SMP does not prescribe the channel to pass out-of-band message - it should be
|
|
|
|
|
agreed by the client applications.
|
2020-01-21 21:01:48 +00:00
|
|
|
|
2020-10-10 21:47:17 +01:00
|
|
|
For practical purposes various solutions can be used, e.g. one of the versions
|
|
|
|
|
or the analogues of [QR code][3] (or their sequence) that is read via the
|
|
|
|
|
camera, either directly from the participant's device or via the video call.
|
|
|
|
|
Although a video call still allows for a highly sophisticated MITM attack, it
|
2020-10-22 11:29:48 +01:00
|
|
|
would require that in addition to compromising simplex queue to intercept
|
2020-10-10 21:47:17 +01:00
|
|
|
messages, the attacker also identifies and compromises the video connection in
|
|
|
|
|
another channel and substitutes the video in real time.
|
2020-01-21 21:01:48 +00:00
|
|
|
|
|
|
|
|
[1]: https://en.wikipedia.org/wiki/Man-in-the-middle_attack
|
|
|
|
|
[2]: https://en.wikipedia.org/wiki/End-to-end_encryption
|
|
|
|
|
[3]: https://en.wikipedia.org/wiki/QR_code
|
|
|
|
|
[4]: https://en.wikipedia.org/wiki/Unidirectional_network
|
|
|
|
|
[5]: https://en.wikipedia.org/wiki/Forward_secrecy
|
|
|
|
|
[6]: https://en.wikipedia.org/wiki/Off-the-Record_Messaging
|
2020-10-10 21:47:17 +01:00
|
|
|
[8]: https://tools.ietf.org/html/rfc5234
|
|
|
|
|
[9]: https://tools.ietf.org/html/rfc4648#section-4
|
|
|
|
|
[10]: https://tools.ietf.org/html/rfc3339
|