mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
Add new attribute KEY-ATTR.
This commit is contained in:
parent
a9c317a95c
commit
1eeefbf7f7
@ -1,3 +1,9 @@
|
|||||||
|
2009-03-10 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
* app-openpgp.c (send_key_attr): New.
|
||||||
|
(do_getattr): New attribute KEY_ATTR.
|
||||||
|
* command.c (send_status_direct): New.
|
||||||
|
|
||||||
2009-03-06 Werner Koch <wk@g10code.com>
|
2009-03-06 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
* app-nks.c (do_learn_status): Factor code out to..
|
* app-nks.c (do_learn_status): Factor code out to..
|
||||||
|
@ -151,7 +151,7 @@ struct app_local_s {
|
|||||||
key. Might be NULL if key is not
|
key. Might be NULL if key is not
|
||||||
available. */
|
available. */
|
||||||
size_t keylen; /* The length of the above S-expression. This
|
size_t keylen; /* The length of the above S-expression. This
|
||||||
is usullay only required for cross checks
|
is usually only required for cross checks
|
||||||
because the length of an S-expression is
|
because the length of an S-expression is
|
||||||
implicitly available. */
|
implicitly available. */
|
||||||
} pk[3];
|
} pk[3];
|
||||||
@ -746,6 +746,24 @@ send_key_data (ctrl_t ctrl, const char *name,
|
|||||||
xfree (buf);
|
xfree (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
send_key_attr (ctrl_t ctrl, app_t app, const char *keyword, int number)
|
||||||
|
{
|
||||||
|
char buffer[200];
|
||||||
|
|
||||||
|
assert (number >=0 && number < DIM(app->app_local->keyattr));
|
||||||
|
|
||||||
|
/* We only support RSA thus the algo identifier is fixed to 1. */
|
||||||
|
snprintf (buffer, sizeof buffer, "%d 1 %u %u %d",
|
||||||
|
number+1,
|
||||||
|
app->app_local->keyattr[number].n_bits,
|
||||||
|
app->app_local->keyattr[number].e_bits,
|
||||||
|
app->app_local->keyattr[number].format);
|
||||||
|
send_status_direct (ctrl, keyword, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Implement the GETATTR command. This is similar to the LEARN
|
/* Implement the GETATTR command. This is similar to the LEARN
|
||||||
command but returns just one value via the status interface. */
|
command but returns just one value via the status interface. */
|
||||||
static gpg_error_t
|
static gpg_error_t
|
||||||
@ -763,6 +781,7 @@ do_getattr (app_t app, ctrl_t ctrl, const char *name)
|
|||||||
{ "PUBKEY-URL", 0x5F50 },
|
{ "PUBKEY-URL", 0x5F50 },
|
||||||
{ "KEY-FPR", 0x00C5, 3 },
|
{ "KEY-FPR", 0x00C5, 3 },
|
||||||
{ "KEY-TIME", 0x00CD, 4 },
|
{ "KEY-TIME", 0x00CD, 4 },
|
||||||
|
{ "KEY-ATTR", 0x0000, -5 },
|
||||||
{ "CA-FPR", 0x00C6, 3 },
|
{ "CA-FPR", 0x00C6, 3 },
|
||||||
{ "CHV-STATUS", 0x00C4, 1 },
|
{ "CHV-STATUS", 0x00C4, 1 },
|
||||||
{ "SIG-COUNTER", 0x0093, 2 },
|
{ "SIG-COUNTER", 0x0093, 2 },
|
||||||
@ -811,14 +830,16 @@ do_getattr (app_t app, ctrl_t ctrl, const char *name)
|
|||||||
}
|
}
|
||||||
if (table[idx].special == -2)
|
if (table[idx].special == -2)
|
||||||
{
|
{
|
||||||
char tmp[50];
|
char tmp[100];
|
||||||
|
|
||||||
sprintf (tmp, "gc=%d ki=%d fc=%d pd=%d mcl3=%u",
|
snprintf (tmp, sizeof tmp,
|
||||||
|
"gc=%d ki=%d fc=%d pd=%d mcl3=%u aac=%d",
|
||||||
app->app_local->extcap.get_challenge,
|
app->app_local->extcap.get_challenge,
|
||||||
app->app_local->extcap.key_import,
|
app->app_local->extcap.key_import,
|
||||||
app->app_local->extcap.change_force_chv,
|
app->app_local->extcap.change_force_chv,
|
||||||
app->app_local->extcap.private_dos,
|
app->app_local->extcap.private_dos,
|
||||||
app->app_local->extcap.max_certlen_3);
|
app->app_local->extcap.max_certlen_3,
|
||||||
|
app->app_local->extcap.algo_attr_change);
|
||||||
send_status_info (ctrl, table[idx].name, tmp, strlen (tmp), NULL, 0);
|
send_status_info (ctrl, table[idx].name, tmp, strlen (tmp), NULL, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -845,6 +866,12 @@ do_getattr (app_t app, ctrl_t ctrl, const char *name)
|
|||||||
}
|
}
|
||||||
return gpg_error (GPG_ERR_INV_NAME);
|
return gpg_error (GPG_ERR_INV_NAME);
|
||||||
}
|
}
|
||||||
|
if (table[idx].special == -5)
|
||||||
|
{
|
||||||
|
for (i=0; i < 3; i++)
|
||||||
|
send_key_attr (ctrl, app, table[idx].name, i);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
relptr = get_one_do (app, table[idx].tag, &value, &valuelen, &rc);
|
relptr = get_one_do (app, table[idx].tag, &value, &valuelen, &rc);
|
||||||
if (relptr)
|
if (relptr)
|
||||||
|
@ -2018,6 +2018,18 @@ send_status_info (ctrl_t ctrl, const char *keyword, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Send a ready formatted status line via assuan. */
|
||||||
|
void
|
||||||
|
send_status_direct (ctrl_t ctrl, const char *keyword, const char *args)
|
||||||
|
{
|
||||||
|
assuan_context_t ctx = ctrl->server_local->assuan_ctx;
|
||||||
|
|
||||||
|
if (strchr (args, '\n'))
|
||||||
|
log_error ("error: LF detected in status line - not sending\n");
|
||||||
|
else
|
||||||
|
assuan_write_status (ctx, keyword, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Helper to send the clients a status change notification. */
|
/* Helper to send the clients a status change notification. */
|
||||||
static void
|
static void
|
||||||
|
@ -125,6 +125,7 @@ void initialize_module_command (void);
|
|||||||
int scd_command_handler (ctrl_t, int);
|
int scd_command_handler (ctrl_t, int);
|
||||||
void send_status_info (ctrl_t ctrl, const char *keyword, ...)
|
void send_status_info (ctrl_t ctrl, const char *keyword, ...)
|
||||||
GNUPG_GCC_A_SENTINEL(1);
|
GNUPG_GCC_A_SENTINEL(1);
|
||||||
|
void send_status_direct (ctrl_t ctrl, const char *keyword, const char *args);
|
||||||
void scd_update_reader_status_file (void);
|
void scd_update_reader_status_file (void);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user