[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Another python3 authentication issue with mixed str types
commit 8bc11004558a1362f61f75d967a221183777672d
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Tue Mar 26 08:29:13 2013 -0700
Another python3 authentication issue with mixed str types
Fixing another failure in our python3 integ tests with cookie authentication.
The hmac function provides us with bytes but we need to be careful to use
unicode in the formatted string to avoid a b'' wrapper.
---
stem/connection.py | 2 +-
stem/util/connection.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/stem/connection.py b/stem/connection.py
index 1f5a53d..b35bdd7 100644
--- a/stem/connection.py
+++ b/stem/connection.py
@@ -742,7 +742,7 @@ def authenticate_safecookie(controller, cookie_path, suppress_ctl_errors = True)
CLIENT_HASH_CONSTANT,
cookie_data + client_nonce + authchallenge_response.server_nonce)
- auth_response = _msg(controller, "AUTHENTICATE %s" % (binascii.b2a_hex(stem.util.str_tools._to_bytes(client_hash))))
+ auth_response = _msg(controller, "AUTHENTICATE %s" % stem.util.str_tools._to_unicode(binascii.b2a_hex(client_hash)))
except stem.ControllerError, exc:
try:
controller.connect()
diff --git a/stem/util/connection.py b/stem/util/connection.py
index fd0ac6e..4549740 100644
--- a/stem/util/connection.py
+++ b/stem/util/connection.py
@@ -274,7 +274,7 @@ def _hmac_sha256(key, msg):
:param str key: starting key for the hash
:param str msg: message to be hashed
- :returns; A sha256 digest of msg, hashed using the given key.
+ :returns: sha256 digest of msg as bytes, hashed using the given key
"""
return hmac.new(key, msg, hashlib.sha256).digest()
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits