core: Set notation flags for verify.
* src/gpgme.h.in (GPGME_STATUS_NOTATION_FLAGS): New. * src/status-table.c (status_table): Add new status. * src/verify.c (parse_notation): Handle flags. Also fix NOTATION_DATA in case gpg would not percent-escape spaces. (_gpgme_verify_status_handler): Handle flags. * tests/run-verify.c (print_result): Print notaion data. -- Note that this does only work with the soon to be released GnuPG 2.1.13.
This commit is contained in:
parent
8ad17f402f
commit
1cacd7d00a
3
NEWS
3
NEWS
@ -3,6 +3,8 @@ Noteworthy changes in version 1.7.0 (unreleased) [C25/A14/R_]
|
|||||||
|
|
||||||
* New function to format a GnuPG style public key algorithm string.
|
* New function to format a GnuPG style public key algorithm string.
|
||||||
|
|
||||||
|
* Notation flags are now correctly set on verify.
|
||||||
|
|
||||||
* Interface changes relative to the 1.6.0 release:
|
* Interface changes relative to the 1.6.0 release:
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
gpgme_pubkey_algo_string NEW.
|
gpgme_pubkey_algo_string NEW.
|
||||||
@ -15,6 +17,7 @@ Noteworthy changes in version 1.7.0 (unreleased) [C25/A14/R_]
|
|||||||
GPGME_STATUS_TOFU_USER NEW.
|
GPGME_STATUS_TOFU_USER NEW.
|
||||||
GPGME_STATUS_TOFU_STATS NEW.
|
GPGME_STATUS_TOFU_STATS NEW.
|
||||||
GPGME_STATUS_TOFU_STATS_LONG NEW.
|
GPGME_STATUS_TOFU_STATS_LONG NEW.
|
||||||
|
GPGME_STATUS_NOTATION_FLAGS NEW.
|
||||||
|
|
||||||
|
|
||||||
Noteworthy changes in version 1.6.0 (2015-08-26) [C25/A14/R0]
|
Noteworthy changes in version 1.6.0 (2015-08-26) [C25/A14/R0]
|
||||||
|
@ -549,7 +549,8 @@ typedef enum
|
|||||||
GPGME_STATUS_KEY_CONSIDERED = 94,
|
GPGME_STATUS_KEY_CONSIDERED = 94,
|
||||||
GPGME_STATUS_TOFU_USER = 95,
|
GPGME_STATUS_TOFU_USER = 95,
|
||||||
GPGME_STATUS_TOFU_STATS = 96,
|
GPGME_STATUS_TOFU_STATS = 96,
|
||||||
GPGME_STATUS_TOFU_STATS_LONG = 97
|
GPGME_STATUS_TOFU_STATS_LONG = 97,
|
||||||
|
GPGME_STATUS_NOTATION_FLAGS = 98
|
||||||
}
|
}
|
||||||
gpgme_status_code_t;
|
gpgme_status_code_t;
|
||||||
|
|
||||||
|
@ -102,6 +102,7 @@ static struct status_table_s status_table[] =
|
|||||||
{ "NO_SGNR", GPGME_STATUS_NO_SGNR },
|
{ "NO_SGNR", GPGME_STATUS_NO_SGNR },
|
||||||
{ "NODATA", GPGME_STATUS_NODATA },
|
{ "NODATA", GPGME_STATUS_NODATA },
|
||||||
{ "NOTATION_DATA", GPGME_STATUS_NOTATION_DATA },
|
{ "NOTATION_DATA", GPGME_STATUS_NOTATION_DATA },
|
||||||
|
{ "NOTATION_FLAGS", GPGME_STATUS_NOTATION_FLAGS },
|
||||||
{ "NOTATION_NAME", GPGME_STATUS_NOTATION_NAME },
|
{ "NOTATION_NAME", GPGME_STATUS_NOTATION_NAME },
|
||||||
{ "PINENTRY_LAUNCHED", GPGME_STATUS_PINENTRY_LAUNCHED},
|
{ "PINENTRY_LAUNCHED", GPGME_STATUS_PINENTRY_LAUNCHED},
|
||||||
{ "PKA_TRUST_BAD", GPGME_STATUS_PKA_TRUST_BAD },
|
{ "PKA_TRUST_BAD", GPGME_STATUS_PKA_TRUST_BAD },
|
||||||
|
46
src/verify.c
46
src/verify.c
@ -504,13 +504,14 @@ parse_notation (gpgme_signature_t sig, gpgme_status_code_t code, char *args)
|
|||||||
gpgme_error_t err;
|
gpgme_error_t err;
|
||||||
gpgme_sig_notation_t *lastp = &sig->notations;
|
gpgme_sig_notation_t *lastp = &sig->notations;
|
||||||
gpgme_sig_notation_t notation = sig->notations;
|
gpgme_sig_notation_t notation = sig->notations;
|
||||||
char *end = strchr (args, ' ');
|
char *p;
|
||||||
|
|
||||||
if (end)
|
|
||||||
*end = '\0';
|
|
||||||
|
|
||||||
if (code == GPGME_STATUS_NOTATION_NAME || code == GPGME_STATUS_POLICY_URL)
|
if (code == GPGME_STATUS_NOTATION_NAME || code == GPGME_STATUS_POLICY_URL)
|
||||||
{
|
{
|
||||||
|
p = strchr (args, ' ');
|
||||||
|
if (p)
|
||||||
|
*p = '\0';
|
||||||
|
|
||||||
/* FIXME: We could keep a pointer to the last notation in the list. */
|
/* FIXME: We could keep a pointer to the last notation in the list. */
|
||||||
while (notation && notation->value)
|
while (notation && notation->value)
|
||||||
{
|
{
|
||||||
@ -538,9 +539,8 @@ parse_notation (gpgme_signature_t sig, gpgme_status_code_t code, char *args)
|
|||||||
|
|
||||||
notation->name_len = strlen (notation->name);
|
notation->name_len = strlen (notation->name);
|
||||||
|
|
||||||
/* FIXME: For now we fake the human-readable flag. The
|
/* Set default flags for use with older gpg versions which
|
||||||
critical flag can not be reported as it is not
|
* do not emit a NOTATIONS_FLAG line. */
|
||||||
provided. */
|
|
||||||
notation->flags = GPGME_SIG_NOTATION_HUMAN_READABLE;
|
notation->flags = GPGME_SIG_NOTATION_HUMAN_READABLE;
|
||||||
notation->human_readable = 1;
|
notation->human_readable = 1;
|
||||||
}
|
}
|
||||||
@ -559,6 +559,37 @@ parse_notation (gpgme_signature_t sig, gpgme_status_code_t code, char *args)
|
|||||||
}
|
}
|
||||||
*lastp = notation;
|
*lastp = notation;
|
||||||
}
|
}
|
||||||
|
else if (code == GPGME_STATUS_NOTATION_FLAGS)
|
||||||
|
{
|
||||||
|
char *field[2];
|
||||||
|
|
||||||
|
while (notation && notation->next)
|
||||||
|
{
|
||||||
|
lastp = ¬ation->next;
|
||||||
|
notation = notation->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!notation || !notation->name)
|
||||||
|
{ /* There are notation flags without a previous notation name.
|
||||||
|
* The crypto backend misbehaves. */
|
||||||
|
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||||
|
}
|
||||||
|
if (_gpgme_split_fields (args, field, DIM (field)) < 2)
|
||||||
|
{ /* Required args missing. */
|
||||||
|
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||||
|
}
|
||||||
|
notation->flags = 0;
|
||||||
|
if (atoi (field[0]))
|
||||||
|
{
|
||||||
|
notation->flags |= GPGME_SIG_NOTATION_CRITICAL;
|
||||||
|
notation->critical = 1;
|
||||||
|
}
|
||||||
|
if (atoi (field[1]))
|
||||||
|
{
|
||||||
|
notation->flags |= GPGME_SIG_NOTATION_HUMAN_READABLE;
|
||||||
|
notation->human_readable = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (code == GPGME_STATUS_NOTATION_DATA)
|
else if (code == GPGME_STATUS_NOTATION_DATA)
|
||||||
{
|
{
|
||||||
int len = strlen (args) + 1;
|
int len = strlen (args) + 1;
|
||||||
@ -918,6 +949,7 @@ _gpgme_verify_status_handler (void *priv, gpgme_status_code_t code, char *args)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case GPGME_STATUS_NOTATION_NAME:
|
case GPGME_STATUS_NOTATION_NAME:
|
||||||
|
case GPGME_STATUS_NOTATION_FLAGS:
|
||||||
case GPGME_STATUS_NOTATION_DATA:
|
case GPGME_STATUS_NOTATION_DATA:
|
||||||
case GPGME_STATUS_POLICY_URL:
|
case GPGME_STATUS_POLICY_URL:
|
||||||
opd->only_newsig_seen = 0;
|
opd->only_newsig_seen = 0;
|
||||||
|
@ -110,6 +110,7 @@ static void
|
|||||||
print_result (gpgme_verify_result_t result)
|
print_result (gpgme_verify_result_t result)
|
||||||
{
|
{
|
||||||
gpgme_signature_t sig;
|
gpgme_signature_t sig;
|
||||||
|
gpgme_sig_notation_t nt;
|
||||||
gpgme_tofu_info_t ti;
|
gpgme_tofu_info_t ti;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
@ -138,8 +139,20 @@ print_result (gpgme_verify_result_t result)
|
|||||||
sig->wrong_key_usage? " wrong-key-usage":"",
|
sig->wrong_key_usage? " wrong-key-usage":"",
|
||||||
sig->chain_model? " chain-model":""
|
sig->chain_model? " chain-model":""
|
||||||
);
|
);
|
||||||
printf (" notations .: %s\n",
|
for (nt = sig->notations; nt; nt = nt->next)
|
||||||
sig->notations? "yes":"no");
|
{
|
||||||
|
printf (" notation ..: '%s'\n", nt->name);
|
||||||
|
if (strlen (nt->name) != nt->name_len)
|
||||||
|
printf (" warning : name larger (%d)\n", nt->name_len);
|
||||||
|
printf (" flags ...:%s%s (0x%02x)\n",
|
||||||
|
nt->critical? " critical":"",
|
||||||
|
nt->human_readable? " human":"",
|
||||||
|
nt->flags);
|
||||||
|
if (nt->value)
|
||||||
|
printf (" value ...: '%s'\n", nt->value);
|
||||||
|
if ((nt->value?strlen (nt->value):0) != nt->value_len)
|
||||||
|
printf (" warning : value larger (%d)\n", nt->value_len);
|
||||||
|
}
|
||||||
for (ti = sig->tofu; ti; ti = ti->next)
|
for (ti = sig->tofu; ti; ti = ti->next)
|
||||||
{
|
{
|
||||||
printf (" tofu addr .: %s\n", ti->address);
|
printf (" tofu addr .: %s\n", ti->address);
|
||||||
|
Loading…
Reference in New Issue
Block a user