mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-18 14:17:03 +01:00
gpg: Split write_pubkey_enc_from_list.
* g10/encrypt.c (write_pubkey_enc_from_list): Split the body of this function out into... (write_pubkey_enc): ... this new function. -- Signed-off-by: Neal H. Walfield <neal@g10code.com>
This commit is contained in:
parent
2fdb950471
commit
7eac4942b5
@ -1,6 +1,7 @@
|
|||||||
/* encrypt.c - Main encryption driver
|
/* encrypt.c - Main encryption driver
|
||||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||||
* 2006, 2009 Free Software Foundation, Inc.
|
* 2006, 2009 Free Software Foundation, Inc.
|
||||||
|
* Copyright (C) 2016 g10 Code GmbH
|
||||||
*
|
*
|
||||||
* This file is part of GnuPG.
|
* This file is part of GnuPG.
|
||||||
*
|
*
|
||||||
@ -854,34 +855,21 @@ encrypt_filter (void *opaque, int control,
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write pubkey-enc packets from the list of PKs to OUT.
|
* Write a pubkey-enc packet for the public key PK to OUT.
|
||||||
*/
|
*/
|
||||||
static int
|
int
|
||||||
write_pubkey_enc_from_list (PK_LIST pk_list, DEK *dek, iobuf_t out)
|
write_pubkey_enc (PKT_public_key *pk, int throw_keyid, DEK *dek, iobuf_t out)
|
||||||
{
|
{
|
||||||
PACKET pkt;
|
PACKET pkt;
|
||||||
PKT_public_key *pk;
|
|
||||||
PKT_pubkey_enc *enc;
|
PKT_pubkey_enc *enc;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
for ( ; pk_list; pk_list = pk_list->next )
|
|
||||||
{
|
|
||||||
gcry_mpi_t frame;
|
gcry_mpi_t frame;
|
||||||
|
|
||||||
pk = pk_list->pk;
|
|
||||||
|
|
||||||
print_pubkey_algo_note ( pk->pubkey_algo );
|
print_pubkey_algo_note ( pk->pubkey_algo );
|
||||||
enc = xmalloc_clear ( sizeof *enc );
|
enc = xmalloc_clear ( sizeof *enc );
|
||||||
enc->pubkey_algo = pk->pubkey_algo;
|
enc->pubkey_algo = pk->pubkey_algo;
|
||||||
keyid_from_pk( pk, enc->keyid );
|
keyid_from_pk( pk, enc->keyid );
|
||||||
enc->throw_keyid = (opt.throw_keyids || (pk_list->flags&1));
|
enc->throw_keyid = throw_keyid;
|
||||||
|
|
||||||
if (opt.throw_keyids && (PGP6 || PGP7 || PGP8))
|
|
||||||
{
|
|
||||||
log_info(_("you may not use %s while in %s mode\n"),
|
|
||||||
"--throw-keyids",compliance_option_string());
|
|
||||||
compliance_failure();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Okay, what's going on: We have the session key somewhere in
|
/* Okay, what's going on: We have the session key somewhere in
|
||||||
* the structure DEK and want to encode this session key in an
|
* the structure DEK and want to encode this session key in an
|
||||||
@ -922,13 +910,35 @@ write_pubkey_enc_from_list (PK_LIST pk_list, DEK *dek, iobuf_t out)
|
|||||||
gpg_strerror (rc));
|
gpg_strerror (rc));
|
||||||
}
|
}
|
||||||
free_pubkey_enc(enc);
|
free_pubkey_enc(enc);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Write pubkey-enc packets from the list of PKs to OUT.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
write_pubkey_enc_from_list (PK_LIST pk_list, DEK *dek, iobuf_t out)
|
||||||
|
{
|
||||||
|
if (opt.throw_keyids && (PGP6 || PGP7 || PGP8))
|
||||||
|
{
|
||||||
|
log_info(_("you may not use %s while in %s mode\n"),
|
||||||
|
"--throw-keyids",compliance_option_string());
|
||||||
|
compliance_failure();
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( ; pk_list; pk_list = pk_list->next )
|
||||||
|
{
|
||||||
|
PKT_public_key *pk = pk_list->pk;
|
||||||
|
int throw_keyid = (opt.throw_keyids || (pk_list->flags&1));
|
||||||
|
int rc = write_pubkey_enc (pk, throw_keyid, dek, out);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
encrypt_crypt_files (ctrl_t ctrl, int nfiles, char **files, strlist_t remusr)
|
encrypt_crypt_files (ctrl_t ctrl, int nfiles, char **files, strlist_t remusr)
|
||||||
{
|
{
|
||||||
|
@ -232,6 +232,8 @@ void encrypt_crypt_files (ctrl_t ctrl,
|
|||||||
int encrypt_filter (void *opaque, int control,
|
int encrypt_filter (void *opaque, int control,
|
||||||
iobuf_t a, byte *buf, size_t *ret_len);
|
iobuf_t a, byte *buf, size_t *ret_len);
|
||||||
|
|
||||||
|
int write_pubkey_enc (PKT_public_key *pk, int throw_keyid,
|
||||||
|
DEK *dek, iobuf_t out);
|
||||||
|
|
||||||
/*-- sign.c --*/
|
/*-- sign.c --*/
|
||||||
int complete_sig (PKT_signature *sig, PKT_public_key *pksk, gcry_md_hd_t md,
|
int complete_sig (PKT_signature *sig, PKT_public_key *pksk, gcry_md_hd_t md,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user