+ * The signature verfication functions are extended. Instead of
+ always returning GPGME_SIG_STATUS_GOOD, the functions return more
+ specific codes for expired signatures. 2 new functions may be used
+ to retrieve more specific information like the signature expiartion
+ time and a validut information of the key without looking up the key.
+
* The current passphrase callback and progress meter callback can be
retrieved with the new functions gpgme_get_passphrase_cb and
gpgme_get_progress_cb respectively.
GpgmeDataEncoding NEW
gpgme_data_set_encoding NEW
gpgme_data_get_encoding NEW
+GPGME_SIG_STAT_GOOD_EXP NEW
+GPGME_SIG_STAT_GOOD_EXPKEY NEW
+gpgme_op_verify CHANGED: Returns more status codes.
+GPGME_ATTR_SIG_STATUS NEW
+gpgme_get_sig_string_attr NEW
+gpgme_get_sig_ulong_attr NEW
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Noteworthy changes in version 0.3.5 (2002-04-01)
GPGME_SIG_STAT_NOKEY = 3,
GPGME_SIG_STAT_NOSIG = 4,
GPGME_SIG_STAT_ERROR = 5,
- GPGME_SIG_STAT_DIFF = 6
+ GPGME_SIG_STAT_DIFF = 6,
+ GPGME_SIG_STAT_GOOD_EXP = 7,
+ GPGME_SIG_STAT_GOOD_EXPKEY = 8
}
GpgmeSigStat;
}
GpgmeSigMode;
-/* The available key attributes. */
+/* The available key and signature attributes. */
typedef enum
{
GPGME_ATTR_KEYID = 1,
GPGME_ATTR_KEY_DISABLED = 25,
GPGME_ATTR_SERIAL = 26,
GPGME_ATTR_ISSUER = 27,
- GPGME_ATTR_CHAINID = 28
+ GPGME_ATTR_CHAINID = 28,
+ GPGME_ATTR_SIG_STATUS = 29
}
GpgmeAttr;
const char *gpgme_get_sig_status (GpgmeCtx ctx, int idx,
GpgmeSigStat *r_stat, time_t *r_created);
+/* Retrieve certain attributes of a signature. IDX is the index
+ number of the signature after a successful verify operation. WHAT
+ is an attribute where GPGME_ATTR_EXPIRE is probably the most useful
+ one. RESERVED must be passed as 0. */
+unsigned long gpgme_get_sig_ulong_attr (GpgmeCtx c, int idx,
+ GpgmeAttr what, int reserved);
+const char *gpgme_get_sig_string_attr (GpgmeCtx c, int idx,
+ GpgmeAttr what, int reserved);
+
+
/* Get the key used to create signature IDX in CTX and return it in
R_KEY. */
GpgmeError gpgme_get_sig_key (GpgmeCtx ctx, int idx, GpgmeKey *r_key);
{
struct verify_result_s *next;
GpgmeSigStat status;
+ GpgmeSigStat expstatus; /* only used by finish_sig */
GpgmeData notation; /* We store an XML fragment here. */
int collecting; /* Private to finish_sig(). */
int notation_in_data; /* Private to add_notation(). */
char fpr[41]; /* Fingerprint of a good signature or keyid of
a bad one. */
ulong timestamp; /* Signature creation time. */
+ ulong exptimestamp; /* signature exipration time or 0 */
+ GpgmeValidity validity;
};
static void
finish_sig (GpgmeCtx ctx, int stop)
{
+ if (ctx->result.verify->status == GPGME_SIG_STAT_GOOD)
+ ctx->result.verify->status = ctx->result.verify->expstatus;
+
if (stop)
return; /* nothing to do */
return;
test_and_allocate_result (ctx, verify);
- if (code == STATUS_GOODSIG || code == STATUS_BADSIG || code == STATUS_ERRSIG)
+ if (code == STATUS_GOODSIG
+ || code == STATUS_EXPSIG
+ || code == STATUS_EXPKEYSIG
+ || code == STATUS_BADSIG
+ || code == STATUS_ERRSIG)
{
finish_sig (ctx,0);
if (ctx->error)
break;
case STATUS_GOODSIG:
- /* We only look at VALIDSIG */
+ ctx->result.verify->expstatus = GPGME_SIG_STAT_GOOD;
+ break;
+
+ case STATUS_EXPSIG:
+ ctx->result.verify->expstatus = GPGME_SIG_STAT_GOOD_EXP;
+ break;
+
+ case STATUS_EXPKEYSIG:
+ ctx->result.verify->expstatus = GPGME_SIG_STAT_GOOD_EXPKEY;
break;
case STATUS_VALIDSIG:
while (args[i] && args[i] != ' ')
i++;
/* And get the timestamp. */
- ctx->result.verify->timestamp = strtoul (args+i, NULL, 10);
+ ctx->result.verify->timestamp = strtoul (args+i, &p, 10);
+ if (args[i])
+ ctx->result.verify->exptimestamp = strtoul (p, NULL, 10);
break;
case STATUS_BADSIG:
add_notation (ctx, code, args);
break;
+ case STATUS_TRUST_UNDEFINED:
+ ctx->result.verify->validity = GPGME_VALIDITY_UNKNOWN;
+ break;
+ case STATUS_TRUST_NEVER:
+ ctx->result.verify->validity = GPGME_VALIDITY_NEVER;
+ break;
+ case STATUS_TRUST_MARGINAL:
+ if (ctx->result.verify->status == GPGME_SIG_STAT_GOOD)
+ ctx->result.verify->validity = GPGME_VALIDITY_MARGINAL;
+ break;
+ case STATUS_TRUST_FULLY:
+ case STATUS_TRUST_ULTIMATE:
+ if (ctx->result.verify->status == GPGME_SIG_STAT_GOOD)
+ ctx->result.verify->validity = GPGME_VALIDITY_FULL;
+ break;
+
case STATUS_END_STREAM:
break;
* GPGME_SIG_STAT_ERROR: Due to some other error the check could not be done.
* GPGME_SIG_STAT_DIFF: There is more than 1 signature and they have not
* the same status.
+ * GPGME_SIG_STAT_GOOD_EXP: The signature is good but has expired.
+ * GPGME_SIG_STAT_GOOD_KEYEXP: The signature is good but the key has expired.
*
* Return value: 0 on success or an errorcode if something not related to
* the signature itself did go wrong.
return result->fpr;
}
+const char *
+gpgme_get_sig_string_attr (GpgmeCtx c, int idx, GpgmeAttr what, int reserved)
+{
+ VerifyResult result;
+
+ if (!c || c->pending || !c->result.verify)
+ return NULL; /* No results yet or verification error. */
+ if (reserved)
+ return NULL; /* We might want to use it to enumerate attributes of
+ one signature */
+ for (result = c->result.verify;
+ result && idx > 0; result = result->next, idx--)
+ ;
+ if (!result)
+ return NULL; /* No more signatures. */
+
+ switch (what)
+ {
+ case GPGME_ATTR_FPR:
+ return result->fpr;
+ default:
+ break;
+ }
+ return NULL;
+}
+
+unsigned long
+gpgme_get_sig_ulong_attr (GpgmeCtx c, int idx, GpgmeAttr what, int reserved)
+{
+ VerifyResult result;
+
+ if (!c || c->pending || !c->result.verify)
+ return 0; /* No results yet or verification error. */
+ if (reserved)
+ return 0;
+ for (result = c->result.verify;
+ result && idx > 0; result = result->next, idx--)
+ ;
+ if (!result)
+ return 0; /* No more signatures. */
+
+ switch (what)
+ {
+ case GPGME_ATTR_CREATED:
+ return result->timestamp;
+ case GPGME_ATTR_EXPIRE:
+ return result->exptimestamp;
+ case GPGME_ATTR_VALIDITY:
+ return (unsigned long)result->validity;
+ case GPGME_ATTR_SIG_STATUS:
+ return (unsigned long)result->status;
+ default:
+ break;
+ }
+ return 0;
+}
+
+
/**
* gpgme_get_sig_key:
}
return err;
}
+