1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-02-02 16:43:03 +01:00

indent: Re-indent parts of build-packet.c

--
This commit is contained in:
Werner Koch 2017-03-29 08:43:04 +02:00
parent b20780658e
commit 5b3523d3e0
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -85,12 +85,13 @@ ctb_pkttype (int ctb)
int int
build_packet( IOBUF out, PACKET *pkt ) build_packet( IOBUF out, PACKET *pkt )
{ {
int new_ctb=0, rc=0, ctb; int rc = 0;
int pkttype; int new_ctb = 0;
int ctb, pkttype;
if( DBG_PACKET ) if (DBG_PACKET)
log_debug("build_packet() type=%d\n", pkt->pkttype ); log_debug ("build_packet() type=%d\n", pkt->pkttype);
log_assert( pkt->pkt.generic ); log_assert (pkt->pkt.generic);
switch ((pkttype = pkt->pkttype)) switch ((pkttype = pkt->pkttype))
{ {
@ -102,36 +103,41 @@ build_packet( IOBUF out, PACKET *pkt )
if (pkt->pkt.public_key->seckey_info) if (pkt->pkt.public_key->seckey_info)
pkttype = PKT_SECRET_SUBKEY; pkttype = PKT_SECRET_SUBKEY;
break; break;
case PKT_PLAINTEXT: new_ctb = pkt->pkt.plaintext->new_ctb; break; case PKT_PLAINTEXT:
new_ctb = pkt->pkt.plaintext->new_ctb;
break;
case PKT_ENCRYPTED: case PKT_ENCRYPTED:
case PKT_ENCRYPTED_MDC: new_ctb = pkt->pkt.encrypted->new_ctb; break; case PKT_ENCRYPTED_MDC:
case PKT_COMPRESSED:new_ctb = pkt->pkt.compressed->new_ctb; break; new_ctb = pkt->pkt.encrypted->new_ctb;
break;
case PKT_COMPRESSED:
new_ctb = pkt->pkt.compressed->new_ctb;
break;
case PKT_USER_ID: case PKT_USER_ID:
if( pkt->pkt.user_id->attrib_data ) if (pkt->pkt.user_id->attrib_data)
pkttype = PKT_ATTRIBUTE; pkttype = PKT_ATTRIBUTE;
break; break;
default: break; default:
break;
} }
if( new_ctb || pkttype > 15 ) /* new format */ if (new_ctb || pkttype > 15) /* new format */
ctb = 0xc0 | (pkttype & 0x3f); ctb = (0xc0 | (pkttype & 0x3f));
else else
ctb = 0x80 | ((pkttype & 15)<<2); ctb = (0x80 | ((pkttype & 15)<<2));
switch( pkttype ) switch (pkttype)
{ {
case PKT_ATTRIBUTE: case PKT_ATTRIBUTE:
case PKT_USER_ID: case PKT_USER_ID:
rc = do_user_id( out, ctb, pkt->pkt.user_id ); rc = do_user_id (out, ctb, pkt->pkt.user_id);
break; break;
case PKT_OLD_COMMENT: case PKT_OLD_COMMENT:
case PKT_COMMENT: case PKT_COMMENT:
/* /* Ignore these. Theoretically, this will never be called as we
Ignore these. Theoretically, this will never be called as * have no way to output comment packets any longer, but just in
we have no way to output comment packets any longer, but * case there is some code path that would end up outputting a
just in case there is some code path that would end up * comment that was written before comments were dropped (in the
outputting a comment that was written before comments were * public key?) this is a no-op. */
dropped (in the public key?) this is a no-op.
*/
break; break;
case PKT_PUBLIC_SUBKEY: case PKT_PUBLIC_SUBKEY:
case PKT_PUBLIC_KEY: case PKT_PUBLIC_KEY:
@ -140,34 +146,36 @@ build_packet( IOBUF out, PACKET *pkt )
rc = do_key (out, ctb, pkt->pkt.public_key); rc = do_key (out, ctb, pkt->pkt.public_key);
break; break;
case PKT_SYMKEY_ENC: case PKT_SYMKEY_ENC:
rc = do_symkey_enc( out, ctb, pkt->pkt.symkey_enc ); rc = do_symkey_enc (out, ctb, pkt->pkt.symkey_enc);
break; break;
case PKT_PUBKEY_ENC: case PKT_PUBKEY_ENC:
rc = do_pubkey_enc( out, ctb, pkt->pkt.pubkey_enc ); rc = do_pubkey_enc (out, ctb, pkt->pkt.pubkey_enc);
break; break;
case PKT_PLAINTEXT: case PKT_PLAINTEXT:
rc = do_plaintext( out, ctb, pkt->pkt.plaintext ); rc = do_plaintext (out, ctb, pkt->pkt.plaintext);
break; break;
case PKT_ENCRYPTED: case PKT_ENCRYPTED:
rc = do_encrypted( out, ctb, pkt->pkt.encrypted ); rc = do_encrypted (out, ctb, pkt->pkt.encrypted);
break; break;
case PKT_ENCRYPTED_MDC: case PKT_ENCRYPTED_MDC:
rc = do_encrypted_mdc( out, ctb, pkt->pkt.encrypted ); rc = do_encrypted_mdc (out, ctb, pkt->pkt.encrypted);
break; break;
case PKT_COMPRESSED: case PKT_COMPRESSED:
rc = do_compressed( out, ctb, pkt->pkt.compressed ); rc = do_compressed (out, ctb, pkt->pkt.compressed);
break; break;
case PKT_SIGNATURE: case PKT_SIGNATURE:
rc = do_signature( out, ctb, pkt->pkt.signature ); rc = do_signature (out, ctb, pkt->pkt.signature);
break; break;
case PKT_ONEPASS_SIG: case PKT_ONEPASS_SIG:
rc = do_onepass_sig( out, ctb, pkt->pkt.onepass_sig ); rc = do_onepass_sig (out, ctb, pkt->pkt.onepass_sig);
break; break;
case PKT_RING_TRUST: case PKT_RING_TRUST:
break; /* ignore it (keyring.c does write it directly)*/ /* Ignore it (keyring.c does write it directly) */
case PKT_MDC: /* we write it directly, so we should never see it here. */ break;
case PKT_MDC:
/* We write it directly, so we should never see it here. */
default: default:
log_bug("invalid packet type in build_packet()\n"); log_bug ("invalid packet type in build_packet()\n");
break; break;
} }
@ -262,13 +270,14 @@ gpg_mpi_write_nohdr (iobuf_t out, gcry_mpi_t a)
u32 u32
calc_packet_length( PACKET *pkt ) calc_packet_length( PACKET *pkt )
{ {
u32 n=0; u32 n = 0;
int new_ctb = 0; int new_ctb = 0;
log_assert (pkt->pkt.generic); log_assert (pkt->pkt.generic);
switch( pkt->pkttype ) { switch (pkt->pkttype)
{
case PKT_PLAINTEXT: case PKT_PLAINTEXT:
n = calc_plaintext( pkt->pkt.plaintext ); n = calc_plaintext (pkt->pkt.plaintext);
new_ctb = pkt->pkt.plaintext->new_ctb; new_ctb = pkt->pkt.plaintext->new_ctb;
break; break;
case PKT_ATTRIBUTE: case PKT_ATTRIBUTE:
@ -284,11 +293,11 @@ calc_packet_length( PACKET *pkt )
case PKT_RING_TRUST: case PKT_RING_TRUST:
case PKT_COMPRESSED: case PKT_COMPRESSED:
default: default:
log_bug("invalid packet type in calc_packet_length()"); log_bug ("invalid packet type in calc_packet_length()");
break; break;
} }
n += calc_header_length(n, new_ctb); n += calc_header_length (n, new_ctb);
return n; return n;
} }
@ -312,10 +321,10 @@ write_fake_data (IOBUF out, gcry_mpi_t a)
/* Serialize the user id (RFC 4880, Section 5.11) or the user /* Serialize the user id (RFC 4880, Section 5.11) or the user
attribute UID (Section 5.12) and write it to OUT. * attribute UID (Section 5.12) and write it to OUT.
*
CTB is the serialization's CTB. It specifies the header format and * CTB is the serialization's CTB. It specifies the header format and
the packet's type. The header length must not be set. */ * the packet's type. The header length must not be set. */
static int static int
do_user_id( IOBUF out, int ctb, PKT_user_id *uid ) do_user_id( IOBUF out, int ctb, PKT_user_id *uid )
{ {
@ -339,17 +348,17 @@ do_user_id( IOBUF out, int ctb, PKT_user_id *uid )
/* Serialize the key (RFC 4880, Section 5.5) described by PK and write /* Serialize the key (RFC 4880, Section 5.5) described by PK and write
it to OUT. * it to OUT.
*
This function serializes both primary keys and subkeys with or * This function serializes both primary keys and subkeys with or
without a secret part. * without a secret part.
*
CTB is the serialization's CTB. It specifies the header format and * CTB is the serialization's CTB. It specifies the header format and
the packet's type. The header length must not be set. * the packet's type. The header length must not be set.
*
PK->VERSION specifies the serialization format. A value of 0 means * PK->VERSION specifies the serialization format. A value of 0 means
to use the default version. Currently, only version 4 packets are * to use the default version. Currently, only version 4 packets are
supported. * supported.
*/ */
static int static int
do_key (iobuf_t out, int ctb, PKT_public_key *pk) do_key (iobuf_t out, int ctb, PKT_public_key *pk)
@ -496,11 +505,12 @@ do_key (iobuf_t out, int ctb, PKT_public_key *pk)
return err; return err;
} }
/* Serialize the symmetric-key encrypted session key packet (RFC 4880,
5.3) described by ENC and write it to OUT.
CTB is the serialization's CTB. It specifies the header format and /* Serialize the symmetric-key encrypted session key packet (RFC 4880,
the packet's type. The header length must not be set. */ * 5.3) described by ENC and write it to OUT.
*
* CTB is the serialization's CTB. It specifies the header format and
* the packet's type. The header length must not be set. */
static int static int
do_symkey_enc( IOBUF out, int ctb, PKT_symkey_enc *enc ) do_symkey_enc( IOBUF out, int ctb, PKT_symkey_enc *enc )
{ {
@ -513,19 +523,15 @@ do_symkey_enc( IOBUF out, int ctb, PKT_symkey_enc *enc )
log_assert( enc->version == 4 ); log_assert( enc->version == 4 );
/* RFC 4880, Section 3.7. */ /* RFC 4880, Section 3.7. */
switch( enc->s2k.mode ) switch (enc->s2k.mode)
{ {
/* Simple S2K. */ case 0: /* Simple S2K. */
case 0: case 1: /* Salted S2K. */
/* Salted S2K. */ case 3: /* Iterated and salted S2K. */
case 1: break; /* Reasonable values. */
/* Iterated and salted S2K. */
case 3:
/* Reasonable values. */
break;
default: default:
log_bug("do_symkey_enc: s2k=%d\n", enc->s2k.mode ); log_bug ("do_symkey_enc: s2k=%d\n", enc->s2k.mode);
} }
iobuf_put( a, enc->version ); iobuf_put( a, enc->version );
iobuf_put( a, enc->cipher_algo ); iobuf_put( a, enc->cipher_algo );