コード例 #1
0
ファイル: Transaction.cpp プロジェクト: referjs/rippled
Transaction::Transaction (STTx::ref stx, Validate validate, std::string& reason)
    noexcept
    : mTransaction (stx)
{
    try
    {
        mFromPubKey.setAccountPublic (mTransaction->getSigningPubKey ());
        mTransactionID  = mTransaction->getTransactionID ();
        mAccountFrom    = mTransaction->getAccountID(sfAccount);
    }
    catch (std::exception& e)
    {
        reason = e.what();
        return;
    }
    catch (...)
    {
        reason = "Unexpected exception";
        return;
    }

    if (validate == Validate::NO ||
        (passesLocalChecks (*mTransaction, reason) && checkSign (reason)))
    {
        mStatus = NEW;
    }
}
コード例 #2
0
ファイル: identity.c プロジェクト: Parantido/opensips
/* verifier
return value: -438: You should send a 438-reply.
			-437: You should send a 437-reply.
			-436: You should send a 436-reply.
			-428: You should send a 428-reply.
			-3: Error verifying Date header field.
			-2: Authentication service is not authoritative.
			-1: An error occured.
			1: verification OK
*/
static int verifier_(struct sip_msg* msg, char* str1, char* str2)
{
	char identityHF[MAX_IDENTITY] = "\0";
	X509 * cert = NULL;
	int retval = -1;
	STACK_OF(X509) * certchain = NULL;

	/* parse all headers */
	if (parse_headers(msg, HDR_EOH_F, 0)!=0) {
		LM_ERR("failed to parse headers\n");
		return -1;
	}

	retval = getIdentityHF(identityHF, msg);
	switch(retval)
	{
		case 0:
			/* Identity header field does not exist */
			return -428;
		case -1:
			LM_ERR("getIdentityHF failed\n");
			return -1;
	}

	if(!getCert(&cert, &certchain, msg))
	{
		return -436;
	}

	if(!validateCert(cert, certchain))
	{
		X509_free(cert);
		sk_X509_pop_free(certchain, X509_free);
		return -437;
	}
	sk_X509_pop_free(certchain, X509_free);

	if(!checkAuthority(cert, msg))
	{
		X509_free(cert);
		return -2;
	}

	if(!checkSign(cert, identityHF, msg))
	{
		X509_free(cert);
		return -438;
	}

	if(!checkDate(cert, msg))
	{
		X509_free(cert);
		return -3;
	}

	X509_free(cert);
	return 1;
}
コード例 #3
0
ファイル: Transaction.cpp プロジェクト: 12w21/rippled
Transaction::Transaction (SerializedTransaction::ref sit, bool bValidate)
    : mInLedger (0), mStatus (INVALID), mResult (temUNCERTAIN), mTransaction (sit)
{
    try
    {
        mFromPubKey.setAccountPublic (mTransaction->getSigningPubKey ());
        mTransactionID  = mTransaction->getTransactionID ();
        mAccountFrom    = mTransaction->getSourceAccount ();
    }
    catch (...)
    {
        return;
    }

    if (!bValidate || checkSign ())
        mStatus = NEW;
}
コード例 #4
0
ファイル: RiddersRoot.C プロジェクト: RahulFoam/CFD-PC
scalar RiddersRoot::root
(
    const scalar x0,
    const scalar x1
) const
{
    scalar fl = f_(x0);
    scalar fh = f_(x1);

    // Check bracketing of the root
    if ((fl > 0 && fh < 0) || (fl < 0 && fh > 0))
    {
        scalar xl = x0;
        scalar xh = x1;

        // Bad guess for answer, to simplify logic below
        scalar ans = -1.11e-30;

        scalar xm, fm, s, xNew, fNew;

        for (label nIter = 0; nIter < maxIter; nIter++)
        {
            // Create a mean value and evaluate function
            xm = 0.5*(xl + xh);
            fm = f_(xm);

            // Solve quadratic equation if well-posed
            s = sqrt(sqr(fm) - fl*fh);

            if (s < SMALL)
            {
                return ans;
            }

            // Updating formula
            if (fl >= fh)
            {
                xNew = xm + (xm - xl)*fm/s;
            }
            else
            {
                xNew = xm - (xm - xl)*fm/s;
            }

            // Check answer
            if (mag(xNew - ans) <= eps_)
            {
                return ans;
            }

            ans = xNew;

            fNew = f_(ans);

            if (mag(fNew) < SMALL)
            {
                return ans;
            }

            if (checkSign(fm, fNew))
            {
                xl = xm;
                fl = fm;
                xh = ans;
                fh = fNew;
            }
            else if (checkSign(fl, fNew))
            {
                xh = ans;
                fh = fNew;
            }
            else if (checkSign(fh, fNew))
            {
                xl = ans;
                fl = fNew;
            }
            else
            {
                // Never get here
                FatalErrorIn
                ( "Foam::scalar Foam::RiddersRoot<Func>::root" )
		<< "Foam::scalar Foam::RiddersRoot<Func>::root\n"
                << "(\n"
                << "    const scalar x0,\n"
                << "    const scalar x1\n"
                << ") const"
                << "Error in search logic" << abort(FatalError);
            }

            if (mag(xh - xl) <= eps_)
            {
                return ans;
            }
        }

        FatalErrorIn
        ( "Foam::scalar Foam::RiddersRoot<Func>::root" )
        <<  "Foam::scalar Foam::RiddersRoot<Func>::root\n"
        <<  "(\n"
        <<  "    const scalar x0,\n"
        <<  "    const scalar x1\n"
        <<  ") const"
        << "Maximum number of iterations exceeded" << abort(FatalError);
    }
    else if (mag(fl) < SMALL)
    {
        return x0;
    }
    else if (mag(fh) < SMALL)
    {
        return x1;
    }
    else
    {
        FatalErrorIn
        ( "Foam::scalar Foam::RiddersRoot<Func>::root" )
        <<  "Foam::scalar Foam::RiddersRoot<Func>::root\n"
        <<  "(\n/home/arattner3/OpenFOAM/OpenFOAM-2.0.x/src/transportModels/twoPhaseInterfaceProperties/alphaContactAngle/RiddersRoot"
        <<  "    const scalar x0,\n"
        <<  "    const scalar x1\n"
        <<  ") const"
        << "Root is not bracketed.  f(x0) = " << fl << " f(x1) = " << fh
        << abort(FatalError);
    }

    // Dummy return to keep compiler happy
    return x0;
}