Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 918708
Collapse All | Expand All

(-)passlib-1.7.4/passlib/handlers/bcrypt.py.dist (-5 / +5 lines)
Lines 656-662 class _BcryptBackend(_BcryptCommon): Link Here
656
        assert isinstance(hash, bytes)
656
        assert isinstance(hash, bytes)
657
        if not hash.startswith(config) or len(hash) != len(config)+31:
657
        if not hash.startswith(config) or len(hash) != len(config)+31:
658
            raise uh.exc.CryptBackendError(self, config, hash, source="`bcrypt` package")
658
            raise uh.exc.CryptBackendError(self, config, hash, source="`bcrypt` package")
659
        return hash[-31:].decode("ascii")
659
        return hash[-31:]
660
660
661
#-----------------------------------------------------------------------
661
#-----------------------------------------------------------------------
662
# bcryptor backend
662
# bcryptor backend
Lines 759-768 class _PyBcryptBackend(_BcryptCommon): Link Here
759
        #        hash encoded as ascii bytes, returns ascii unicode.
759
        #        hash encoded as ascii bytes, returns ascii unicode.
760
        secret, ident = self._prepare_digest_args(secret)
760
        secret, ident = self._prepare_digest_args(secret)
761
        config = self._get_config(ident)
761
        config = self._get_config(ident)
762
        hash = _pybcrypt.hashpw(secret, config)
762
        hash = _pybcrypt.hashpw(secret, config.encode('ascii'))
763
        if not hash.startswith(config) or len(hash) != len(config) + 31:
763
        if not hash.startswith(config.encode('ascii')) or len(hash) != len(config) + 31:
764
            raise uh.exc.CryptBackendError(self, config, hash, source="pybcrypt library")
764
            raise uh.exc.CryptBackendError(self, config, hash, source="pybcrypt library")
765
        return str_to_uascii(hash[-31:])
765
        return hash[-31:]
766
766
767
    _calc_checksum = _calc_checksum_raw
767
    _calc_checksum = _calc_checksum_raw
768
768
Lines 862-868 class _BuiltinBackend(_BcryptCommon): Link Here
862
        secret, ident = self._prepare_digest_args(secret)
862
        secret, ident = self._prepare_digest_args(secret)
863
        chk = _builtin_bcrypt(secret, ident[1:-1],
863
        chk = _builtin_bcrypt(secret, ident[1:-1],
864
                              self.salt.encode("ascii"), self.rounds)
864
                              self.salt.encode("ascii"), self.rounds)
865
        return chk.decode("ascii")
865
        return chk
866
866
867
#=============================================================================
867
#=============================================================================
868
# handler
868
# handler
(-)passlib-1.7.4/passlib/utils/handlers.py.dist (-1 / +6 lines)
Lines 789-795 class GenericHandler(MinimalHandler): Link Here
789
        chk = self.checksum
789
        chk = self.checksum
790
        if chk is None:
790
        if chk is None:
791
            raise exc.MissingDigestError(cls)
791
            raise exc.MissingDigestError(cls)
792
        return consteq(self._calc_checksum(secret), chk)
792
        calced_chk = self._calc_checksum(secret)
793
        if not isinstance(calced_chk, (bytes, bytearray)):
794
            calced_chk = calced_chk.encode('ascii')
795
        if not isinstance(chk, (bytes, bytearray)):
796
            chk = chk.encode('ascii')
797
        return consteq(calced_chk, chk)
793
798
794
    #===================================================================
799
    #===================================================================
795
    # legacy crypt interface
800
    # legacy crypt interface

Return to bug 918708