diff options
author | Amber Brown <hawkowl@atleastfornow.net> | 2018-09-12 20:41:31 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-12 20:41:31 +1000 |
commit | 02aa41809bd48cc1dd02da3634f02f5eae71b41c (patch) | |
tree | 71cd7d6ae4983d2cff2f2f25fa82b088d746871b /synapse/rest/client/v1/admin.py | |
parent | Port crypto/ to Python 3 (#3822) (diff) | |
download | synapse-02aa41809bd48cc1dd02da3634f02f5eae71b41c.tar.xz |
Port rest/ to Python 3 (#3823)
Diffstat (limited to 'synapse/rest/client/v1/admin.py')
-rw-r--r-- | synapse/rest/client/v1/admin.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/synapse/rest/client/v1/admin.py b/synapse/rest/client/v1/admin.py index ad536ab570..41534b8c2a 100644 --- a/synapse/rest/client/v1/admin.py +++ b/synapse/rest/client/v1/admin.py @@ -101,7 +101,7 @@ class UserRegisterServlet(ClientV1RestServlet): nonce = self.hs.get_secrets().token_hex(64) self.nonces[nonce] = int(self.reactor.seconds()) - return (200, {"nonce": nonce.encode('ascii')}) + return (200, {"nonce": nonce}) @defer.inlineCallbacks def on_POST(self, request): @@ -164,7 +164,7 @@ class UserRegisterServlet(ClientV1RestServlet): key=self.hs.config.registration_shared_secret.encode(), digestmod=hashlib.sha1, ) - want_mac.update(nonce) + want_mac.update(nonce.encode('utf8')) want_mac.update(b"\x00") want_mac.update(username) want_mac.update(b"\x00") @@ -173,7 +173,10 @@ class UserRegisterServlet(ClientV1RestServlet): want_mac.update(b"admin" if admin else b"notadmin") want_mac = want_mac.hexdigest() - if not hmac.compare_digest(want_mac, got_mac.encode('ascii')): + if not hmac.compare_digest( + want_mac.encode('ascii'), + got_mac.encode('ascii') + ): raise SynapseError(403, "HMAC incorrect") # Reuse the parts of RegisterRestServlet to reduce code duplication |