Hanno Böck
move crypt password hash verification to its own function
Hanno Böck commited 523f8e8 at 2023-12-08 21:33:48
<?php
/*
This file belongs to the Webinterface of schokokeks.org Hosting
Written by schokokeks.org Hosting, namely
Bernd Wurst <bernd@schokokeks.org>
Hanno Böck <hanno@schokokeks.org>
This code is published under a 0BSD license.
Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
*/
require_once('inc/error.php');
require_once('inc/base.php');
require_once('vendor/autoload.php');
function gen_pw_hash($password)
{
$pwhash = crypt($password, '$6$' . random_string(6));
if (strlen($pwhash) < 13) {
/* returns a string shorter than 13 chars on failure */
system_failure("Failed to calculate password hash!");
}
return $pwhash;
}
function check_pw_hash($password, $pwhash)
{
$checkhash = crypt($password, $pwhash);
if (strlen($checkhash) < 13) {
/* returns a string shorter than 13 chars on failure */
system_failure("Invalid password hash!");
}
return hash_equals($checkhash, $pwhash);
}
function strong_password($password, $user = [])
{
$pwcheck = config('pwcheck');
$result = null;
if ($pwcheck) {
DEBUG($pwcheck);
$req = curl_init($pwcheck);
curl_setopt($req, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($req, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($req, CURLOPT_SSL_VERIFYSTATUS, 1);
curl_setopt($req, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($req, CURLOPT_TIMEOUT, 5);
curl_setopt($req, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($req, CURLOPT_POST, 1);
 
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX