]> git.ipfire.org Git - pbs.git/commitdiff
builders: Drop unused password hashing functions
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 13 Oct 2022 08:40:32 +0000 (08:40 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 13 Oct 2022 08:40:32 +0000 (08:40 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/builders.py

index 415e053d5e564ba4220acc1aebbfed49087275b0..1718ebeae4c388bdef5bde9c4c669404d75138e8 100644 (file)
@@ -1,16 +1,11 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 import asyncio
 import botocore.exceptions
 import datetime
-import hashlib
 import logging
-import random
-import string
-import time
 
 from . import base
-from . import misc
 
 from .decorators import *
 
@@ -632,42 +627,3 @@ class Builder(base.DataObject):
                )
 
                return res.t
-
-
-def generate_password_hash(password, salt=None, algo="sha512"):
-       """
-               This function creates a salted digest of the given password.
-       """
-       # Generate the salt (length = 16) of none was given.
-       if salt is None:
-               salt = misc.generate_random_string(length=16)
-
-       # Compute the hash.
-       # <SALT> + <PASSWORD>
-       if not algo in hashlib.algorithms:
-               raise Exception("Unsupported password hash algorithm: %s" % algo)
-
-       # Calculate the digest.
-       h = hashlib.new(algo)
-       h.update(salt)
-       h.update(password)
-
-       # Output string is of kind "<algo>$<salt>$<hash>".
-       return "$".join((algo, salt, h.hexdigest()))
-
-def check_password_hash(password, password_hash):
-       """
-               Check a plain-text password with the given digest.
-       """
-       # Handle plaintext passwords (plain$<password>).
-       if password_hash.startswith("plain$"):
-               return password_hash[6:] == password
-
-       try:
-               algo, salt, digest = password_hash.split("$", 2)
-       except ValueError:
-               logging.warning("Unknown password hash: %s" % password_hash)
-               return False
-
-       # Re-generate the password hash and compare the result.
-       return password_hash == generate_password_hash(password, salt=salt, algo=algo)