add SSHA password hasher

This commit is contained in:
Anthony Bourguignon
2023-02-22 12:30:45 +01:00
parent aa74e9a4a8
commit f44b5607b8
2 changed files with 20 additions and 1 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ from django.utils.encoding import smart_text
from modoboa.core.password_hashers.advanced import ( # NOQA:F401
BLFCRYPTHasher, MD5CRYPTHasher, SHA256CRYPTHasher, SHA512CRYPTHasher,
ARGON2IDHasher
ARGON2IDHasher, SSHAHasher
)
from modoboa.core.password_hashers.base import ( # NOQA:F401
CRYPTHasher, MD5Hasher, PLAINHasher, SHA256Hasher
+19
View File
@@ -113,6 +113,25 @@ class SHA512CRYPTHasher(PasswordHasher):
return sha512_crypt.verify(clearvalue, hashed_value)
class SSHAHasher(PasswordHasher):
"""
Salted SHA1 password hasher.
"""
_weak = True
@property
def scheme(self):
return "{SSHA}"
def _encrypt(self, clearvalue, salt=None):
# We have to remove the {SSHA} at the beginning of the string
return ldap_salted_sha1.hash(clearvalue)[6:]
def verify(self, clearvalue, hashed_value):
# We have to add the scheme for the hashed_value to be validated
return ldap_salted_sha1.verify(clearvalue, f'{{SSHA}}{hashed_value}')
if argon2_hasher is not None:
class ARGON2IDHasher(PasswordHasher):
"""