Added basic code for keylisting.

New Assuan command LISTKEYS.
This commit is contained in:
Werner Koch 2001-11-19 16:17:43 +00:00
parent ff1ba2fdc7
commit a413066de1
5 changed files with 22 additions and 7 deletions

View File

@ -34,6 +34,7 @@ gpgsm_SOURCES = \
certdump.c \
certcheck.c \
certpath.c \
keylist.c \
verify.c \
import.c

View File

@ -33,7 +33,7 @@
#include "gpgsm.h"
/* Return the fingerprint of the certificate (we can't put this into
libksba becuase we need libgcrypt support). The caller must
libksba because we need libgcrypt support). The caller must
provide an array of sufficient length or NULL so that the function
allocates the array. If r_len is not NULL, the length of the
digest is return, well, this can also be done by using

View File

@ -730,7 +730,7 @@ main ( int argc, char **argv)
break;
case oWithKeyData: opt.with_key_data=1; /* fall thru */
case oWithColons: opt.with_colons=':'; break;
case oWithColons: ctrl.with_colons = 1; break;
case oSkipVerify: opt.skip_verify=1; break;
@ -969,10 +969,9 @@ main ( int argc, char **argv)
break;
case aListKeys:
sl = NULL;
for ( ; argc; argc--, argv++ )
for (sl=NULL; argc; argc--, argv++)
add_to_strlist (&sl, *argv);
/* public_key_list( sl ); */
gpgsm_list_keys (&ctrl, sl, stdout);
free_strlist(sl);
break;

View File

@ -130,7 +130,6 @@ struct {
const char *homedir; /* configuration directory name */
char *outfile; /* name of output file */
int with_colons; /* use column delimited output format */
int with_key_data;/* include raw key in the column delimted output */
int fingerprint; /* list fingerprints in all key listings */
@ -176,6 +175,7 @@ struct server_control_s {
int no_server; /* we are not running under server control */
int status_fd; /* only for non-server mode */
struct server_local_s *server_local;
int with_colons; /* use column delimited output format */
};
typedef struct server_control_s *CTRL;
@ -204,7 +204,8 @@ int gpgsm_check_cms_signature (KsbaCert cert, const char *sigval,
/*-- certpath.c --*/
int gpgsm_validate_path (KsbaCert cert);
/*-- keylist.c --*/
void gpgsm_list_keys (CTRL ctrl, STRLIST names, FILE *fp);
/*-- import.c --*/

View File

@ -185,6 +185,19 @@ cmd_message (ASSUAN_CONTEXT ctx, char *line)
return 0;
}
static int
cmd_listkeys (ASSUAN_CONTEXT ctx, char *line)
{
CTRL ctrl = assuan_get_pointer (ctx);
ctrl->with_colons = 1;
/* fixme: check that the returned data_fp is not NULL */
gpgsm_list_keys (assuan_get_pointer (ctx), NULL, assuan_get_data_fp (ctx));
return 0;
}
@ -206,6 +219,7 @@ register_commands (ASSUAN_CONTEXT ctx)
{ "", ASSUAN_CMD_INPUT, NULL },
{ "", ASSUAN_CMD_OUTPUT, NULL },
{ "MESSAGE", 0, cmd_message },
{ "LISTKEYS", 0, cmd_listkeys },
{ NULL }
};
int i, j, rc;