Open vith opened 5 years ago
How does this relate to https://github.com/otrv4/otrv4 ?
Covered in #ircv3
: OTR is for single device-device encryption only
2 issues with the Olm side of this
ERR_NOSUCHSICK
)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 libolm3
yet and the python wrapper in pip (which needs libolm3
rather than libolm2
which Debian has) can't have the C source included with it due to US crypto export control laws (this is the same reason the Olm source code is gitlab.matrix.org instead of github.com)
@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?
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.
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:
"Publicly available" encryption source code is not subject to the EAR once the email notification per section 742.15(b) is sent. A common example would be open source encryption source code available for free online.
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:
9. In my personal opinion, the benefits of multi-party E2EE are sufficiently marginal, relative to OTRvN for two-party and TLS-everywhere for multi-party, that the priority should be on producing a very strong proposal, even at the expense of shipping in a timely fashion.
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 promiscuous
field should be added to the MegolmSessionState
type.
4. Unlike XMPP (and Matrix?), the primary messaging target in IRC is the nickname, which is completely untrusted. This problematizes the use of trust-on-first-use for keys in the IRC setting, even where this technique has been successful in other domains. 5. account-tag is a partial fix for this problem; we might want to recommend its use.
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.
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.
Perhaps a boolean promiscuous field should be added to the MegolmSessionState type.
Do you have any thoughts on megolm vs. MLS?
The following is a partisan/opinionated summary of some discussion from #ircv3 (not all of these ideas are mine, but any misconceptions are):
4. Unlike XMPP (and Matrix?), the primary messaging target in IRC is the nickname, which is completely untrusted. This problematizes the use of trust-on-first-use for keys in the IRC setting, even where this technique has been successful in other domains.
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 think most of the point of IRCv3 is to address this and create strong, owned, authenticated nicknames.
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.
I don't think there has been much systematic attention to this issue.
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 a continuation 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 as follows: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
echo-message
with alabel
to find out your ownmsgid
adds significant latency since we can't predict or generate our ownmsgid
s.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.