Exemplo n.º 1
0
static enum user_response
get_user_info_from_header(const realm_type type,
                          char **user_name,
                          struct user_info **user_item)
{
  int ret_val = no_user_response;
  if ((type == ws_realm)) {
    if (is_basic(user_name) == 0)
      ret_val = access_denied_user_response;
    if (is_digest(user_name) == 0)
      ret_val = ok_user_response;
  } else {
    if (is_basic(user_name) < 0 &&
	/* Load of *user_name here, but not after the is_digest call.  */
	is_digest(user_name) < 0)
      ;
    else if ((*user_item = find_user(*user_name)) != ((void *)0))
      ret_val = ok_user_response;
    else
      ret_val = access_denied_user_response;
    if (ret_val != ok_user_response)
      g_free(*user_name);
  }
  return ret_val;
}
Exemplo n.º 2
0
/*
 * Set/initialize default |type| and |flag| for new drbg instances.
 *
 * Returns 1 on success, 0 on failure.
 */
int RAND_DRBG_set_defaults(int type, unsigned int flags)
{
    int all;
    if (!(is_digest(type) || is_ctr(type))) {
        RANDerr(RAND_F_RAND_DRBG_SET_DEFAULTS, RAND_R_UNSUPPORTED_DRBG_TYPE);
        return 0;
    }

    if ((flags & ~rand_drbg_used_flags) != 0) {
        RANDerr(RAND_F_RAND_DRBG_SET_DEFAULTS, RAND_R_UNSUPPORTED_DRBG_FLAGS);
        return 0;
    }

    all = ((flags & RAND_DRBG_TYPE_FLAGS) == 0);
    if (all || (flags & RAND_DRBG_FLAG_MASTER) != 0) {
        rand_drbg_type[RAND_DRBG_TYPE_MASTER] = type;
        rand_drbg_flags[RAND_DRBG_TYPE_MASTER] = flags | RAND_DRBG_FLAG_MASTER;
    }
    if (all || (flags & RAND_DRBG_FLAG_PUBLIC) != 0) {
        rand_drbg_type[RAND_DRBG_TYPE_PUBLIC]  = type;
        rand_drbg_flags[RAND_DRBG_TYPE_PUBLIC] = flags | RAND_DRBG_FLAG_PUBLIC;
    }
    if (all || (flags & RAND_DRBG_FLAG_PRIVATE) != 0) {
        rand_drbg_type[RAND_DRBG_TYPE_PRIVATE] = type;
        rand_drbg_flags[RAND_DRBG_TYPE_PRIVATE] = flags | RAND_DRBG_FLAG_PRIVATE;
    }
    return 1;
}
Exemplo n.º 3
0
/*
 * Set/initialize |drbg| to be of type |type|, with optional |flags|.
 *
 * If |type| and |flags| are zero, use the defaults
 *
 * Returns 1 on success, 0 on failure.
 */
int RAND_DRBG_set(RAND_DRBG *drbg, int type, unsigned int flags)
{
    int ret = 1;

    if (type == 0 && flags == 0) {
        type = rand_drbg_type[RAND_DRBG_TYPE_MASTER];
        flags = rand_drbg_flags[RAND_DRBG_TYPE_MASTER];
    }

    /* If set is called multiple times - clear the old one */
    if (drbg->type != 0 && (type != drbg->type || flags != drbg->flags)) {
        drbg->meth->uninstantiate(drbg);
        rand_pool_free(drbg->adin_pool);
        drbg->adin_pool = NULL;
    }

    drbg->state = DRBG_UNINITIALISED;
    drbg->flags = flags;
    drbg->type = type;

    if (type == 0) {
        /* Uninitialized; that's okay. */
        drbg->meth = NULL;
        return 1;
    } else if (is_ctr(type)) {
        ret = drbg_ctr_init(drbg);
    } else if (is_digest(type)) {
        if (flags & RAND_DRBG_FLAG_HMAC)
            ret = drbg_hmac_init(drbg);
        else
            ret = drbg_hash_init(drbg);
    } else {
        drbg->type = 0;
        drbg->flags = 0;
        drbg->meth = NULL;
        RANDerr(RAND_F_RAND_DRBG_SET, RAND_R_UNSUPPORTED_DRBG_TYPE);
        return 0;
    }

    if (ret == 0) {
        drbg->state = DRBG_ERROR;
        RANDerr(RAND_F_RAND_DRBG_SET, RAND_R_ERROR_INITIALISING_DRBG);
    }
    return ret;
}
Exemplo n.º 4
0
authent_author(request *req)
{
  struct realm *realm;
  char *user_name = ((void *)0);
  struct user_info *user_item = ((void *)0);
  int res = 0;
  asm ("");
  realm = realms;
  if (__builtin_strcmp("Wsd", realm->name) == 0) {
    req->internal_realm = ws_realm;
    is_digest(&user_name);
  }
  if (authenticate_user(req, &user_name, &user_item) < 0) {
    if (user_name != ((void *)0))
      req->user = user_name;
    res = -2;
    goto authent_author_return;
  }
  if (is_member_of_groups(user_item, realm->groups) < 0)
    res = -1;
authent_author_return:
  return res;
}