This is an implementation of the OMEMO protocol based on X3DH written in C.
Get to know the main idea of the project: Main idea
- Unit - user, friend, one side of the conversation.
- libsodium
Flags: --init | -i.
cmemo -i
Export yours public bundle to share them.
Flags: --export | -x.
cmemo -x > pub.bl
Flags: --add | -a.
cmemo -a < unit_pub.bl
Value here is fingerprint of added unit public bundle.
Flags: --unit | -u.
cmemo -u 6860b33af65db960db48932aef5d512
To start a conversation, you need to make a request.
You and your interlocutor must agree on a common starting key for the conversation and the ID of the one-time prekey. The key needs to be from 1 to 32 characters long (above 32 no sense) and the ID must be from 0 to 99.
For example, the key "NONCE_SUPER_KEY" and the ID "67". They must be written using the ":" symbol:
NONCE_SUPER_KEY:67
You must save the public ephemeral key when requesting.
Flags: --request | -q.
cmemo -q NONCE_SUPER_KEY:67 -u 6860b33 > /tmp/eph.key
Flags: --response | -p.
cmemo -p NONCE_SUPER_KEY:67 -u 48dabed < /tmp/eph.key
Flags: --send | -s.
cmemo -s -u 48dabed < /tmp/msg > /tmp/enmsg
Flags: --receive | -r.
cmemo -r -u 6860b33 < /tmp/enmsg > /tmp/demsg
Used to indicate that you are receiving or sending encrypted data. Currently used "HEX".
Flags: --encode | -e.
echo "Hello, how are you?" | cmemo -s -u 48dabed -e
# Output: e831361abb5b73d...
echo "e831361abb5b73d..." | cmemo -r -u 6860b33 -e
# Output: Hello, how are you?
Create directories for Alice and Bob.
mkdir -p /tmp/cmemo/alice
mkdir -p /tmp/cmemo/bob
In two shells, we set the HOME for Alias and Bob.
export HOME="/tmp/cmemo/alice"
export HOME="/tmp/cmemo/bob"
Alice/Bob:
cmemo -i
Alice:
cmemo -a < /tmp/cmemo/bob/.cmemo/public.bl
Bob:
cmemo -a < /tmp/cmemo/alice/.cmemo/public.bl
Key: ExampleKey00
ID: 69
Alice:
cmemo -q ExampleKey00:69 -u 0bfb608d2 -e > /tmp/cmemo/ep.key
Bob:
cmemo -p ExampleKey00:69 -u e2e5a35dcd2 -e < /tmp/cmemo/ep.key
Alice:
echo "Hello, Bob" | cmemo -s -u 0bfb608d2 > /tmp/cmemo/enmsg
Bob:
cmemo -r -u e2e5a35dcd2 < /tmp/cmemo/enmsg
# Output: Hello, Bob
Bob:
echo "Hi, Alice" | cmemo -s -u e2e5a35dcd2 -e
# Output: f5fcde767b83...
Alice:
echo "f5fcde767b83..." | cmemo -r -u 0bfb608d2 -e
# Output: Hi, Alice
The main idea of the project is to enable sending end-to-end encrypted messages regardless of the method of transmission. You can easily use it in unencrypted messengers, game chats, radio, and so on. That is, you can write various extensions that can integrate into the chat, track history for any method of communication.
- Add base64 encoding.
- Clean code.
- Binding a nickname to unit.
- Export public bundle.
- Size-independent initial key.
- Add more errors messages.
This is my first project on C. I would be happy for any support and I absolutely accept consideration of any suggestions and improvements.