Changeset - 82b1eaec25f5
[Not reviewed]
default
0 3 0
Mads Kiilerich - 6 years ago 2019-12-16 00:53:11
mads@kiilerich.com
Grafted from: 0925be0940da
py3: replace base64 encoding with base64 module
3 files changed with 7 insertions and 5 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/base.py
Show inline comments
 
@@ -28,6 +28,7 @@ Original author and date, and relevant c
 
:license: GPLv3, see LICENSE.md for more details.
 
"""
 

	
 
import base64
 
import datetime
 
import logging
 
import traceback
 
@@ -171,7 +172,7 @@ class BasicAuth(paste.auth.basic.AuthBas
 
        (authmeth, auth) = authorization.split(' ', 1)
 
        if 'basic' != authmeth.lower():
 
            return self.build_authentication(environ)
 
        auth = auth.strip().decode('base64')
 
        auth = base64.b64decode(auth.strip())
 
        _parts = auth.split(':', 1)
 
        if len(_parts) == 2:
 
            username, password = _parts
kallithea/lib/ssh.py
Show inline comments
 
@@ -21,7 +21,7 @@
 
# You should have received a copy of the GNU General Public License
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 

	
 
import binascii
 
import base64
 
import logging
 
import re
 

	
 
@@ -84,8 +84,8 @@ def parse_pub_key(ssh_key):
 
        raise SshKeyParseError(_("Incorrect SSH key - unexpected characters in base64 part %r") % keyvalue)
 

	
 
    try:
 
        decoded = keyvalue.decode('base64')
 
    except binascii.Error:
 
        decoded = base64.b64decode(keyvalue)
 
    except TypeError:
 
        raise SshKeyParseError(_("Incorrect SSH key - failed to decode base64 part %r") % keyvalue)
 

	
 
    if not decoded.startswith('\x00\x00\x00' + chr(len(keytype)) + str(keytype) + '\x00'):
kallithea/model/db.py
Show inline comments
 
@@ -25,6 +25,7 @@ Original author and date, and relevant c
 
:license: GPLv3, see LICENSE.md for more details.
 
"""
 

	
 
import base64
 
import collections
 
import datetime
 
import functools
 
@@ -2544,4 +2545,4 @@ class UserSshKeys(Base, BaseDbModel):
 
        # use fingerprints similar to 'ssh-keygen -E sha256 -lf ~/.ssh/id_rsa.pub'
 
        self._public_key = full_key
 
        enc_key = full_key.split(" ")[1]
 
        self.fingerprint = hashlib.sha256(enc_key.decode('base64')).digest().encode('base64').replace('\n', '').rstrip('=')
 
        self.fingerprint = base64.b64encode(hashlib.sha256(base64.b64decode(enc_key)).digest()).replace(b'\n', b'').rstrip(b'=').decode()
0 comments (0 inline, 0 general)