mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
gpg: Implement encryption to ADSKs.
* g10/getkey.c (get_pubkey_fromfile): Add optional arg r_keyblock. * g10/pkclist.c (find_and_check_key): Also encrypt to RENC subkeys. * g10/getkey.c (parse_key_usage): Make public. * g10/misc.c (openpgp_pk_algo_usage): Take PUBKEY_USAGE_RENC in account. * g10/packet.h (PKT_public_key): Change pubkey_usage from byte to u16. (PKT_user_id): Cosmetic fix: change help_key_usage from int to u16. * g10/sig-check.c (check_signature_metadata_validity): Handle time conflict for ADSKs. -- GnuPG-bug-id: 6395 This patch handles ADSK keys and encrypts to them. It does not yet allow the creation of them. We backport this from master early to get this part of the code out into the field.
This commit is contained in:
parent
fde59f9ae6
commit
e4f61df850
6 changed files with 54 additions and 24 deletions
21
g10/getkey.c
21
g10/getkey.c
|
@ -1794,7 +1794,8 @@ get_best_pubkey_byname (ctrl_t ctrl, enum get_pubkey_modes mode,
|
|||
*
|
||||
* This function returns 0 on success. Otherwise, an error code is
|
||||
* returned. In particular, GPG_ERR_NO_PUBKEY is returned if the key
|
||||
* is not found.
|
||||
* is not found. If R_KEYBLOCK is not NULL and a key was found the
|
||||
* keyblock is stored there; otherwiese NULL is stored there.
|
||||
*
|
||||
* The self-signed data has already been merged into the public key
|
||||
* using merge_selfsigs. The caller must release the content of PK by
|
||||
|
@ -1802,13 +1803,17 @@ get_best_pubkey_byname (ctrl_t ctrl, enum get_pubkey_modes mode,
|
|||
* free_public_key).
|
||||
*/
|
||||
gpg_error_t
|
||||
get_pubkey_fromfile (ctrl_t ctrl, PKT_public_key *pk, const char *fname)
|
||||
get_pubkey_fromfile (ctrl_t ctrl, PKT_public_key *pk, const char *fname,
|
||||
kbnode_t *r_keyblock)
|
||||
{
|
||||
gpg_error_t err;
|
||||
kbnode_t keyblock;
|
||||
kbnode_t found_key;
|
||||
unsigned int infoflags;
|
||||
|
||||
if (r_keyblock)
|
||||
*r_keyblock = NULL;
|
||||
|
||||
err = read_key_from_file_or_buffer (ctrl, fname, NULL, 0, &keyblock);
|
||||
if (!err)
|
||||
{
|
||||
|
@ -1823,7 +1828,10 @@ get_pubkey_fromfile (ctrl_t ctrl, PKT_public_key *pk, const char *fname)
|
|||
err = gpg_error (GPG_ERR_UNUSABLE_PUBKEY);
|
||||
}
|
||||
|
||||
release_kbnode (keyblock);
|
||||
if (!err && r_keyblock)
|
||||
*r_keyblock = keyblock;
|
||||
else
|
||||
release_kbnode (keyblock);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -1885,12 +1893,12 @@ get_pubkey_from_buffer (ctrl_t ctrl, PKT_public_key *pkbuf,
|
|||
* returned public key may be a subkey rather than the primary key.
|
||||
* Note: The self-signed data has already been merged into the public
|
||||
* key using merge_selfsigs. Free *PK by calling
|
||||
* release_public_key_parts (or, if PK was allocated using xfree, you
|
||||
* release_public_key_parts (or, if PK was allocated using xmalloc, you
|
||||
* can use free_public_key, which calls release_public_key_parts(PK)
|
||||
* and then xfree(PK)).
|
||||
*
|
||||
* If PK->REQ_USAGE is set, it is used to filter the search results.
|
||||
* (Thus, if PK is not NULL, PK->REQ_USAGE must be valid!!!) See the
|
||||
* Thus, if PK is not NULL, PK->REQ_USAGE must be valid! See the
|
||||
* documentation for finish_lookup to understand exactly how this is
|
||||
* used.
|
||||
*
|
||||
|
@ -2491,7 +2499,8 @@ merge_keys_and_selfsig (ctrl_t ctrl, kbnode_t keyblock)
|
|||
}
|
||||
|
||||
|
||||
static int
|
||||
/* This function parses the key flags and returns PUBKEY_USAGE_ flags. */
|
||||
unsigned int
|
||||
parse_key_usage (PKT_signature * sig)
|
||||
{
|
||||
int key_usage = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue