From 226b58b31224e98f7657a04443e375f7f44ecb1e Mon Sep 17 00:00:00 2001 From: Melvin Keskin Date: Thu, 12 Mar 2020 19:08:42 +0100 Subject: [PATCH 1/4] XEP-0384: Rely also on PubSub --- xep-0384.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xep-0384.xml b/xep-0384.xml index 58f46cb4..05323850 100644 --- a/xep-0384.xml +++ b/xep-0384.xml @@ -173,7 +173,7 @@

While in the future a dedicated key server component could be used to distribute - key material for session creation, the current specification relies on &xep0163; to publish + key material for session creation, the current specification relies on &xep0060; and &xep0163; to publish and acquire key bundles.

From 324507d8ee0804ee389d23c6357e31fb193a95a8 Mon Sep 17 00:00:00 2001 From: Melvin Keskin Date: Thu, 12 Mar 2020 19:12:52 +0100 Subject: [PATCH 2/4] XEP-0384: Fix misspellings --- xep-0384.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xep-0384.xml b/xep-0384.xml index 05323850..72991b3e 100644 --- a/xep-0384.xml +++ b/xep-0384.xml @@ -508,7 +508,7 @@

When an OMEMO element is received, the client MUST check whether there is a <keys> element with a jid attribute matching its own bare jid and an inner <key> element with a rid attribute matching its own device id. If this is not the case the message was not encrypted for this particular device and a warning message SHOULD be displayed instead. If such an element exists, the client checks whether the element's contents are an OMEMOKeyExchange.

If this is the case, a new session is built from this received element. The client MUST then republish their bundle information, replacing the used PreKey, such that it won't be used again by a different client. If the client already has a session with the sender's device, it MUST replace this session with the newly built session. The client MUST eventually delete the private key belonging to the PreKey after use (this is subject to the Business rules).

-

If the element's contents are a OMEMOAuthenticatedMessage, and the client has a session with the sender's device, it tries to decrypt the OMEMOAuthenticatedMessage using this session. If the decryption fails or there is no session with the sending device, a warning message SHOULD be displayed instead. Also refer to the section about recovering from broken sessions in the Business Rules.

+

If the element's contents are an OMEMOAuthenticatedMessage, and the client has a session with the sender's device, it tries to decrypt the OMEMOAuthenticatedMessage using this session. If the decryption fails or there is no session with the sending device, a warning message SHOULD be displayed instead. Also refer to the section about recovering from broken sessions in the Business Rules.

After either the OMEMOKeyExchange or the OMEMOAuthenticatedMessage is decrypted, the content is decrypted as described in the section about Message Decryption.

@@ -547,7 +547,7 @@

Before sending a message a participant MUST explicitly fetch device lists (if not already cached) for each of the members.

- From 3849495c3dba53f0e6b1c72880039ba8a2e7a906 Mon Sep 17 00:00:00 2001 From: Melvin Keskin Date: Thu, 12 Mar 2020 21:14:08 +0100 Subject: [PATCH 3/4] XEP-0384: Clarify confusing sentences --- xep-0384.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xep-0384.xml b/xep-0384.xml index 72991b3e..24f0ce9f 100644 --- a/xep-0384.xml +++ b/xep-0384.xml @@ -481,8 +481,8 @@

An OMEMO encrypted message is specified to include an <encrypted> element in the 'urn:xmpp:omemo:1' namespace. It always contains two child nodes, the <header> and the &payload; element. The <header> element has an attribute named 'sid' referencing the device id of the sending device and contains one or multiple <keys> elements, each with an attribute 'jid' of one of the recipients bare JIDs as well as one or multiple <key> elements. - A <key> element has an attribute named 'rid' referencing the device id of the recipient device, and an attribute named 'kex' which defaults to 'false' and indicates if the enclosed encrypted message includes a key exchange. The ciphertext that is the key and HMAC encrypted using the long-standing OMEMO session for that recipient device is encoded using base64 and placed as text content into the <key> element. - The ciphertext that is the encrypted &content; element is encoded using base64 and placed as text content into the &payload; element. + A <key> element has an attribute named 'rid' referencing the device id of the recipient device, and an attribute named 'kex' which defaults to 'false' and indicates if the enclosed encrypted message includes a key exchange. The key and HMAC encrypted using the long-standing OMEMO session for that recipient device are encoded using base64 and placed as text content into the <key> element. + The encrypted &content; element is encoded using base64 and placed as text content into the &payload; element.

From 32eb6e5ace8acf98185923f04190c17046c4aa7e Mon Sep 17 00:00:00 2001 From: Melvin Keskin Date: Thu, 12 Mar 2020 22:43:14 +0100 Subject: [PATCH 4/4] XEP-0384: Use consistent quotation marks --- xep-0384.xml | 116 +++++++++++++++++++++++++-------------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/xep-0384.xml b/xep-0384.xml index 24f0ce9f..e6934418 100644 --- a/xep-0384.xml +++ b/xep-0384.xml @@ -180,7 +180,7 @@

It is a result of XMPP's federated nature that a message may pass more than just one server. Therefore it is in the users' interest to secure their communication from any intermediate host. End-to-end encryption is an efficient way to protect any data exchanged between sender and receiver against passive and active attackers such as servers and network nodes.

-

OMEMO is an end-to-end encryption protocol based on the Double Ratchet specified in section Double Ratchet. It provides the following guarantees under the threat model described in the next section:

+

OMEMO is an end-to-end encryption protocol based on the Double Ratchet specified in section Double Ratchet. It provides the following guarantees under the threat model described in the next section:

  • Confidentiality: Nobody else except sender and receiver is able to read the content of a message.
  • Perfect forward secrecy: Compromised key material does not compromise previous or future message exchanges.
  • @@ -221,28 +221,28 @@

    - The X3DH key exchange is specified here and placed under the public domain. OMEMO uses this key exchange mechanism with the following parameters/settings: + The X3DH key exchange is specified here and placed under the public domain. OMEMO uses this key exchange mechanism with the following parameters/settings:

    curve
    X25519
    hash function
    SHA-256
    info string
    "OMEMO X3DH"
    -
    byte-encoding of the public keys
    The little-endian encoding of the u-coordinate as specified here (this is the default way most crypto-libraries encode the public key).
    +
    byte-encoding of the public keys
    The little-endian encoding of the u-coordinate as specified here (this is the default way most crypto-libraries encode the public key).
    signed PreKey rotation period
    Signed PreKeys SHOULD be rotated periodically once a week to once a month. A faster or slower rotation period should not be required.
    time to keep the private key of the old signed PreKey after rotating it
    The private key of the old signed PreKey SHOULD be kept for another rotation period as defined above, to account for delayed messages using the old signed PreKey.
    number of PreKeys to provide in the bundle
    The bundle SHOULD always contain around 100 PreKeys.
    minimum number of PreKeys to provide in the bundle
    The bundle MUST always contain at least 25 PreKeys.
    associated data
    The associated data is created by concatenating the IdentityKeys of Alice and Bob: AD = Encode(IK_A) || Encode(IK_B)
    -
    XEdDSA
    To reduce the amount of bytes that have to be transferred, the key exchange uses XEdDSA on curves X25519/Ed25519 (aka XEd25519) to build and verify signatures using encryption key pairs.
    +
    XEdDSA
    To reduce the amount of bytes that have to be transferred, the key exchange uses XEdDSA on curves X25519/Ed25519 (aka XEd25519) to build and verify signatures using encryption key pairs.

    The key exchange is done just-in-time when sending the first message to a device. Thus, each key exchange message always also contains encrypted content as produced by the Double Ratchet encryption scheme below.

    -

    NOTE: OMEMOMessage.proto, OMEMOAuthenticatedMessage.proto and OMEMOKeyExchange.proto refer to the protobuf structures as defined here.

    +

    NOTE: OMEMOMessage.proto, OMEMOAuthenticatedMessage.proto and OMEMOKeyExchange.proto refer to the protobuf structures as defined here.

    - The Double Ratchet encryption scheme is specified here and placed under the public domain. OMEMO uses this protocol with the following parameters/settings: + The Double Ratchet encryption scheme is specified here and placed under the public domain. OMEMO uses this protocol with the following parameters/settings:

    ratchet initialization
    The Double Ratchet is initialized using the shared secret, ad and public keys as yielded by the X3DH key exchange, as explained in the Double Ratchet specification.
    @@ -257,7 +257,7 @@
    1. Use HKDF-SHA-256 to generate 80 bytes of output from the message key by providing mk as HKDF input, 256 zero-bits as HKDF salt and "OMEMO Message Key Material" as HKDF info.
    2. Divide the HKDF output into a 32-byte encryption key, a 32-byte authentication key and a 16 byte IV.
    3. -
    4. Encrypt the plaintext (which consists of a 32 bytes key and a 32 bytes HMAC as specified here) using AES-256-CBC with PKCS#7 padding, using the encryption key and IV derived in the previous step.
    5. +
    6. Encrypt the plaintext (which consists of a 32 bytes key and a 32 bytes HMAC as specified here) using AES-256-CBC with PKCS#7 padding, using the encryption key and IV derived in the previous step.
    7. Split the associated data as returned by CONCAT into the original ad and the OMEMOMessage.proto structure.
    8. Add the ciphertext to the OMEMOMessage.proto structure.
    9. Serialize the ad and the OMEMOMessage.proto structure into a parseable byte array by concatenating ad and the serialized protobuf structure.
    10. @@ -364,7 +364,7 @@

      Furthermore, a device MUST publish its IdentityKey, a signed PreKey, and a list of PreKeys. This tuple is called a bundle and is provided by OMEMO libraries. Bundles are maintained as multiple items in a PEP node called &nsbundles;. Each bundle MUST be stored in a seperate item. The item id MUST be set to the device id.

      A bundle is an element called 'bundle' in the &ns; namespace. It has a child element called ‘spk’ that contains the public part of the signed PreKey as base64 encoded data, a child element called ‘spks’ that contains the signed PreKey signature as base64 encoded data and a child element called ‘ik’ that contains the public part of the IdentityKey as base64 encoded data. PreKeys are multiple elements called ‘pk’ that each contain the public part of one PreKey as base64 encoded data. PreKeys are wrapped in an element called ‘prekeys’ which is a child of the bundle element. The ‘spk’ and the ‘pk’s are tagged with an ‘id’-attribute which is a positive integer that uniquely identifies the keys. The ‘spk’ and the ‘pk’s are considered separate, which means that an ‘spk’ can have the same ‘id’ as a ‘pk’. These ids are used to save bandwidth during key exchanges, which refer to the keys using their id instead of their full public parts.

      -

      When publishing bundles a client MUST make sure that the &nsbundles; node is configured to store multiple items. This is not the default with &xep0163;. If the node doesn’t exist yet it can be configured on the fly by using publish-options as described in XEP-0060 §7.1.5. The value for 'pubsub#max_items' in publish_options MUST be set to 'max'. If the node did exist and was configured differently the bundle publication will fail. Clients MUST then reconfigure the node as described in XEP-0060 §8.2.

      +

      When publishing bundles a client MUST make sure that the &nsbundles; node is configured to store multiple items. This is not the default with &xep0163;. If the node doesn’t exist yet it can be configured on the fly by using publish-options as described in XEP-0060 §7.1.5. The value for 'pubsub#max_items' in publish_options MUST be set to 'max'. If the node did exist and was configured differently the bundle publication will fail. Clients MUST then reconfigure the node as described in XEP-0060 §8.2.

      @@ -426,7 +426,7 @@

      In order to build a session with a device, their bundle information is fetched.

      - SHOULD contain a <from/> affix element.
    11. MUST contain a <to/> affix element whenever a message is sent via a group chat (MUC/MIX). This is used to prevent the server from silently converting a group message into a private message and vice versa.
- @@ -471,7 +471,7 @@

- The &content; element is encrypted as described in the section about Message Encryption. + The &content; element is encrypted as described in the section about Message Encryption.

Clients MUST only consider the devices on the &nsdevices; node of each recipient (i.e. including their own devices node, but excluding itself). @@ -484,7 +484,7 @@ A <key> element has an attribute named 'rid' referencing the device id of the recipient device, and an attribute named 'kex' which defaults to 'false' and indicates if the enclosed encrypted message includes a key exchange. The key and HMAC encrypted using the long-standing OMEMO session for that recipient device are encoded using base64 and placed as text content into the <key> element. The encrypted &content; element is encoded using base64 and placed as text content into the &payload; element.

-
@@ -493,7 +493,7 @@ b64/encoded/data - b64/encoded/data + b64/encoded/data
@@ -507,10 +507,10 @@

When an OMEMO element is received, the client MUST check whether there is a <keys> element with a jid attribute matching its own bare jid and an inner <key> element with a rid attribute matching its own device id. If this is not the case the message was not encrypted for this particular device and a warning message SHOULD be displayed instead. If such an element exists, the client checks whether the element's contents are an OMEMOKeyExchange.

-

If this is the case, a new session is built from this received element. The client MUST then republish their bundle information, replacing the used PreKey, such that it won't be used again by a different client. If the client already has a session with the sender's device, it MUST replace this session with the newly built session. The client MUST eventually delete the private key belonging to the PreKey after use (this is subject to the Business rules).

-

If the element's contents are an OMEMOAuthenticatedMessage, and the client has a session with the sender's device, it tries to decrypt the OMEMOAuthenticatedMessage using this session. If the decryption fails or there is no session with the sending device, a warning message SHOULD be displayed instead. Also refer to the section about recovering from broken sessions in the Business Rules.

+

If this is the case, a new session is built from this received element. The client MUST then republish their bundle information, replacing the used PreKey, such that it won't be used again by a different client. If the client already has a session with the sender's device, it MUST replace this session with the newly built session. The client MUST eventually delete the private key belonging to the PreKey after use (this is subject to the Business rules).

+

If the element's contents are an OMEMOAuthenticatedMessage, and the client has a session with the sender's device, it tries to decrypt the OMEMOAuthenticatedMessage using this session. If the decryption fails or there is no session with the sending device, a warning message SHOULD be displayed instead. Also refer to the section about recovering from broken sessions in the Business Rules.

- After either the OMEMOKeyExchange or the OMEMOAuthenticatedMessage is decrypted, the content is decrypted as described in the section about Message Decryption. + After either the OMEMOKeyExchange or the OMEMOAuthenticatedMessage is decrypted, the content is decrypted as described in the section about Message Decryption.

@@ -644,103 +644,103 @@ - + + - + - - + + - + - + - - + + - + - + - - + + - + - + - - - + + + - + - - + + - + - - + + - + - - - - + + + + - + - - + + - - + + - + - - + + - + - - + +