void sfssrp_authorizer::authinit (const sfsagent_authinit_arg *argp, sfsagent_auth_res *resp, cbv cb) { resp->set_authenticate (false); if (!ntries_ok (argp->ntries)) { (*cb) (); return; } sfs_autharg2 aarg (SFS_SRPAUTH); if (!reqinit (&aarg.srpauth->req, argp)) { (*cb) (); return; } if (!srpc) { srpc = New srp_client; delete_srpc = true; } if (!srpc->init (&aarg.srpauth->msg, aarg.srpauth->req.authid, aarg.srpauth->req.user, NULL, // XXX -- eventually change next line to just 6 argp->server_release < 8 ? 3 : 6)) warn ("SRP client initialization failed\n"); else setres (resp, aarg); (*cb) (); }
void sfssrp_authorizer::authmore (const sfsagent_authmore_arg *argp, sfsagent_auth_res *resp, cbv cb) { resp->set_authenticate (false); sfs_autharg2 aarg (SFS_SRPAUTH); aarg.srpauth->req.type = SFS_SIGNED_AUTHREQ; aarg.srpauth->req.authid = srpc->sessid; aarg.srpauth->req.seqno = argp->seqno; aarg.srpauth->req.user = srpc->user; switch (srpc->next (&aarg.srpauth->msg, &argp->more)) { case SRP_SETPWD: if (!argp->checkserver) { getpwd (strbuf () << "Passphrase for " << srpc->getname () << ": ", false, wrap (this, &sfssrp_authorizer::authmore_2, argp, resp, cb)); return; } break; case SRP_NEXT: if (!argp->checkserver) setres (resp, aarg); break; case SRP_DONE: if (argp->checkserver) resp->set_authenticate (true); break; default: break; } (*cb) (); }
// Pown Range Test TEST(POWN, RangeTest) { typedef yalaa::details::double_iv_t iv_t; typedef yalaa::details::base_traits<iv_t> iv_traits; typedef double base_t; std::deque<iv_t> m_x; for(int exp = -10; exp <= 10; exp++) { m_x.clear(); if(exp < 0) m_x.push_back(iv_t(0.1, 10)); else m_x.push_back(iv_t(-10, 10)); while(!m_x.empty()) { iv_t x(m_x.front()); iv_t fiv(iv_traits::my_pow(x, exp)); AFF_TYPE aarg(x); AFF_TYPE faff(pown(aarg, exp)); iv_t faffiv (to_iv(faff)); iv_t isect(intersect(faffiv, fiv)); if(!exp) ASSERT_EQ(faffiv, iv_traits::my_one()) << "pown(x,0) does not yield iv_traits::my_one()" << "Input was " << x << "^" << exp << " fiv: " << fiv << " faff " << faff << std::endl; else if(exp == 1) ASSERT_EQ(faff, aarg) << "pown(x,1) does not preserve identity of x!" << "Input was " << x << "^" << exp << " fiv: " << fiv << " faff " << faff << std::endl; ASSERT_TRUE(iv_traits::my_inf(faffiv) <= iv_traits::my_sup(fiv) && iv_traits::my_sup(faffiv) >= iv_traits::my_inf(fiv)) << "Interval and affine evaluation do not intersect!" << std::endl << "Input was " << x << "^" << exp << " fiv: " << fiv << " faff " << faff << std::endl; // ASSERT_LE(iv_traits::my_inf(faffiv), iv_traits::my_inf(fiv)) // << "Affine evaluation was tigher than IV for a single elementary function." // << "Input was " << x << " fiv: " << fiv << " faff " << faff << std::endl; // ASSERT_GE(iv_traits::my_sup(faffiv), iv_traits::my_sup(fiv)) // << "Affine evaluation was tigher than IV for a single elementary function." // << "Input was " << x << " fiv: " << fiv << " faff " << faff << std::endl; if(iv_traits::my_sup(x) - iv_traits::my_inf(x) > 0.0001) { base_t mid = (iv_traits::my_inf(x) + iv_traits::my_sup(x))/2; m_x.push_back(iv_t(iv_traits::my_inf(x), mid)); m_x.push_back(iv_t(mid, iv_traits::my_sup(x))); } m_x.pop_front(); } } }