aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2013-08-21 01:15:56 +0200
committerMichał Górny <mgorny@gentoo.org>2013-08-21 01:15:56 +0200
commitf6e60c91e3f56d97165f13dcff26e2ef8f617cfd (patch)
tree67fb778edaab6d77cad197f09d2d97bc9536b752 /okupy/common
parentAdd unpadded base32 en-/decoder to crypto. (diff)
downloadidentity.gentoo.org-f6e60c91e3f56d97165f13dcff26e2ef8f617cfd.tar.gz
identity.gentoo.org-f6e60c91e3f56d97165f13dcff26e2ef8f617cfd.tar.bz2
identity.gentoo.org-f6e60c91e3f56d97165f13dcff26e2ef8f617cfd.zip
Encode encrypted session ID using base32.
This will be more friendly to SSH input.
Diffstat (limited to 'okupy/common')
-rw-r--r--okupy/common/crypto.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/okupy/common/crypto.py b/okupy/common/crypto.py
index db1627c..1fdcf7c 100644
--- a/okupy/common/crypto.py
+++ b/okupy/common/crypto.py
@@ -121,8 +121,8 @@ class SessionRefCipher(object):
data = (cipher.rng.read(self.random_prefix_bytes)
+ session_id.encode('utf8'))
- session['encrypted_id'] = base64.b64encode(
- cipher.encrypt(data))
+ session['encrypted_id'] = ub32encode(
+ cipher.encrypt(data)).lower()
session.save()
return session['encrypted_id']
@@ -133,7 +133,7 @@ class SessionRefCipher(object):
"""
try:
- session_id = cipher.decrypt(base64.b64decode(eid),
+ session_id = cipher.decrypt(ub32decode(eid),
self.session_id_length
+ self.random_prefix_bytes)
except (TypeError, ValueError):