summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-11-03 17:51:42 +0000
committerErik Johnston <erik@matrix.org>2014-11-03 17:51:42 +0000
commit68698e0ac8c39083f6ab7d377a48b5bead3d3598 (patch)
treed2b722e1743d024cf8dcece32f0b8c07fb1bcf0e /scripts
parentMerge branch 'event_signing' of github.com:matrix-org/synapse into federation... (diff)
downloadsynapse-68698e0ac8c39083f6ab7d377a48b5bead3d3598.tar.xz
Fix bugs in generating event signatures and hashing
Diffstat (limited to 'scripts')
-rw-r--r--scripts/check_event_hash.py12
-rw-r--r--scripts/check_signature.py1
2 files changed, 8 insertions, 5 deletions
diff --git a/scripts/check_event_hash.py b/scripts/check_event_hash.py
index 9fa4452ee6..7c32f8102a 100644
--- a/scripts/check_event_hash.py
+++ b/scripts/check_event_hash.py
@@ -6,6 +6,7 @@ import hashlib
 import sys
 import json
 
+
 class dictobj(dict):
     def __init__(self, *args, **kargs):
         dict.__init__(self, *args, **kargs)
@@ -14,9 +15,12 @@ class dictobj(dict):
     def get_dict(self):
         return dict(self)
 
+    def get_full_dict(self):
+        return dict(self)
+
 
 def main():
-    parser = parser = argparse.ArgumentParser()
+    parser = argparse.ArgumentParser()
     parser.add_argument("input_json", nargs="?", type=argparse.FileType('r'),
                         default=sys.stdin)
     args = parser.parse_args()
@@ -29,14 +33,14 @@ def main():
     }
 
     for alg_name in event_json.hashes:
-        if check_event_pdu_content_hash(event_json, algorithms[alg_name]):
+        if check_event_content_hash(event_json, algorithms[alg_name]):
             print "PASS content hash %s" % (alg_name,)
         else:
             print "FAIL content hash %s" % (alg_name,)
 
     for algorithm in algorithms.values():
-        name, h_bytes = compute_pdu_event_reference_hash(event_json, algorithm)
-        print "Reference hash %s: %s" % (name, encode_base64(bytes))
+        name, h_bytes = compute_event_reference_hash(event_json, algorithm)
+        print "Reference hash %s: %s" % (name, encode_base64(h_bytes))
 
 if __name__=="__main__":
     main()
diff --git a/scripts/check_signature.py b/scripts/check_signature.py
index e7964e7e71..e146e18e24 100644
--- a/scripts/check_signature.py
+++ b/scripts/check_signature.py
@@ -1,5 +1,4 @@
 
-from synapse.crypto.event_signing import verify_signed_event_pdu
 from syutil.crypto.jsonsign import verify_signed_json
 from syutil.crypto.signing_key import (
     decode_verify_key_bytes, write_signing_keys