Merge branch 'master' into json-tool

This commit is contained in:
Werner Koch 2018-03-20 11:13:14 +01:00
commit 44f9e80ea9
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
9 changed files with 39 additions and 12 deletions

3
NEWS
View File

@ -3,9 +3,10 @@ Noteworthy changes in version 1.10.1 (unreleased)
* Interface changes relative to the 1.10.0 release:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gpgme_import_result_t EXTENDED: New field 'skipped_v3_keys'
cpp: Key::locate NEW.
cpp: Data::toString NEW.
cpp: ImportResult::numV3KeysSkipped NEW.
Noteworthy changes in version 1.10.0 (2017-12-12)
-------------------------------------------------

View File

@ -4811,6 +4811,12 @@ The number of keys not imported.
@item gpgme_import_status_t imports
A list of gpgme_import_status_t objects which contain more information
about the keys for which an import was attempted.
@item int skipped_v3_keys
For security reasons modern versions of GnuPG do not anymore support
v3 keys (created with PGP 2.x) and ignores them on import. This
counter provides the number of such skipped v3 keys.
@end table
@end deftp

View File

@ -154,6 +154,11 @@ int GpgME::ImportResult::notImported() const
return d ? d->res.not_imported : 0 ;
}
int GpgME::ImportResult::numV3KeysSkipped() const
{
return d ? d->res.skipped_v3_keys : 0 ;
}
GpgME::Import GpgME::ImportResult::import(unsigned int idx) const
{
return Import(d, idx);

View File

@ -78,6 +78,7 @@ public:
int numSecretKeysUnchanged() const;
int notImported() const;
int numV3KeysSkipped() const;
Import import(unsigned int idx) const;
std::vector<Import> imports() const;

View File

@ -1639,6 +1639,9 @@ struct _gpgme_op_import_result
/* List of keys for which an import was attempted. */
gpgme_import_status_t imports;
/* Number of v3 keys skipped. */
int skipped_v3_keys;
};
typedef struct _gpgme_op_import_result *gpgme_import_result_t;

View File

@ -94,8 +94,9 @@ gpgme_op_import_result (gpgme_ctx_t ctx)
TRACE_LOG3 ("%i secret keys, %i imported, %i unchanged",
opd->result.secret_read, opd->result.secret_imported,
opd->result.secret_unchanged);
TRACE_LOG2 ("%i skipped new keys, %i not imported",
opd->result.skipped_new_keys, opd->result.not_imported);
TRACE_LOG3 ("%i skipped new keys, %i not imported, %i v3 skipped",
opd->result.skipped_new_keys, opd->result.not_imported,
opd->result.skipped_v3_keys);
impstat = opd->result.imports;
i = 0;
@ -212,6 +213,10 @@ parse_import_res (char *args, gpgme_import_result_t result)
PARSE_NEXT (result->secret_unchanged);
PARSE_NEXT (result->skipped_new_keys);
PARSE_NEXT (result->not_imported);
if (args && *args)
{
PARSE_NEXT (result->skipped_v3_keys);
}
return 0;
}

View File

@ -1261,7 +1261,7 @@ gpgme_get_key (gpgme_ctx_t ctx, const char *fpr, gpgme_key_t *r_key,
{
gpgme_ctx_t listctx;
gpgme_error_t err;
gpgme_key_t key;
gpgme_key_t result, key;
TRACE_BEG2 (DEBUG_CTX, "gpgme_get_key", ctx,
"fpr=%s, secret=%i", fpr, secret);
@ -1295,7 +1295,7 @@ gpgme_get_key (gpgme_ctx_t ctx, const char *fpr, gpgme_key_t *r_key,
err = gpgme_op_keylist_start (listctx, fpr, secret);
if (!err)
err = gpgme_op_keylist_next (listctx, r_key);
err = gpgme_op_keylist_next (listctx, &result);
if (!err)
{
try_next_key:
@ -1305,9 +1305,9 @@ gpgme_get_key (gpgme_ctx_t ctx, const char *fpr, gpgme_key_t *r_key,
else
{
if (!err
&& *r_key && (*r_key)->subkeys && (*r_key)->subkeys->fpr
&& result && result->subkeys && result->subkeys->fpr
&& key && key->subkeys && key->subkeys->fpr
&& !strcmp ((*r_key)->subkeys->fpr, key->subkeys->fpr))
&& !strcmp (result->subkeys->fpr, key->subkeys->fpr))
{
/* The fingerprint is identical. We assume that this is
the same key and don't mark it as an ambiguous. This
@ -1323,12 +1323,14 @@ gpgme_get_key (gpgme_ctx_t ctx, const char *fpr, gpgme_key_t *r_key,
gpgme_key_unref (key);
err = gpg_error (GPG_ERR_AMBIGUOUS_NAME);
}
gpgme_key_unref (*r_key);
gpgme_key_unref (result);
result = NULL;
}
}
gpgme_release (listctx);
if (! err)
{
*r_key = result;
TRACE_LOG2 ("key=%p (%s)", *r_key,
((*r_key)->subkeys && (*r_key)->subkeys->fpr) ?
(*r_key)->subkeys->fpr : "invalid");

View File

@ -196,7 +196,8 @@ print_import_result (gpgme_import_result_t r)
" secret imported: %d\n"
" secret unchanged: %d\n"
" skipped new keys: %d\n"
" not imported: %d\n",
" not imported: %d\n"
" skipped v3 keys: %d\n",
r->considered,
r->no_user_id,
r->imported,
@ -210,6 +211,7 @@ print_import_result (gpgme_import_result_t r)
r->secret_imported,
r->secret_unchanged,
r->skipped_new_keys,
r->not_imported);
r->not_imported,
r->skipped_v3_keys);
}

View File

@ -177,7 +177,8 @@ print_import_result (gpgme_import_result_t r)
" secret imported: %d\n"
" secret unchanged: %d\n"
" skipped new keys: %d\n"
" not imported: %d\n",
" not imported: %d\n"
" skipped v3 keys: %d\n",
r->considered,
r->no_user_id,
r->imported,
@ -191,6 +192,7 @@ print_import_result (gpgme_import_result_t r)
r->secret_imported,
r->secret_unchanged,
r->skipped_new_keys,
r->not_imported);
r->not_imported,
r->skipped_v3_keys);
}