Esempio n. 1
0
function UIdoLogin($data)
{
    $data1 = $data;
    try {
        if (@isset($_SESSION['AESKEY']) && @isset($_SESSION['AESIV'])) {
            $data1 = AESDecrypt($data, $_SESSION['AESKEY'], $_SESSION['AESIV']);
        }
    } catch (Exception $e) {
    }
    $dataArray = preg_split("/[\\s,]+/", $data1);
    $host = $dataArray[0];
    $passwd = $dataArray[1];
    if ($GLOBALS['loginPassWord'] === $passwd) {
        if (!isset($_SESSION['host'])) {
            $_SESSION['host'] = $host;
            $_SESSION['passwd'] = $passwd;
        }
        UIFinishLogin();
    } else {
        echo 'failed';
    }
}
Esempio n. 2
0
function getCertFromCA($CAinterface = null, $CAPem = null)
{
    if (empty(getConfig_TempAESiv())) {
        setConfig_TempAESiv(create_RandomString());
    }
    if (empty(getConfig_TempAESKey())) {
        setConfig_TempAESKey(create_RandomString());
    }
    if (empty($CAinterface)) {
        $CAinterface = getConfig_CAIntertfaceURL();
    }
    if (empty($CAinterface)) {
        return 'CAinterface is empty';
    }
    if (empty($CAPem)) {
        $CAPem = getConfig_PublicX509FromCA();
    }
    if (empty($CAPem)) {
        return 'PublicX509FromCA is empty';
    }
    $getstr = DataTransport::go($CAinterface, 'action=doGetCertStep2&data=' . RSAEncrypt(getConfig_TempAESKey() . ',' . getConfig_TempAESiv() . "," . getConfig_SelfIntertfaceURL(), $CAPem));
    //getstr原型$returnStr=$userGUID.",".$newCert['privateKey'].",".$newCert['publicX509'];
    $decryptGetStr = AESDecrypt($getstr, getConfig_TempAESKey(), getConfig_TempAESiv());
    $arr = splitByComma($decryptGetStr);
    if (count($arr) == 4) {
        setConfig_SelfGUID($arr[0]);
        setConfig_SelfPrivateKey($arr[1]);
        setConfig_SelfPublicX509($arr[2]);
        setConfig_CAGUID($arr[3]);
        save_AESKeyIV(getConfig_CAGUID(), getConfig_TempAESKey(), getConfig_TempAESiv(), 'in');
        save_AESKeyIV(getConfig_CAGUID(), getConfig_TempAESKey(), getConfig_TempAESiv(), 'out');
        return true;
    } else {
        return 'error';
    }
}