Пример #1
0
static SRP_RESULT
slu_sys_lookup(SRP_SERVER_LOOKUP * slu, SRP * srp, cstr * username)
{
  struct t_passwd * p;

  p = gettpnam(username->data);
  if(p == NULL)
    return SRP_ERROR;
  if(!SRP_OK(SRP_set_params(srp, p->tc.modulus.data, p->tc.modulus.len,
			    p->tc.generator.data, p->tc.generator.len,
			    p->tp.salt.data, p->tp.salt.len)))
    return SRP_ERROR;
  if(!SRP_OK(SRP_set_authenticator(srp,
				   p->tp.password.data, p->tp.password.len)))
    return SRP_ERROR;

  return SRP_SUCCESS;
}
Пример #2
0
cstr *ssrp_client_start(SRP *srpc, cstr *modulus, cstr *generator, cstr *salt, const char *user)
{
    SRP_RESULT rc;
    cstr * client_pub = NULL;

    rc = SRP_set_username(srpc, user);
    check(SRP_OK(rc), "Failed to set client username.");

    rc = SRP_set_params(srpc, modulus->data, modulus->length,
            generator->data, generator->length,
            salt->data, salt->length);
    check(SRP_OK(rc), "SRP_set_params failed\n");

    rc = SRP_gen_pub(srpc, &client_pub);
    check(SRP_OK(rc), "SRP_gen_pub failed\n");

    return client_pub;

error:
    return NULL;
}
Пример #3
0
cstr *ssrp_server_start(SRP *srps, cstr *modulus, cstr *generator,
        cstr *salt, cstr *auth, const char * user)
{
    SRP_RESULT rc;
    cstr *server_pub = NULL;

    rc = SRP_set_username(srps, user);
    check(SRP_OK(rc), "SRP_set_username failed\n");

    rc = SRP_set_params(srps, modulus->data, modulus->length,
            generator->data, generator->length, salt->data, salt->length);
    check(SRP_OK(rc), "SRP_set_params failed\n");

    rc = SRP_set_authenticator(srps, auth->data, auth->length);
    check(SRP_OK(rc), "SRP_set_authenticator failed\n");

    rc = SRP_gen_pub(srps, &server_pub);
    check(SRP_OK(rc), "SRP_gen_pub failed\n");

    return server_pub;

error:
    return NULL;
}