-
Notifications
You must be signed in to change notification settings - Fork 3
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
Proposed end-to-end encryption protocol #29
Comments
How does this relate to https://github.com/otrv4/otrv4 ? |
Covered in |
2 issues with the Olm side of this
Both could be solved by having a way to tell the other user that you don't know the session they're using to encrypt stuff, thus triggering a renegotiation |
I feel it pertinent that there's some teething issues with using things like Olm wrappers. I tried to get the python-olm lib working today and ended up having to jump through some hoops for it because Debian repos don't have |
@jesopo This will be an issue regardless of crypto algorithm used. American crypto export laws are widely ignored by existing IRC implementations for OTR so I don't see why this will be an issue for OLM. |
It's not that it's an issue with OLM directly, but it's an issue with encryption in general when the libraries are distributed/hosted in the US. The fact that it's not an issue with OTR is only representative of the fact that it's not noticeable by the government, right? Wouldn't this happen regardless of algorithm used so long as the distributed/hosted are published in the US? |
just a note about this potentially not being very pleasant for client devs to work with. |
My impression is that there is a full carve-out in the export regulations for FOSS:
I think we should not allow the export regulations to deter us from standardizing OLM (or any other cryptographic algorithm). |
The following is a partisan/opinionated summary of some discussion from #ircv3 (not all of these ideas are mine, but any misconceptions are):
|
I just came across a blog post about the Messaging Layer Security working group, which may have a better story about key trust and revocation: |
I think there are at least two group usage modalities we should consider. Small, invite only group chats benefit from not needing to trust a service provider to protect their privacy. On the other hand, huge public rooms with hundreds or thousands of users don't really see the same benefits, because participants already have to expect that their communications there are not private, with or without E2EE--because without controls on who can join, you have to assume that someone malicious has. So yeah, the benefits over TLS are more marginal for that scenario. But this difference leads to an important problem to solve: how to securely control the policy around whether to freely share the ratchet state with new users. Perhaps a boolean |
Agreed, the mutability of nicknames (well, more so, the unreliability of their ownership) is a problem. An environment where presence in a network/channel is persistent and independent from having a live network connection makes things much simpler. As far as I can tell this is related to CHATHISTORY, but not technically part of it? I wonder if it should somehow be a formal requirement for E2EE. |
I've implemented such a feature in Oragono 2.0.0 ("always-on"), but have not thought much about how to specify it or make it discoverable. How do you see this as changing the state of play, though? In a typical Oragono deployment, some clients will be always-on and others won't, and there's no way to detect whether another client is always-on. I think if we wanted to use the account system to harden TOFU, the thing to do would be to require account-tag on the relevant handshake messages.
Do you have any thoughts on megolm vs. MLS? |
I think most of the point of IRCv3 is to address this and create strong, owned, authenticated nicknames. |
Wouldn't say it's "most of the point" but it is a very strong point, that you should be able to obtain an account from a message. BitBot for the most part tracks by account name too, which is very nice. |
I don't think there has been much systematic attention to this issue. In a typical multi-server network, if the services framework goes down, I think the rest of the network will continue functioning with reduced or nonexistent nickname protections. Oragono can be configured to have nickname protections ranging from very strong (i.e., if the ircd is up at all, then nicknames are strictly protected and the nickname and the account name are synonyms) to nonexistent, but there is no ISUPPORT token to convey to the client which of these states is in effect. All that being said, I think the use case here is largely addressed by account-tag --- you could just require account-tag on the handshake messages that try to establish the counterparty's key. This seems peripheral to the megolm vs. MLS question. |
Then IRC3 has already failed. This is THE big problem with IRC. |
Doesn't something like OTR (mentioning this now would be helpful) help for some of this? I think they have some overlapping use-cases. Though, I did hear about OTR not at all being usable for public channels - but it could be a start. |
still digesting the full conversation but wanted to mention https://saltpack.org/ which was developed by keybase |
double ratchet and more is now an RFC https://www.rfc-editor.org/rfc/rfc9420.html |
Background
This protocol is an adaptation of Matrix.org's Olm and Megolm encryption to the IRC protocol.
Olm is an implementation of the double ratchet algorithm developed by Open Whisper Systems and
first used in the Signal app.
The IRC adaptation is being designed under KiwiIRC with the goal of creating a modern end-to-end
encryption standard for IRC that could be implemented by many different clients.
Peer sessions
Raw byte arrays are base64 encoded without padding for transmission as Message Tag values.
To establish a one-on-one session with another user, we must first obtain their public identity key
and a one-time-key.
At this point, alice can construct an outgoing session to bob using the onetimekey and identity and
start sending encrypted payloads such as OlmMessages:
When the first packet is received by the other side, they will be able to construct the session
ratchet and use it to send packets back as well.
Group sessions
For one-to-many encryption (in IRC channels), each sender creates an outbound-only ratchet. This
mitigates some scalability issues with ongoing sessions in large channels by avoiding the need to
encrypt a copy of each message separately for each recipient. First, encrypted one-to-one sessions
must be established between participants, as described in the previous section. Once these secure
channels are available they are used to share the ratchet state for the outbound group sessions.
Further details about the ratchet design can be found in the [Megolm docs].
After receiving the MegolmSessionState, any MegolmPackets created with that session from that point
forward can be decrypted.
All of the protocol sample codeblocks up to this point form a complete key negotiation and
conversation between two users in both one-to-one mode and group mode.
Payload types and serialization
Protocol payloads are serialized to CBOR as tagged entities with the following tag IDs and fields:
OlmPacket
0x7035
[senderKey: ByteString, type: int, body: ByteString]
The body field can contain an encrypted OlmMessage or MegolmSessionState.
OlmMessage
0x7036
text: string
A single chat message in a peer session.
OlmOneTimeKey
0x7037
oneTimeKey: ByteString
Combined with an OlmIdentity, OlmOneTimeKey is used to initialize a new peer session.
OlmIdentity
0x7038
curve25519IdentityKey: ByteString
MegolmMessage
0x7039
text: string
A single chat message in a group session.
MegolmPacket
0x703a
[ciphertext: ByteString, senderKey: ByteString, sessionID: ByteString, signature: ByteString]
Ciphertext contains an encrypted MegolmMessage.
MegolmSessionState
0x703b
[sessionID: ByteString, sessionKey: ByteString, messageIndex: ByteString]
Contains the ratchet state necessary to decrypt received MegolmPackets from a user.
Message Tag fragmentation
Because the serialized payloads can be particularly large, the message tag data will sometimes be
split across multiple IRC messages.
When a message is fragmented, it is marked with the tag
@+kiwi/fragmented
. When a message is acontinuation of a previous fragment, it is tagged
@+kiwi/previous-frag=<previous message ID>
.Fragmentation is only allowed on the following tags' values:
The tag values should be split into chunks of as large a size as possible within the limitations of
the Message Tags spec. The chunks do not need to be of equal size, but they must be transmitted in
order.
A client must not interpret the fragmented data until it has been reconstructed, with the final
fragment being indicated by the lack of a
@+kiwi/fragmented
tag.For example,
@+kiwi/olm-packet=abcdefghijklmnopqrstuvwxyz TAGMSG user
could be fragmented asfollows:
The sender will need to use a
label
tag and theecho-message
capability to find thedraft/msgid
of their sent message fragment in order to reference it with the+kiwi/previous-frag
tag.
Creating a compatible implementation
Our experimental javascript implementation makes use of the C libolm library compiled to WASM with
emscripten. Clients written in other languages should be able to use bindings to libolm to
implement the protocol in without needing to reimplement the cryptographic functions from the Olm
specs. Although the latter always remains a possibility.
Points of difficulty / Room for improvement
Tag fragmentation
protocol.
on the length of the server's generated msgids, whether we're trying to send the first, last, or
a middle fragment, and so on.
echo-message
with alabel
to find out your ownmsgid
adds significant latencysince we can't predict or generate our own
msgid
s.very small due to other tags being present) or others (i.e. resource leaks from never completing
the reassembly process).
Binary encoding overhead
Not having a way to directly transmit binary data causes significant overhead through base64
encoding.
Message Tags vs CBOR tagged entities
There is some impedance mismatch between the Message Tags and the CBOR serialized records. For
example, MegolmPacket packs four different values into one tag because using a separate Message Tag
for each part would be quite verbose, which eats into the space available for the actual data. The
values of our tags end up being self-describing through very efficient headers inside the CBOR
serialization, so it's tempting to only use a
+kiwi/olm
tag for everything instead.The self-describing serialized values are necessary for part of the protocol due to the end-to-end
encryption itself: some of the protocol messages need to be encapsulated inside encrypted blobs, and
we might as well not leak metadata about the nature of the encrypted payload.
But I stuck with multiple separate Message Tags in an attempt to mesh with the human-readable style
of the IRC protocol to the extent it was possible.
The text was updated successfully, but these errors were encountered: