Commit f8c61b8f authored by Richard van der Hoff's avatar Richard van der Hoff
Browse files

Python: Make ed25519_verify take some arguments

It's not much use if everything is hardcoded.
parent 853ea8fb
...@@ -65,11 +65,25 @@ def build_arg_parser(): ...@@ -65,11 +65,25 @@ def build_arg_parser():
account.unpickle(args.key, read_base64_file(args.account_file)) account.unpickle(args.key, read_base64_file(args.account_file))
print(account.identity_keys()['curve25519']) print(account.identity_keys()['curve25519'])
id_key = commands.add_parser("identity_key", id_key = commands.add_parser(
help="Get the identity key for an account") "identity_key",
help="Get the public part of the identity key for an account",
id_key.add_argument("account_file", help="Local account file") id_key.add_argument("account_file", help="Local account file")
id_key.set_defaults(func=do_id_key) id_key.set_defaults(func=do_id_key)
def do_signing_key(args):
account = Account()
account.unpickle(args.key, read_base64_file(args.account_file))
signing_key = commands.add_parser(
help="Get the public part of the signing key for an account",
signing_key.add_argument("account_file", help="Local account file")
def do_one_time_key(args): def do_one_time_key(args):
account = Account() account = Account()
account.unpickle(args.key, read_base64_file(args.account_file)) account.unpickle(args.key, read_base64_file(args.account_file))
...@@ -346,6 +360,16 @@ def build_arg_parser(): ...@@ -346,6 +360,16 @@ def build_arg_parser():
ed25519_verify = commands.add_parser("ed25519_verify", ed25519_verify = commands.add_parser("ed25519_verify",
help="Verify an ed25519 signature") help="Verify an ed25519 signature")
help="Public signing key used to create the signature"
help="Signature to be verified")
help="Message file (default stdin)",
type=argparse.FileType('r'), nargs='?',
ed25519_verify.set_defaults(func=do_verify_ed25519_signature) ed25519_verify.set_defaults(func=do_verify_ed25519_signature)
return parser return parser
...@@ -434,12 +458,8 @@ def do_export_inbound_group(args): ...@@ -434,12 +458,8 @@ def do_export_inbound_group(args):
def do_verify_ed25519_signature(args): def do_verify_ed25519_signature(args):
account = Account() message =
account.create() ed25519_verify(args.signing_key, message, args.signature)
message = "A Message".encode("ASCII")
ed25519_key = account.identity_keys()["ed25519"].encode("utf-8")
signature = account.sign(message)
ed25519_verify(ed25519_key, message, signature)
if __name__ == '__main__': if __name__ == '__main__':
#! /bin/bash #! /bin/bash
set -e
cd `dirname $0` cd `dirname $0`
OLM="python -m olm" OLM="python -m olm"
...@@ -38,6 +40,7 @@ $OLM group_decrypt $BOB_GROUP_SESSION group_message ...@@ -38,6 +40,7 @@ $OLM group_decrypt $BOB_GROUP_SESSION group_message
$OLM export_inbound_group $BOB_GROUP_SESSION | $OLM import_inbound_group $CHARLIE_GROUP_SESSION $OLM export_inbound_group $BOB_GROUP_SESSION | $OLM import_inbound_group $CHARLIE_GROUP_SESSION
$OLM group_decrypt $CHARLIE_GROUP_SESSION group_message $OLM group_decrypt $CHARLIE_GROUP_SESSION group_message
### Utility ### Sign/verify
$OLM ed25519_verify sig="$(echo "Test message" | $OLM sign $ALICE_ACCOUNT - -)"
echo "Test message" | $OLM ed25519_verify $ALICE_SIGNING_KEY $sig -
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment