mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
gpg: Add magic parameter "default" to --quick-add-adsk.
* g10/getkey.c (has_key_with_fingerprint): New.
* g10/keyedit.c (menu_addadsk): Replace code by new function.
(keyedit_quick_addadsk): Handle magic arg "default".
* g10/keygen.c (append_all_default_adsks): New.
--
GnuPG-bug-id: 6882
(cherry picked from commit 77afc9ee1c
)
This commit is contained in:
parent
222045d850
commit
ce75af47eb
6 changed files with 88 additions and 18 deletions
27
g10/getkey.c
27
g10/getkey.c
|
@ -4574,3 +4574,30 @@ have_secret_key_with_kid (ctrl_t ctrl, u32 *keyid)
|
|||
keydb_release (kdbhd);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* Return an error if KEYBLOCK has a primary or subkey with the given
|
||||
* fingerprint (FPR,FPRLEN). */
|
||||
gpg_error_t
|
||||
has_key_with_fingerprint (kbnode_t keyblock, const byte *fpr, size_t fprlen)
|
||||
{
|
||||
kbnode_t node;
|
||||
PKT_public_key *pk;
|
||||
byte pkfpr[MAX_FINGERPRINT_LEN];
|
||||
size_t pkfprlen;
|
||||
|
||||
for (node = keyblock; node; node = node->next)
|
||||
{
|
||||
if (node->pkt->pkttype == PKT_PUBLIC_KEY
|
||||
|| node->pkt->pkttype == PKT_PUBLIC_SUBKEY
|
||||
|| node->pkt->pkttype == PKT_SECRET_KEY
|
||||
|| node->pkt->pkttype == PKT_SECRET_SUBKEY)
|
||||
{
|
||||
pk = node->pkt->pkt.public_key;
|
||||
fingerprint_from_pk (pk, pkfpr, &pkfprlen);
|
||||
if (pkfprlen == fprlen && !memcmp (pkfpr, fpr, fprlen))
|
||||
return gpg_error (GPG_ERR_DUP_KEY);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue