mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
gpg: Move a keydb function to another file.
* g10/keydb.c (build_keyblock_image): Move to ... * g10/build-packet.c (build_keyblock_image): here. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
264c15c72f
commit
61f41cdce5
@ -79,6 +79,49 @@ ctb_pkttype (int ctb)
|
||||
}
|
||||
|
||||
|
||||
/* Build a keyblock image from KEYBLOCK. Returns 0 on success and
|
||||
* only then stores a new iobuf object at R_IOBUF; the returned iobuf
|
||||
* can be access with the iobuf_get_temp_buffer and
|
||||
* iobuf_get_temp_length macros. */
|
||||
gpg_error_t
|
||||
build_keyblock_image (kbnode_t keyblock, iobuf_t *r_iobuf)
|
||||
{
|
||||
gpg_error_t err;
|
||||
iobuf_t iobuf;
|
||||
kbnode_t kbctx, node;
|
||||
|
||||
*r_iobuf = NULL;
|
||||
|
||||
iobuf = iobuf_temp ();
|
||||
for (kbctx = NULL; (node = walk_kbnode (keyblock, &kbctx, 0));)
|
||||
{
|
||||
/* Make sure to use only packets valid on a keyblock. */
|
||||
switch (node->pkt->pkttype)
|
||||
{
|
||||
case PKT_PUBLIC_KEY:
|
||||
case PKT_PUBLIC_SUBKEY:
|
||||
case PKT_SIGNATURE:
|
||||
case PKT_USER_ID:
|
||||
case PKT_ATTRIBUTE:
|
||||
case PKT_RING_TRUST:
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
err = build_packet_and_meta (iobuf, node->pkt);
|
||||
if (err)
|
||||
{
|
||||
iobuf_close (iobuf);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
*r_iobuf = iobuf;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Build a packet and write it to the stream OUT.
|
||||
* Returns: 0 on success or on an error code. */
|
||||
int
|
||||
|
44
g10/keydb.c
44
g10/keydb.c
@ -1359,48 +1359,6 @@ internal_keydb_get_keyblock (KEYDB_HANDLE hd, KBNODE *ret_kb)
|
||||
}
|
||||
|
||||
|
||||
/* Build a keyblock image from KEYBLOCK. Returns 0 on success and
|
||||
* only then stores a new iobuf object at R_IOBUF. */
|
||||
static gpg_error_t
|
||||
build_keyblock_image (kbnode_t keyblock, iobuf_t *r_iobuf)
|
||||
{
|
||||
gpg_error_t err;
|
||||
iobuf_t iobuf;
|
||||
kbnode_t kbctx, node;
|
||||
|
||||
*r_iobuf = NULL;
|
||||
|
||||
iobuf = iobuf_temp ();
|
||||
for (kbctx = NULL; (node = walk_kbnode (keyblock, &kbctx, 0));)
|
||||
{
|
||||
/* Make sure to use only packets valid on a keyblock. */
|
||||
switch (node->pkt->pkttype)
|
||||
{
|
||||
case PKT_PUBLIC_KEY:
|
||||
case PKT_PUBLIC_SUBKEY:
|
||||
case PKT_SIGNATURE:
|
||||
case PKT_USER_ID:
|
||||
case PKT_ATTRIBUTE:
|
||||
case PKT_RING_TRUST:
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
err = build_packet_and_meta (iobuf, node->pkt);
|
||||
if (err)
|
||||
{
|
||||
iobuf_close (iobuf);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
keydb_stats.build_keyblocks++;
|
||||
*r_iobuf = iobuf;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Update the keyblock KB (i.e., extract the fingerprint and find the
|
||||
* corresponding keyblock in the keyring).
|
||||
* keydb_update_keyblock diverts to here in the non-keyboxd mode.
|
||||
@ -1473,6 +1431,7 @@ internal_keydb_update_keyblock (ctrl_t ctrl, KEYDB_HANDLE hd, kbnode_t kb)
|
||||
err = build_keyblock_image (kb, &iobuf);
|
||||
if (!err)
|
||||
{
|
||||
keydb_stats.build_keyblocks++;
|
||||
err = keybox_update_keyblock (hd->active[hd->found].u.kb,
|
||||
iobuf_get_temp_buffer (iobuf),
|
||||
iobuf_get_temp_length (iobuf));
|
||||
@ -1543,6 +1502,7 @@ internal_keydb_insert_keyblock (KEYDB_HANDLE hd, kbnode_t kb)
|
||||
err = build_keyblock_image (kb, &iobuf);
|
||||
if (!err)
|
||||
{
|
||||
keydb_stats.build_keyblocks++;
|
||||
err = keybox_insert_keyblock (hd->active[idx].u.kb,
|
||||
iobuf_get_temp_buffer (iobuf),
|
||||
iobuf_get_temp_length (iobuf));
|
||||
|
@ -862,6 +862,7 @@ PACKET *create_gpg_control ( ctrlpkttype_t type,
|
||||
size_t datalen );
|
||||
|
||||
/*-- build-packet.c --*/
|
||||
gpg_error_t build_keyblock_image (kbnode_t keyblock, iobuf_t *r_iobuf);
|
||||
int build_packet (iobuf_t out, PACKET *pkt);
|
||||
gpg_error_t build_packet_and_meta (iobuf_t out, PACKET *pkt);
|
||||
gpg_error_t gpg_mpi_write (iobuf_t out, gcry_mpi_t a, unsigned int *t_nwritten);
|
||||
|
Loading…
x
Reference in New Issue
Block a user