1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-23 15:07:03 +01:00

gpg: Re-indent check_key_signature2.

--

I am considering some changes and thus better start off by switching
to standard GNU indentation.  This patch also changes comment lines
like

      if (foo)
        /* Comment on foo.  */
        {

to

      if (foo)
        { /* Comment on foo.  */

or

      if (foo) /* Comment on foo.  */
        {

to make the brace of the opening block stand out immediately.

Further stars on the left are added to longer comments because that
makes the code easier to read by disabled hackers, when reading
without font locking, and for reading black-white printouts.
This commit is contained in:
Werner Koch 2016-01-12 10:41:07 +01:00
parent 4b4639b0b0
commit 4619ea8e51
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -48,42 +48,43 @@ check_signature (PKT_signature *sig, gcry_md_hd_t digest)
return check_signature2 (sig, digest, NULL, NULL, NULL, NULL); return check_signature2 (sig, digest, NULL, NULL, NULL, NULL);
} }
/* Check a signature. /* Check a signature.
*
Looks up the public key that created the signature (SIG->KEYID) * Looks up the public key that created the signature (SIG->KEYID)
from the key db. Makes sure that the signature is valid (it was * from the key db. Makes sure that the signature is valid (it was
not created prior to the key, the public key was created in the * not created prior to the key, the public key was created in the
past, and the signature does not include any unsupported critical * past, and the signature does not include any unsupported critical
features), finishes computing the hash of the signature data, and * features), finishes computing the hash of the signature data, and
checks that the signature verifies the digest. If the key that * checks that the signature verifies the digest. If the key that
generated the signature is a subkey, this function also verifies * generated the signature is a subkey, this function also verifies
that there is a valid backsig from the subkey to the primary key. * that there is a valid backsig from the subkey to the primary key.
Finally, if status fd is enabled and the signature class is 0x00 or * Finally, if status fd is enabled and the signature class is 0x00 or
0x01, then a STATUS_SIG_ID is emitted on the status fd. * 0x01, then a STATUS_SIG_ID is emitted on the status fd.
*
SIG is the signature to check. * SIG is the signature to check.
*
DIGEST contains a valid hash context that already includes the * DIGEST contains a valid hash context that already includes the
signed data. This function adds the relevant meta-data from the * signed data. This function adds the relevant meta-data from the
signature packet to compute the final hash. (See Section 5.2 of * signature packet to compute the final hash. (See Section 5.2 of
RFC 4880: "The concatenation of the data being signed and the * RFC 4880: "The concatenation of the data being signed and the
signature data from the version number through the hashed subpacket * signature data from the version number through the hashed subpacket
data (inclusive) is hashed.") * data (inclusive) is hashed.")
*
If R_EXPIREDATE is not NULL, R_EXPIREDATE is set to the key's * If R_EXPIREDATE is not NULL, R_EXPIREDATE is set to the key's
expiry. * expiry.
*
If R_EXPIRED is not NULL, *R_EXPIRED is set to 1 if PK has expired * If R_EXPIRED is not NULL, *R_EXPIRED is set to 1 if PK has expired
(0 otherwise). Note: PK being expired does not cause this function * (0 otherwise). Note: PK being expired does not cause this function
to fail. * to fail.
*
If R_REVOKED is not NULL, *R_REVOKED is set to 1 if PK has been * If R_REVOKED is not NULL, *R_REVOKED is set to 1 if PK has been
revoked (0 otherwise). Note: PK being revoked does not cause this * revoked (0 otherwise). Note: PK being revoked does not cause this
function to fail. * function to fail.
*
If PK is not NULL, the public key is saved in *PK on success. * If PK is not NULL, the public key is saved in *PK on success.
*
Returns 0 on success. An error code otherwise. */ * Returns 0 on success. An error code otherwise. */
int int
check_signature2 (PKT_signature *sig, gcry_md_hd_t digest, u32 *r_expiredate, check_signature2 (PKT_signature *sig, gcry_md_hd_t digest, u32 *r_expiredate,
int *r_expired, int *r_revoked, PKT_public_key *pk ) int *r_expired, int *r_revoked, PKT_public_key *pk )
@ -237,22 +238,22 @@ check_signature2 (PKT_signature *sig, gcry_md_hd_t digest, u32 *r_expiredate,
/* The signature SIG was generated with the public key PK. Check /* The signature SIG was generated with the public key PK. Check
whether the signature is valid in the following sense: * whether the signature is valid in the following sense:
*
- Make sure the public key was created before the signature was * - Make sure the public key was created before the signature was
generated. * generated.
*
- Make sure the public key was created in the past * - Make sure the public key was created in the past
*
- Check whether PK has expired (set *R_EXPIRED to 1 if so and 0 * - Check whether PK has expired (set *R_EXPIRED to 1 if so and 0
otherwise) * otherwise)
*
- Check whether PK has been revoked (set *R_REVOKED to 1 if so * - Check whether PK has been revoked (set *R_REVOKED to 1 if so
and 0 otherwise). * and 0 otherwise).
*
If either of the first two tests fail, returns an error code. * If either of the first two tests fail, returns an error code.
Otherwise returns 0. (Thus, this function doesn't fail if the * Otherwise returns 0. (Thus, this function doesn't fail if the
public key is expired or revoked.) */ * public key is expired or revoked.) */
static int static int
check_signature_metadata_validity (PKT_public_key *pk, PKT_signature *sig, check_signature_metadata_validity (PKT_public_key *pk, PKT_signature *sig,
int *r_expired, int *r_revoked) int *r_expired, int *r_revoked)
@ -318,34 +319,34 @@ check_signature_metadata_validity (PKT_public_key *pk, PKT_signature *sig,
/* Finish generating a signature and check it. Concretely: make sure /* Finish generating a signature and check it. Concretely: make sure
that the signature is valid (it was not created prior to the key, * that the signature is valid (it was not created prior to the key,
the public key was created in the past, and the signature does not * the public key was created in the past, and the signature does not
include any unsupported critical features), finish computing the * include any unsupported critical features), finish computing the
digest by adding the relevant data from the signature packet, and * digest by adding the relevant data from the signature packet, and
check that the signature verifies the digest. * check that the signature verifies the digest.
*
DIGEST contains a hash context, which has already hashed the signed * DIGEST contains a hash context, which has already hashed the signed
data. This function adds the relevant meta-data from the signature * data. This function adds the relevant meta-data from the signature
packet to compute the final hash. (See Section 5.2 of RFC 4880: * packet to compute the final hash. (See Section 5.2 of RFC 4880:
"The concatenation of the data being signed and the signature data * "The concatenation of the data being signed and the signature data
from the version number through the hashed subpacket data * from the version number through the hashed subpacket data
(inclusive) is hashed.") * (inclusive) is hashed.")
*
SIG is the signature to check. * SIG is the signature to check.
*
PK is the public key used to generate the signature. * PK is the public key used to generate the signature.
*
If R_EXPIRED is not NULL, *R_EXPIRED is set to 1 if PK has expired * If R_EXPIRED is not NULL, *R_EXPIRED is set to 1 if PK has expired
(0 otherwise). Note: PK being expired does not cause this function * (0 otherwise). Note: PK being expired does not cause this function
to fail. * to fail.
*
If R_REVOKED is not NULL, *R_REVOKED is set to 1 if PK has been * If R_REVOKED is not NULL, *R_REVOKED is set to 1 if PK has been
revoked (0 otherwise). Note: PK being revoked does not cause this * revoked (0 otherwise). Note: PK being revoked does not cause this
function to fail. * function to fail.
*
If RET_PK is not NULL, PK is copied into RET_PK on success. * If RET_PK is not NULL, PK is copied into RET_PK on success.
*
Returns 0 on success. An error code other. */ * Returns 0 on success. An error code other. */
static int static int
check_signature_end (PKT_public_key *pk, PKT_signature *sig, check_signature_end (PKT_public_key *pk, PKT_signature *sig,
gcry_md_hd_t digest, gcry_md_hd_t digest,
@ -486,35 +487,36 @@ cache_sig_result ( PKT_signature *sig, int result )
} }
} }
/* SIG is a key revocation signature. Check if this signature was /* SIG is a key revocation signature. Check if this signature was
generated by any of the public key PK's designated revokers. * generated by any of the public key PK's designated revokers.
*
PK is the public key that SIG allegedly revokes. * PK is the public key that SIG allegedly revokes.
*
SIG is the revocation signature to check. * SIG is the revocation signature to check.
*
This function avoids infinite recursion, which can happen if two * This function avoids infinite recursion, which can happen if two
keys are designed revokers for each other and they revoke each * keys are designed revokers for each other and they revoke each
other. This is done by observing that if a key A is revoked by key * other. This is done by observing that if a key A is revoked by key
B we still consider the revocation to be valid even if B is * B we still consider the revocation to be valid even if B is
revoked. Thus, we don't need to determine whether B is revoked to * revoked. Thus, we don't need to determine whether B is revoked to
determine whether A has been revoked by B, we just need to check * determine whether A has been revoked by B, we just need to check
the signature. * the signature.
*
Returns 0 if sig is valid (i.e. pk is revoked), non-0 if not * Returns 0 if sig is valid (i.e. pk is revoked), non-0 if not
revoked. We are careful to make sure that GPG_ERR_NO_PUBKEY is * revoked. We are careful to make sure that GPG_ERR_NO_PUBKEY is
only returned when a revocation signature is from a valid * only returned when a revocation signature is from a valid
revocation key designated in a revkey subpacket, but the revocation * revocation key designated in a revkey subpacket, but the revocation
key itself isn't present. */ * key itself isn't present.
*
/* XXX: This code will need to be modified if gpg ever becomes * XXX: This code will need to be modified if gpg ever becomes
multi-threaded. Note that this guarantees that a designated * multi-threaded. Note that this guarantees that a designated
revocation sig will never be considered valid unless it is actually * revocation sig will never be considered valid unless it is actually
valid, as well as being issued by a revocation key in a valid * valid, as well as being issued by a revocation key in a valid
direct signature. Note also that this is written so that a revoked * direct signature. Note also that this is written so that a revoked
revoker can still issue revocations: i.e. If A revokes B, but A is * revoker can still issue revocations: i.e. If A revokes B, but A is
revoked, B is still revoked. I'm not completely convinced this is * revoked, B is still revoked. I'm not completely convinced this is
the proper behavior, but it matches how PGP does it. -dms */ * the proper behavior, but it matches how PGP does it. -dms */
int int
check_revocation_keys (PKT_public_key *pk, PKT_signature *sig) check_revocation_keys (PKT_public_key *pk, PKT_signature *sig)
{ {
@ -526,29 +528,29 @@ check_revocation_keys (PKT_public_key *pk, PKT_signature *sig)
assert((sig->keyid[0]!=pk->keyid[0]) || (sig->keyid[0]!=pk->keyid[1])); assert((sig->keyid[0]!=pk->keyid[0]) || (sig->keyid[0]!=pk->keyid[1]));
/* Avoid infinite recursion. Consider the following: /* Avoid infinite recursion. Consider the following:
*
- We want to check if A is revoked. * - We want to check if A is revoked.
*
- C is a designated revoker for B and has revoked B. * - C is a designated revoker for B and has revoked B.
*
- B is a designated revoker for A and has revoked A. * - B is a designated revoker for A and has revoked A.
*
When checking if A is revoked (in merge_selfsigs_main), we * When checking if A is revoked (in merge_selfsigs_main), we
observe that A has a designed revoker. As such, we call this * observe that A has a designed revoker. As such, we call this
function. This function sees that there is a valid revocation * function. This function sees that there is a valid revocation
signature, which is signed by B. It then calls check_signature() * signature, which is signed by B. It then calls check_signature()
to verify that the signature is good. To check the sig, we need * to verify that the signature is good. To check the sig, we need
to lookup B. Looking up B means calling merge_selfsigs_main, * to lookup B. Looking up B means calling merge_selfsigs_main,
which checks whether B is revoked, which calls this function to * which checks whether B is revoked, which calls this function to
see if B was revoked by some key. * see if B was revoked by some key.
*
In this case, the added level of indirection doesn't hurt. It * In this case, the added level of indirection doesn't hurt. It
just means a bit more work. However, if C == A, then we'd end up * just means a bit more work. However, if C == A, then we'd end up
in a loop. But, it doesn't make sense to look up C anyways: even * in a loop. But, it doesn't make sense to look up C anyways: even
if B is revoked, we conservatively consider a valid revocation * if B is revoked, we conservatively consider a valid revocation
signed by B to revoke A. Since this is the only place where this * signed by B to revoke A. Since this is the only place where this
type of recursion can occur, we simply cause this function to * type of recursion can occur, we simply cause this function to
fail if it is entered recursively. */ * fail if it is entered recursively. */
if (busy) if (busy)
{ {
/* Return an error (i.e. not revoked), but mark the pk as /* Return an error (i.e. not revoked), but mark the pk as
@ -637,202 +639,225 @@ check_backsig (PKT_public_key *main_pk,PKT_public_key *sub_pk,
/* Check that a signature over a key is valid. This is a /* Check that a signature over a key is valid. This is a
specialization of check_key_signature2 with the unnamed parameters * specialization of check_key_signature2 with the unnamed parameters
passed as NULL. See the documentation for that function for more * passed as NULL. See the documentation for that function for more
details. */ * details. */
int int
check_key_signature (KBNODE root, KBNODE node, int *is_selfsig) check_key_signature (KBNODE root, KBNODE node, int *is_selfsig)
{ {
return check_key_signature2 (root, node, NULL, NULL, is_selfsig, NULL, NULL); return check_key_signature2 (root, node, NULL, NULL, is_selfsig, NULL, NULL);
} }
/* Check that a signature over a key (e.g., a key revocation, key /* Check that a signature over a key (e.g., a key revocation, key
binding, user id certification, etc.) is valid. If the function * binding, user id certification, etc.) is valid. If the function
detects a self-signature, it uses the public key from the specified * detects a self-signature, it uses the public key from the specified
key block and does not bother looking up the key specified in the * key block and does not bother looking up the key specified in the
signature packet. * signature packet.
*
ROOT is a keyblock. * ROOT is a keyblock.
*
NODE references a signature packet that appears in the keyblock * NODE references a signature packet that appears in the keyblock
that should be verified. * that should be verified.
*
If CHECK_PK is set, the specified key is sometimes preferred for * If CHECK_PK is set, the specified key is sometimes preferred for
verifying signatures. See the implementation for details. * verifying signatures. See the implementation for details.
*
If RET_PK is not NULL, the public key that successfully verified * If RET_PK is not NULL, the public key that successfully verified
the signature is copied into *RET_PK. * the signature is copied into *RET_PK.
*
If IS_SELFSIG is not NULL, *IS_SELFSIG is set to 1 if NODE is a * If IS_SELFSIG is not NULL, *IS_SELFSIG is set to 1 if NODE is a
self-signature. * self-signature.
*
If R_EXPIREDATE is not NULL, *R_EXPIREDATE is set to the expiry * If R_EXPIREDATE is not NULL, *R_EXPIREDATE is set to the expiry
date. * date.
*
If R_EXPIRED is not NULL, *R_EXPIRED is set to 1 if PK has been * If R_EXPIRED is not NULL, *R_EXPIRED is set to 1 if PK has been
expired (0 otherwise). Note: PK being revoked does not cause this * expired (0 otherwise). Note: PK being revoked does not cause this
function to fail. * function to fail.
*
*
If OPT.NO_SIG_CACHE is not set, this function will first check if * If OPT.NO_SIG_CACHE is not set, this function will first check if
the result of a previous verification is already cached in the * the result of a previous verification is already cached in the
signature packet's data structure. */ * signature packet's data structure.
/* TODO: add r_revoked here as well. It has the same problems as *
r_expiredate and r_expired and the cache. */ * TODO: add r_revoked here as well. It has the same problems as
* r_expiredate and r_expired and the cache. */
int int
check_key_signature2(KBNODE root, KBNODE node, PKT_public_key *check_pk, check_key_signature2 (kbnode_t root, kbnode_t node, PKT_public_key *check_pk,
PKT_public_key *ret_pk, int *is_selfsig, PKT_public_key *ret_pk, int *is_selfsig,
u32 *r_expiredate, int *r_expired ) u32 *r_expiredate, int *r_expired )
{ {
gcry_md_hd_t md; gcry_md_hd_t md;
PKT_public_key *pk; PKT_public_key *pk;
PKT_signature *sig; PKT_signature *sig;
int algo; int algo;
int rc; int rc;
if( is_selfsig ) if (is_selfsig)
*is_selfsig = 0; *is_selfsig = 0;
if( r_expiredate ) if (r_expiredate)
*r_expiredate = 0; *r_expiredate = 0;
if( r_expired ) if (r_expired)
*r_expired = 0; *r_expired = 0;
assert( node->pkt->pkttype == PKT_SIGNATURE ); assert (node->pkt->pkttype == PKT_SIGNATURE);
assert( root->pkt->pkttype == PKT_PUBLIC_KEY ); assert (root->pkt->pkttype == PKT_PUBLIC_KEY);
pk = root->pkt->pkt.public_key; pk = root->pkt->pkt.public_key;
sig = node->pkt->pkt.signature; sig = node->pkt->pkt.signature;
algo = sig->digest_algo; algo = sig->digest_algo;
/* Check whether we have cached the result of a previous signature /* Check whether we have cached the result of a previous signature
check. Note that we may no longer have the pubkey or hash check. Note that we may no longer have the pubkey or hash
needed to verify a sig, but can still use the cached value. A needed to verify a sig, but can still use the cached value. A
cache refresh detects and clears these cases. */ cache refresh detects and clears these cases. */
if ( !opt.no_sig_cache ) { if ( !opt.no_sig_cache )
if (sig->flags.checked) { /*cached status available*/ {
if( is_selfsig ) { if (sig->flags.checked) /* Cached status available. */
u32 keyid[2]; {
if (is_selfsig)
{
u32 keyid[2];
keyid_from_pk( pk, keyid ); keyid_from_pk (pk, keyid);
if( keyid[0] == sig->keyid[0] && keyid[1] == sig->keyid[1] ) if (keyid[0] == sig->keyid[0] && keyid[1] == sig->keyid[1])
*is_selfsig = 1; *is_selfsig = 1;
} }
/* BUG: This is wrong for non-self-sigs.. needs to be the /* BUG: This is wrong for non-self-sigs... needs to be the
actual pk */ actual pk. */
if((rc = check_signature_metadata_validity (pk, sig, rc = check_signature_metadata_validity (pk, sig, r_expired, NULL);
r_expired, NULL))) if (rc)
return rc; return rc;
return sig->flags.valid? 0 : gpg_error (GPG_ERR_BAD_SIGNATURE); return sig->flags.valid? 0 : gpg_error (GPG_ERR_BAD_SIGNATURE);
} }
} }
if( (rc=openpgp_pk_test_algo(sig->pubkey_algo)) ) rc = openpgp_pk_test_algo(sig->pubkey_algo);
return rc; if (rc)
if( (rc=openpgp_md_test_algo(algo)) ) return rc;
return rc; rc = openpgp_md_test_algo(algo);
if (rc)
return rc;
if( sig->sig_class == 0x20 ) { /* key revocation */ if (sig->sig_class == 0x20) /* key revocation */
u32 keyid[2]; {
keyid_from_pk( pk, keyid ); u32 keyid[2];
keyid_from_pk( pk, keyid );
/* is it a designated revoker? */ /* Is it a designated revoker? */
if(keyid[0]!=sig->keyid[0] || keyid[1]!=sig->keyid[1]) if (keyid[0] != sig->keyid[0] || keyid[1] != sig->keyid[1])
rc=check_revocation_keys(pk,sig); rc = check_revocation_keys (pk, sig);
else else
{ {
if (gcry_md_open (&md, algo, 0 )) if (gcry_md_open (&md, algo, 0))
BUG (); BUG ();
hash_public_key( md, pk ); hash_public_key (md, pk);
rc = check_signature_end (pk, sig, md, r_expired, NULL, ret_pk); rc = check_signature_end (pk, sig, md, r_expired, NULL, ret_pk);
cache_sig_result ( sig, rc ); cache_sig_result (sig, rc);
gcry_md_close(md); gcry_md_close (md);
} }
} }
else if( sig->sig_class == 0x28 ) { /* subkey revocation */ else if (sig->sig_class == 0x28) /* subkey revocation */
KBNODE snode = find_prev_kbnode( root, node, PKT_PUBLIC_SUBKEY ); {
kbnode_t snode = find_prev_kbnode (root, node, PKT_PUBLIC_SUBKEY);
if( snode ) { if (snode)
if (gcry_md_open (&md, algo, 0)) {
BUG (); if (gcry_md_open (&md, algo, 0))
hash_public_key( md, pk ); BUG ();
hash_public_key( md, snode->pkt->pkt.public_key ); hash_public_key (md, pk);
rc = check_signature_end (pk, sig, md, r_expired, NULL, ret_pk); hash_public_key (md, snode->pkt->pkt.public_key);
cache_sig_result ( sig, rc ); rc = check_signature_end (pk, sig, md, r_expired, NULL, ret_pk);
gcry_md_close(md); cache_sig_result (sig, rc);
gcry_md_close (md);
} }
else else
{ {
if (opt.verbose) if (opt.verbose)
log_info (_("key %s: no subkey for subkey" log_info (_("key %s: no subkey for subkey"
" revocation signature\n"),keystr_from_pk(pk)); " revocation signature\n"), keystr_from_pk(pk));
rc = GPG_ERR_SIG_CLASS; rc = GPG_ERR_SIG_CLASS;
} }
} }
else if( sig->sig_class == 0x18 ) { /* key binding */ else if (sig->sig_class == 0x18) /* key binding */
KBNODE snode = find_prev_kbnode( root, node, PKT_PUBLIC_SUBKEY ); {
kbnode_t snode = find_prev_kbnode (root, node, PKT_PUBLIC_SUBKEY);
if( snode ) { if (snode)
if( is_selfsig ) { /* does this make sense????? */ {
u32 keyid[2]; /* it should always be a selfsig */ if (is_selfsig)
{
/* Does this make sense? It should always be a
selfsig. Yes: We can't be sure about this and we
need to be able to indicate that it is a selfsig.
FIXME: The question is whether we should reject
such a signature if it is not a selfsig. */
u32 keyid[2];
keyid_from_pk( pk, keyid ); keyid_from_pk (pk, keyid);
if( keyid[0] == sig->keyid[0] && keyid[1] == sig->keyid[1] ) if (keyid[0] == sig->keyid[0] && keyid[1] == sig->keyid[1])
*is_selfsig = 1; *is_selfsig = 1;
} }
if (gcry_md_open (&md, algo, 0)) if (gcry_md_open (&md, algo, 0))
BUG (); BUG ();
hash_public_key( md, pk ); hash_public_key (md, pk);
hash_public_key( md, snode->pkt->pkt.public_key ); hash_public_key (md, snode->pkt->pkt.public_key);
rc = check_signature_end (pk, sig, md, r_expired, NULL, ret_pk); rc = check_signature_end (pk, sig, md, r_expired, NULL, ret_pk);
cache_sig_result ( sig, rc ); cache_sig_result ( sig, rc );
gcry_md_close(md); gcry_md_close (md);
} }
else else
{ {
if (opt.verbose) if (opt.verbose)
log_info(_("key %s: no subkey for subkey" log_info(_("key %s: no subkey for subkey"
" binding signature\n"),keystr_from_pk(pk)); " binding signature\n"), keystr_from_pk(pk));
rc = GPG_ERR_SIG_CLASS; rc = GPG_ERR_SIG_CLASS;
} }
} }
else if( sig->sig_class == 0x1f ) { /* direct key signature */ else if (sig->sig_class == 0x1f) /* direct key signature */
{
if (gcry_md_open (&md, algo, 0 )) if (gcry_md_open (&md, algo, 0 ))
BUG (); BUG ();
hash_public_key( md, pk ); hash_public_key( md, pk );
rc = check_signature_end (pk, sig, md, r_expired, NULL, ret_pk); rc = check_signature_end (pk, sig, md, r_expired, NULL, ret_pk);
cache_sig_result ( sig, rc ); cache_sig_result (sig, rc);
gcry_md_close(md); gcry_md_close (md);
} }
else { /* all other classes */ else /* all other classes */
KBNODE unode = find_prev_kbnode( root, node, PKT_USER_ID ); {
kbnode_t unode = find_prev_kbnode (root, node, PKT_USER_ID);
if( unode ) { if (unode)
{
u32 keyid[2]; u32 keyid[2];
keyid_from_pk( pk, keyid ); keyid_from_pk (pk, keyid);
if (gcry_md_open (&md, algo, 0 )) if (gcry_md_open (&md, algo, 0))
BUG (); BUG ();
hash_public_key( md, pk ); hash_public_key (md, pk);
hash_uid_node( unode, md, sig ); hash_uid_node (unode, md, sig);
if( keyid[0] == sig->keyid[0] && keyid[1] == sig->keyid[1] ) if (keyid[0] == sig->keyid[0] && keyid[1] == sig->keyid[1])
/* The primary key is the signing key. */ { /* The primary key is the signing key. */
{
if( is_selfsig ) if (is_selfsig)
*is_selfsig = 1; *is_selfsig = 1;
rc = check_signature_end (pk, sig, md, r_expired, NULL, ret_pk); rc = check_signature_end (pk, sig, md, r_expired, NULL, ret_pk);
} }
else if (check_pk) else if (check_pk)
/* The caller specified a key. Try that. */ { /* The caller specified a key. Try that. */
rc = check_signature_end (check_pk, sig, md,
r_expired, NULL, ret_pk);
else
/* Look up the key. XXX: Could it be that the key is
not is not in this keyblock? */
rc = check_signature2 (sig, md, r_expiredate, r_expired,
NULL, ret_pk);
cache_sig_result ( sig, rc ); rc = check_signature_end (check_pk, sig, md,
gcry_md_close(md); r_expired, NULL, ret_pk);
} }
else
{ /* Look up the key. */
rc = check_signature2 (sig, md, r_expiredate, r_expired,
NULL, ret_pk);
}
cache_sig_result (sig, rc);
gcry_md_close (md);
}
else else
{ {
if (!opt.quiet) if (!opt.quiet)
@ -840,7 +865,7 @@ check_key_signature2(KBNODE root, KBNODE node, PKT_public_key *check_pk,
" of class %02x\n",keystr_from_pk(pk),sig->sig_class); " of class %02x\n",keystr_from_pk(pk),sig->sig_class);
rc = GPG_ERR_SIG_CLASS; rc = GPG_ERR_SIG_CLASS;
} }
} }
return rc; return rc;
} }