Example #1
0
function doGetCertStep4($data)
{
    //解密
    $decryptData = RSADecrypt($data, $GLOBALS['CAPrivKeyStr']);
    //分割
    $usercert = SQLAdopt::getOne(new certModel($decryptData, '', '', ''));
    if (!empty($usercert)) {
        $keyII = md5(uniqid(mt_rand(), true));
        $ivII = md5(uniqid(mt_rand(), true));
        $_SESSION['AESKEY'] = $keyII;
        $_SESSION['AESIV'] = $ivII;
        save_AESKeyIV($decryptData, $keyII, $ivII, 'in');
        save_AESKeyIV($decryptData, $keyII, $ivII, 'out');
        echo RSAEncrypt($keyII . ',' . $ivII, $usercert->x509);
    } else {
        echo 'noEncrypt';
    }
}
Example #2
0
function build_AESSwitchChannel($data, $selfPrivateKey)
{
    $decryptData = RSADecrypt($data, $selfPrivateKey);
    if (count(splitByComma($decryptData)) === 3) {
        //解开获取数据
        $requestGUID = splitByComma($decryptData)[0];
        $requestKey = splitByComma($decryptData)[1];
        $requestIV = splitByComma($decryptData)[2];
        //获取目标pem
        $targetPEM = request_AutoPemFromCA($requestGUID);
        //获取新生成的key
        $newAESKeyIV = request_switchAESKeyIV($requestGUID, $requestKey, $requestIV);
        //RSA加密返回
        return RSAEncrypt($newAESKeyIV['key'] . "," . $newAESKeyIV['iv'], $targetPEM);
    } else {
        return false;
    }
}