tests/
* gpgsm/t-keylist.c (doit): Print operation info if available. gpgme/ * keylist.c (struct keylist_result_s): New. (_gpgme_release_keylist_result): Release it here (keylist_status_handler): Handle truncated. (append_xml_keylistinfo): New. * gpgme.c (_gpgme_release_result): and use it here. * types.h: Declare the new type here. * context.h (struct gpgme_context_s): Use it here.
This commit is contained in:
parent
e7dc765826
commit
61c97e9fa9
@ -2255,6 +2255,54 @@ is one of @code{GPGME_VALIDITY_UNKNOWN}, @code{GPGME_VALIDITY_NEVER},
|
|||||||
@item GPGME_ATTR_SIG_STATUS
|
@item GPGME_ATTR_SIG_STATUS
|
||||||
This is the same value as returned by @code{gpgme_get_sig_status}.
|
This is the same value as returned by @code{gpgme_get_sig_status}.
|
||||||
|
|
||||||
|
@item GPGME_ATTR_SIG_SUMMARY
|
||||||
|
This returns a bit vector giving a summary of the signature status.
|
||||||
|
Itprovides an easy interface to a defined semantic of the signature
|
||||||
|
status. Checking just one bit is sufficient to see whether a signature
|
||||||
|
is valid without any restrictions.
|
||||||
|
|
||||||
|
The defined bits are:
|
||||||
|
@table @code
|
||||||
|
@item GPGME_SIGSUM_VALID
|
||||||
|
The signature is fully valid.
|
||||||
|
|
||||||
|
@item GPGME_SIGSUM_GREEN
|
||||||
|
The signature is good but one might want to display some extra
|
||||||
|
information. Check the other bits.
|
||||||
|
|
||||||
|
@item GPGME_SIGSUM_RED
|
||||||
|
The signature is bad. It might be useful to checkother bits and
|
||||||
|
display moe information, i.e. a revoked certificate might not render a
|
||||||
|
signature invalid when the message was received prior to the cause for
|
||||||
|
the revocation.
|
||||||
|
|
||||||
|
@item GPGME_SIGSUM_KEY_REVOKED
|
||||||
|
The key or at least one certificate has been revoked.
|
||||||
|
|
||||||
|
@item GPGME_SIGSUM_KEY_EXPIRED
|
||||||
|
The key or one of the certificates has expired. It is probably a good
|
||||||
|
idea to display the date of the expiration.
|
||||||
|
|
||||||
|
@item GPGME_SIGSUM_SIG_EXPIRED
|
||||||
|
The signature has expired.
|
||||||
|
|
||||||
|
@item GPGME_SIGSUM_KEY_MISSING
|
||||||
|
Can't verifydue to a missing key o certificate.
|
||||||
|
|
||||||
|
@item GPGME_SIGSUM_CRL_MISSING
|
||||||
|
The CRL (or an equivalent mechanism) is not available.
|
||||||
|
|
||||||
|
@item GPGME_SIGSUM_CRL_TOO_OLD
|
||||||
|
Available CRL is too old.
|
||||||
|
|
||||||
|
@item GPGME_SIGSUM_BAD_POLICY
|
||||||
|
A policy requirement was not met.
|
||||||
|
|
||||||
|
@item GPGME_SIGSUM_SYS_ERROR
|
||||||
|
A system error occured.
|
||||||
|
|
||||||
|
@end table
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
@end deftypefun
|
@end deftypefun
|
||||||
|
|
||||||
|
@ -1,3 +1,13 @@
|
|||||||
|
2002-06-12 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* keylist.c (struct keylist_result_s): New.
|
||||||
|
(_gpgme_release_keylist_result): Release it here
|
||||||
|
(keylist_status_handler): Handle truncated.
|
||||||
|
(append_xml_keylistinfo): New.
|
||||||
|
* gpgme.c (_gpgme_release_result): and use it here.
|
||||||
|
* types.h: Declare the new type here.
|
||||||
|
* context.h (struct gpgme_context_s): Use it here.
|
||||||
|
|
||||||
2002-06-11 Marcus Brinkmann <marcus@g10code.de>
|
2002-06-11 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
* engine-gpgsm.c (_gpgme_gpgsm_release): Close status_cb.fd.
|
* engine-gpgsm.c (_gpgme_gpgsm_release): Close status_cb.fd.
|
||||||
|
@ -82,6 +82,7 @@ struct gpgme_context_s
|
|||||||
ImportResult import;
|
ImportResult import;
|
||||||
DeleteResult delete;
|
DeleteResult delete;
|
||||||
GenKeyResult genkey;
|
GenKeyResult genkey;
|
||||||
|
KeylistResult keylist;
|
||||||
} result;
|
} result;
|
||||||
|
|
||||||
/* Last signature notation. */
|
/* Last signature notation. */
|
||||||
|
@ -94,6 +94,7 @@ _gpgme_release_result (GpgmeCtx ctx)
|
|||||||
_gpgme_release_import_result (ctx->result.import);
|
_gpgme_release_import_result (ctx->result.import);
|
||||||
_gpgme_release_delete_result (ctx->result.delete);
|
_gpgme_release_delete_result (ctx->result.delete);
|
||||||
_gpgme_release_genkey_result (ctx->result.genkey);
|
_gpgme_release_genkey_result (ctx->result.genkey);
|
||||||
|
_gpgme_release_keylist_result (ctx->result.keylist);
|
||||||
memset (&ctx->result, 0, sizeof (ctx->result));
|
memset (&ctx->result, 0, sizeof (ctx->result));
|
||||||
_gpgme_set_op_info (ctx, NULL);
|
_gpgme_set_op_info (ctx, NULL);
|
||||||
ctx->error = 0;
|
ctx->error = 0;
|
||||||
|
@ -33,19 +33,83 @@
|
|||||||
|
|
||||||
#define my_isdigit(a) ( (a) >='0' && (a) <= '9' )
|
#define my_isdigit(a) ( (a) >='0' && (a) <= '9' )
|
||||||
|
|
||||||
|
struct keylist_result_s
|
||||||
|
{
|
||||||
|
int truncated;
|
||||||
|
GpgmeData xmlinfo;
|
||||||
|
};
|
||||||
|
|
||||||
static void finish_key ( GpgmeCtx ctx );
|
static void finish_key ( GpgmeCtx ctx );
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_release_keylist_result (KeylistResult result)
|
||||||
|
{
|
||||||
|
if (!result)
|
||||||
|
return;
|
||||||
|
xfree (result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Append some XML info. args is currently ignore but we might want
|
||||||
|
to add more information in the future (like source of the
|
||||||
|
keylisting. With args of NULL the XML structure is closed. */
|
||||||
|
static void
|
||||||
|
append_xml_keylistinfo (GpgmeData *rdh, char *args)
|
||||||
|
{
|
||||||
|
GpgmeData dh;
|
||||||
|
|
||||||
|
if (!*rdh)
|
||||||
|
{
|
||||||
|
if (gpgme_data_new (rdh))
|
||||||
|
return; /* FIXME: We are ignoring out-of-core. */
|
||||||
|
dh = *rdh;
|
||||||
|
_gpgme_data_append_string (dh, "<GnupgOperationInfo>\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dh = *rdh;
|
||||||
|
_gpgme_data_append_string (dh, " </keylisting>\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!args)
|
||||||
|
{
|
||||||
|
/* Just close the XML containter. */
|
||||||
|
_gpgme_data_append_string (dh, "</GnupgOperationInfo>\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_gpgme_data_append_string (dh,
|
||||||
|
" <keylisting>\n"
|
||||||
|
" <truncated/>\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
keylist_status_handler (GpgmeCtx ctx, GpgStatusCode code, char *args)
|
keylist_status_handler (GpgmeCtx ctx, GpgStatusCode code, char *args)
|
||||||
{
|
{
|
||||||
if (ctx->error)
|
if (ctx->error)
|
||||||
return;
|
return;
|
||||||
|
test_and_allocate_result (ctx, keylist);
|
||||||
|
|
||||||
switch (code)
|
switch (code)
|
||||||
{
|
{
|
||||||
|
case STATUS_TRUNCATED:
|
||||||
|
ctx->result.keylist->truncated = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case STATUS_EOF:
|
case STATUS_EOF:
|
||||||
finish_key (ctx);
|
finish_key (ctx);
|
||||||
|
if (ctx->result.keylist->truncated)
|
||||||
|
append_xml_keylistinfo (&ctx->result.keylist->xmlinfo, "1");
|
||||||
|
if (ctx->result.keylist->xmlinfo)
|
||||||
|
{
|
||||||
|
append_xml_keylistinfo (&ctx->result.keylist->xmlinfo, NULL);
|
||||||
|
_gpgme_set_op_info (ctx, ctx->result.keylist->xmlinfo);
|
||||||
|
ctx->result.keylist->xmlinfo = NULL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -129,6 +129,9 @@ void _gpgme_release_delete_result (DeleteResult res);
|
|||||||
/*-- genkey.c --*/
|
/*-- genkey.c --*/
|
||||||
void _gpgme_release_genkey_result (GenKeyResult res);
|
void _gpgme_release_genkey_result (GenKeyResult res);
|
||||||
|
|
||||||
|
/*-- keylist.c --*/
|
||||||
|
void _gpgme_release_keylist_result (KeylistResult res);
|
||||||
|
|
||||||
/*-- version.c --*/
|
/*-- version.c --*/
|
||||||
const char *_gpgme_compare_versions (const char *my_version,
|
const char *_gpgme_compare_versions (const char *my_version,
|
||||||
const char *req_version);
|
const char *req_version);
|
||||||
|
@ -88,5 +88,9 @@ typedef struct delete_result_s *DeleteResult;
|
|||||||
struct genkey_result_s;
|
struct genkey_result_s;
|
||||||
typedef struct genkey_result_s *GenKeyResult;
|
typedef struct genkey_result_s *GenKeyResult;
|
||||||
|
|
||||||
|
/*-- keylist.c --*/
|
||||||
|
struct keylist_result_s;
|
||||||
|
typedef struct keylist_result_s *KeylistResult;
|
||||||
|
|
||||||
|
|
||||||
#endif /* TYPES_H */
|
#endif /* TYPES_H */
|
||||||
|
@ -92,7 +92,7 @@ copy_token (const char *string, char *buffer, size_t length)
|
|||||||
for (i = 1; i < length && *s && *s != ' ' ; i++)
|
for (i = 1; i < length && *s && *s != ' ' ; i++)
|
||||||
*p++ = *s++;
|
*p++ = *s++;
|
||||||
*p = 0;
|
*p = 0;
|
||||||
/* conmtinue scanning in case the copy was truncated */
|
/* continue scanning in case the copy was truncated */
|
||||||
while (*s && *s != ' ')
|
while (*s && *s != ' ')
|
||||||
s++;
|
s++;
|
||||||
return s - string;
|
return s - string;
|
||||||
@ -537,12 +537,18 @@ calc_sig_summary (VerifyResult result)
|
|||||||
else if (result->status == GPGME_SIG_STAT_ERROR)
|
else if (result->status == GPGME_SIG_STAT_ERROR)
|
||||||
sum |= GPGME_SIGSUM_SYS_ERROR;
|
sum |= GPGME_SIGSUM_SYS_ERROR;
|
||||||
|
|
||||||
/* FIXME: Set GPGME_SIGSUM_KEY_REVOKED. */
|
if ( !strcmp (result->trust_errtok, "Certificate_Revoked"))
|
||||||
/* FIXME: Set GPGME_SIGSUM_CRL_MISSING. */
|
sum |= GPGME_SIGSUM_KEY_REVOKED;
|
||||||
/* FIXME: Set GPGME_SIGSUM_CRL_TOO_OLD. */
|
else if ( !strcmp (result->trust_errtok, "No_CRL_Known"))
|
||||||
/* FIXME: Set GPGME_SIGSUM_BAD_POLICY. */
|
sum |= GPGME_SIGSUM_CRL_MISSING;
|
||||||
|
else if ( !strcmp (result->trust_errtok, "CRL_Too_Old"))
|
||||||
|
sum |= GPGME_SIGSUM_CRL_TOO_OLD;
|
||||||
|
else if ( !strcmp (result->trust_errtok, "No_Policy_Match"))
|
||||||
|
sum |= GPGME_SIGSUM_BAD_POLICY;
|
||||||
|
else if (*result->trust_errtok)
|
||||||
|
sum |= GPGME_SIGSUM_SYS_ERROR;
|
||||||
|
|
||||||
/* That the valid flag when the signature is unquestionable
|
/* Set the valid flag when the signature is unquestionable
|
||||||
valid. */
|
valid. */
|
||||||
if ((sum & GPGME_SIGSUM_GREEN) && !(sum & ~GPGME_SIGSUM_GREEN))
|
if ((sum & GPGME_SIGSUM_GREEN) && !(sum & ~GPGME_SIGSUM_GREEN))
|
||||||
sum |= GPGME_SIGSUM_VALID;
|
sum |= GPGME_SIGSUM_VALID;
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2002-06-12 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* gpgsm/t-keylist.c (doit): Print operation info if available.
|
||||||
|
|
||||||
2002-06-10 Werner Koch <wk@gnupg.org>
|
2002-06-10 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
* gpgsm/t-verify.c (print_sig_stat): Print the error token.
|
* gpgsm/t-verify.c (print_sig_stat): Print the error token.
|
||||||
|
@ -91,6 +91,19 @@ doit ( GpgmeCtx ctx, const char *pattern )
|
|||||||
}
|
}
|
||||||
if ( err != GPGME_EOF )
|
if ( err != GPGME_EOF )
|
||||||
fail_if_err (err);
|
fail_if_err (err);
|
||||||
|
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
p = gpgme_get_op_info (ctx, 0);
|
||||||
|
if (p)
|
||||||
|
{
|
||||||
|
fputs ("<!-- begin operation info -->\n", stdout);
|
||||||
|
fputs (p, stdout);
|
||||||
|
fputs ("<!-- end operation info -->\n", stdout);
|
||||||
|
free (p);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -113,7 +113,10 @@ print_sig_stat ( GpgmeCtx ctx, GpgmeSigStat status )
|
|||||||
|
|
||||||
printf ("Verification Status: %s\n", status_string (status));
|
printf ("Verification Status: %s\n", status_string (status));
|
||||||
|
|
||||||
for(idx=0; (s=gpgme_get_sig_status (ctx, idx, &status, &created)); idx++ ) {
|
for (idx=0; (s=gpgme_get_sig_status (ctx, idx, &status, &created)); idx++ )
|
||||||
|
{
|
||||||
|
unsigned long sum;
|
||||||
|
|
||||||
printf ("sig %d: created: %lu expires: %lu status: %s\n",
|
printf ("sig %d: created: %lu expires: %lu status: %s\n",
|
||||||
idx, (unsigned long)created,
|
idx, (unsigned long)created,
|
||||||
gpgme_get_sig_ulong_attr (ctx, idx, GPGME_ATTR_EXPIRE, 0),
|
gpgme_get_sig_ulong_attr (ctx, idx, GPGME_ATTR_EXPIRE, 0),
|
||||||
@ -123,7 +126,35 @@ print_sig_stat ( GpgmeCtx ctx, GpgmeSigStat status )
|
|||||||
gpgme_get_sig_string_attr (ctx, idx, GPGME_ATTR_ERRTOK, 0),
|
gpgme_get_sig_string_attr (ctx, idx, GPGME_ATTR_ERRTOK, 0),
|
||||||
validity_string (gpgme_get_sig_ulong_attr
|
validity_string (gpgme_get_sig_ulong_attr
|
||||||
(ctx, idx, GPGME_ATTR_VALIDITY, 0)) );
|
(ctx, idx, GPGME_ATTR_VALIDITY, 0)) );
|
||||||
if ( !gpgme_get_sig_key (ctx, idx, &key) ) {
|
|
||||||
|
sum = gpgme_get_sig_ulong_attr (ctx, idx, GPGME_ATTR_SIG_SUMMARY, 0);
|
||||||
|
fputs ("summary:", stdout);
|
||||||
|
if ((sum & GPGME_SIGSUM_VALID))
|
||||||
|
fputs (" valid", stdout);
|
||||||
|
if ((sum & GPGME_SIGSUM_GREEN))
|
||||||
|
fputs (" green", stdout);
|
||||||
|
if ((sum & GPGME_SIGSUM_RED))
|
||||||
|
fputs (" red", stdout);
|
||||||
|
if ((sum & GPGME_SIGSUM_KEY_REVOKED))
|
||||||
|
fputs (" keyRevoked", stdout);
|
||||||
|
if ((sum & GPGME_SIGSUM_KEY_EXPIRED))
|
||||||
|
fputs (" keyExpired", stdout);
|
||||||
|
if ((sum & GPGME_SIGSUM_SIG_EXPIRED))
|
||||||
|
fputs (" sigExpired", stdout);
|
||||||
|
if ((sum & GPGME_SIGSUM_KEY_MISSING))
|
||||||
|
fputs (" keyMissing", stdout);
|
||||||
|
if ((sum & GPGME_SIGSUM_CRL_MISSING))
|
||||||
|
fputs (" crlMissing", stdout);
|
||||||
|
if ((sum & GPGME_SIGSUM_CRL_TOO_OLD))
|
||||||
|
fputs (" crlTooOld", stdout);
|
||||||
|
if ((sum & GPGME_SIGSUM_BAD_POLICY))
|
||||||
|
fputs (" badPolicy", stdout);
|
||||||
|
if ((sum & GPGME_SIGSUM_SYS_ERROR))
|
||||||
|
fputs (" sysError", stdout);
|
||||||
|
putchar ('\n');
|
||||||
|
|
||||||
|
if ( !gpgme_get_sig_key (ctx, idx, &key) )
|
||||||
|
{
|
||||||
char *p = gpgme_key_get_as_xml ( key );
|
char *p = gpgme_key_get_as_xml ( key );
|
||||||
printf ("sig %d: key object:\n%s\n", idx, p );
|
printf ("sig %d: key object:\n%s\n", idx, p );
|
||||||
free (p);
|
free (p);
|
||||||
|
Loading…
Reference in New Issue
Block a user