send_key_attr (ctrl_t ctrl, app_t app, const char *keyword, int number)
{
  char buffer[200];
  int n_bits;
  const char *curve_oid;

  assert (number >=0 && number < DIM(app->app_local->keyattr));

  if (app->app_local->keyattr[number].key_type == KEY_TYPE_RSA)
    snprintf (buffer, sizeof buffer, "%d 1 %u %u %d",
              number+1,
              app->app_local->keyattr[number].rsa.n_bits,
              app->app_local->keyattr[number].rsa.e_bits,
              app->app_local->keyattr[number].rsa.format);
  else if (app->app_local->keyattr[number].key_type == KEY_TYPE_ECC)
    {
      get_ecc_key_parameters (app->app_local->keyattr[number].ecc.curve,
                              &n_bits, &curve_oid);
      snprintf (buffer, sizeof buffer, "%d %d %u %s",
                number+1, number==1? 18: 19, n_bits, curve_oid);
    }
  else if (app->app_local->keyattr[number].key_type == KEY_TYPE_EDDSA)
    {
      get_ecc_key_parameters (app->app_local->keyattr[number].eddsa.curve,
                              &n_bits, &curve_oid);
      snprintf (buffer, sizeof buffer, "%d 22 %u %s",
                number+1, n_bits, curve_oid);
    }
  else
    snprintf (buffer, sizeof buffer, "0 0 UNKNOWN");

  send_status_direct (ctrl, keyword, buffer);
}
send_key_attr (ctrl_t ctrl, app_t app, const char *keyword, int number)
{
  char buffer[200];
  int n_bits;
  const char *curve_oid;

  assert (number >=0 && number < DIM(app->app_local->keyattr));

  if (app->app_local->keyattr[number].key_type == KEY_TYPE_RSA)
    snprintf (buffer, sizeof buffer, "%d 1 %u %u %d",
              number+1,
              app->app_local->keyattr[number].rsa.n_bits,
              app->app_local->keyattr[number].rsa.e_bits,
              app->app_local->keyattr[number].rsa.format);
  else if (app->app_local->keyattr[number].key_type == KEY_TYPE_ECC)
    {
      get_ecc_key_parameters (app->app_local->keyattr[number].ecc.curve,
                              &n_bits, &curve_oid);
      snprintf (buffer, sizeof buffer, "%d %d %u %s",
                number+1, number==1? 18: 19, n_bits, curve_oid);
    }
  else if (app->app_local->keyattr[number].key_type == KEY_TYPE_EDDSA)
    {
      get_ecc_key_parameters (app->app_local->keyattr[number].eddsa.curve,
                              &n_bits, &curve_oid);
      snprintf (buffer, sizeof buffer, "%d 22 %u %s",
                number+1, n_bits, curve_oid);
    }
  else
    snprintf (buffer, sizeof buffer, "0 0 UNKNOWN");

  send_status_direct (ctrl, keyword, buffer);
}