test_olm.sh 1.41 KB
Newer Older
1
2
#! /bin/bash

3
4
set -e

5
6
cd `dirname $0`

7
OLM="python -m olm"
8
9
10

ALICE_ACCOUNT=alice.account
ALICE_SESSION=alice.session
11
ALICE_GROUP_SESSION=alice.group_session
12
13
BOB_ACCOUNT=bob.account
BOB_SESSION=bob.session
14
BOB_GROUP_SESSION=bob.group_session
15
CHARLIE_GROUP_SESSION=charlie.group_session
16

17
18
19
rm -f $ALICE_ACCOUNT $BOB_ACCOUNT
rm -f $ALICE_SESSION $BOB_SESSION
rm -f $ALICE_GROUP_SESSION $BOB_GROUP_SESSION $CHARLIE_GROUP_SESSION
20
21
22
23
24

$OLM create_account $ALICE_ACCOUNT
$OLM create_account $BOB_ACCOUNT
$OLM generate_keys $BOB_ACCOUNT 1

25
26
BOB_IDENTITY_KEY="$($OLM identity_key $BOB_ACCOUNT)"
BOB_ONE_TIME_KEY="$($OLM one_time_key $BOB_ACCOUNT)"
27
28
29
30

$OLM outbound $ALICE_ACCOUNT $ALICE_SESSION "$BOB_IDENTITY_KEY" "$BOB_ONE_TIME_KEY"

echo "Hello world" | $OLM encrypt $ALICE_SESSION - - | $OLM inbound $BOB_ACCOUNT $BOB_SESSION - -
31
32
33
34
35


### group sessions

$OLM outbound_group $ALICE_GROUP_SESSION
36
$OLM group_credentials $ALICE_GROUP_SESSION | $OLM inbound_group $BOB_GROUP_SESSION
37
38
39
40
41
echo "Hello group" | $OLM group_encrypt $ALICE_GROUP_SESSION - group_message
$OLM group_decrypt $BOB_GROUP_SESSION group_message

$OLM export_inbound_group $BOB_GROUP_SESSION | $OLM import_inbound_group $CHARLIE_GROUP_SESSION
$OLM group_decrypt $CHARLIE_GROUP_SESSION group_message
42

43
44
45
46
### Sign/verify
ALICE_SIGNING_KEY="$($OLM signing_key $ALICE_ACCOUNT)"
sig="$(echo "Test message" | $OLM sign $ALICE_ACCOUNT - -)"
echo "Test message" | $OLM ed25519_verify $ALICE_SIGNING_KEY $sig -