Esempio n. 1
0
<?php

/*
  The file is part of the HOBA server.
  
  HOBA server is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
  
  HOBA server is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with this program. If not, see <http://www.gnu.org/licenses/>.
  Copyright (C) 2016, Andrew McConachie, <*****@*****.**>
*/
include_once 'globals.php';
include_once 'crypto.php';
$chal = getChal(getPeer());
header('WWW-Authenticate: HOBA: challenge=' . $chal . ",expires=" . $GLOBALS['chalTimeout']);
Esempio n. 2
0
function sendChallenge()
{
    $chal = getChal(getPeer());
    header('WWW-Authenticate: HOBA: challenge=' . $chal . ",expires=" . $GLOBALS['chalTimeout']);
    header('HTTP/1.0 401 Unauthorized');
}
Esempio n. 3
0
function test()
{
    $peer = "10.0.0.1";
    $otherpeer = "10.0.0.2";
    $foo = getChal($peer);
    $bar = checkChal($foo, $peer);
    print $foo . " is a " . ($bar ? "good" : "bad") . " challenge from " . $peer . "\n";
    $bar = checkChal($foo, $otherpeer);
    print $foo . " is a " . ($bar ? "good" : "bad") . " challenge from " . $otherpeer . "\n";
    sleep(2);
    $bar = checkChal($foo, $peer);
    print $foo . " is (now) a " . ($bar ? "good" : "bad") . " challenge from " . $peer . "\n";
}