Skip to content
This repository was archived by the owner on Jan 29, 2024. It is now read-only.
This repository was archived by the owner on Jan 29, 2024. It is now read-only.

OMEMO Identity Key Signing does not match the Spec #172

@COM8

Description

@COM8

Description

XEP-0384: OMEMO Encryption requires a EdDSA-compatible signature when signing Identity Keys. UWPX currently performs EdDSA with Curve25519 (Montgomery) based keys and not like mandated here by XEdDSA with Ed25519 (Twisted Edwards) keys.

Expected Behavior

We should use Ed25519 (Twisted Edwards) keys here.

Actual Behavior

/// <summary>
/// Generates the signature of the given <paramref name="preKey"/> and returns it.
/// </summary>
/// <param name="preKey">The <see cref="PreKeyModel"/> that should be signed.</param>
/// <param name="identiyKey">The private Key used for signing the given <paramref name="preKey"/>.</param>
/// <returns>The signature of the given <paramref name="preKey"/>.</returns>
public static byte[] SignPreKey(PreKeyModel preKey, ECPrivKeyModel identiyKey)
{
byte[] pubKey = preKey.pubKey.ToByteArrayWithPrefix();
Key key = Key.Import(SignatureAlgorithm.Ed25519, identiyKey.key, KeyBlobFormat.RawPrivateKey);
return SignatureAlgorithm.Ed25519.Sign(key, pubKey);
}

Possible Fix

Convert the Curve25519 (Montgomery) based keys to Ed25519 (Twisted Edwards) before signing. This is defined in by the XEdDSA spec inside the calculate_key_pair call.

Steps to Reproduce

  1. Add an account
  2. Connect the account
  3. UWPX will publish an OMEMO bundle with an "invalid" signature.
  4. Other clients (!= UWPX):💥

Context

We can no send OMEMO encrypted messages to other XMPP clients like Kaidan, that follow the spec.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions