Exemple #1
0
static int
doit (Shishi * handle, Shishi_ap * ap, int verbose)
{
  char line[BUFSIZ];
  int res;

  printf ("Application exchange start.  Press ^D to finish.\n");

  while (fgets (line, sizeof (line), stdin))
    {
      Shishi_safe *safe;

      line[strlen(line)-1] = '\0';
      printf ("read: %s\n", line);

      res = shishi_safe (handle, &safe);
      if (res != SHISHI_OK)
	{
	  printf ("Could not build SAFE: %s\n", shishi_strerror (res));
	  return res;
	}

      res = shishi_safe_set_user_data (handle, shishi_safe_safe (safe),
				       line, strlen (line));
      if (res != SHISHI_OK)
	{
	  printf ("Could not set application data in SAFE: %s\n",
		  shishi_strerror (res));
	  return res;
	}

      res = shishi_safe_build (safe, shishi_ap_key (ap));
      if (res != SHISHI_OK)
	{
	  printf ("Could not build SAFE: %s\n", shishi_strerror (res));
	  return res;
	}

      res = shishi_safe_print (handle, stdout, shishi_safe_safe (safe));
      if (res != SHISHI_OK)
	{
	  printf ("Could not print SAFE: %s\n", shishi_strerror (res));
	  return res;
	}
    }

  if (ferror (stdin))
    {
      printf ("error reading stdin\n");
      return 1;
    }

  return 0;
}
Exemple #2
0
int
_gsasl_kerberos_v5_client_encode (Gsasl_session * sctx,
				  void *mech_data,
				  const char *input,
				  size_t input_len,
				  char **output, size_t * output_len)
{
  struct _Gsasl_kerberos_v5_client_state *state = mech_data;
  int res;

  if (state && state->sessionkey && state->clientqop & GSASL_QOP_AUTH_CONF)
    {
      return GSASL_INTEGRITY_ERROR;
    }
  else if (state && state->sessionkey
	   && state->clientqop & GSASL_QOP_AUTH_INT)
    {
      res = shishi_safe (state->sh, &state->safe);
      if (res != SHISHI_OK)
	return GSASL_KERBEROS_V5_INTERNAL_ERROR;

      res = shishi_safe_set_user_data (state->sh,
				       shishi_safe_safe (state->safe),
				       input, input_len);
      if (res != SHISHI_OK)
	return GSASL_KERBEROS_V5_INTERNAL_ERROR;

      res = shishi_safe_build (state->safe, state->sessionkey);
      if (res != SHISHI_OK)
	return GSASL_KERBEROS_V5_INTERNAL_ERROR;

      res = shishi_safe_safe_der (state->safe, output, output_len);
      if (res != SHISHI_OK)
	return GSASL_KERBEROS_V5_INTERNAL_ERROR;
    }
  else
    {
      *output_len = input_len;
      *output = malloc (input_len);
      if (!*output)
	return GSASL_MALLOC_ERROR;
      memcpy (*output, input, input_len);
    }

  return GSASL_OK;
}