mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-21 14:47:03 +01:00
gpg: Split the function check_signature_end.
* g10/sig-check.c (check_signature_end): Break the basic signature check into... (check_signature_end_simple): ... this new function. -- Signed-off-by: Neal H. Walfield <neal@g10code.com>
This commit is contained in:
parent
10671c3a4c
commit
ac5aea9545
@ -40,6 +40,9 @@ static int check_signature_end (PKT_public_key *pk, PKT_signature *sig,
|
|||||||
int *r_expired, int *r_revoked,
|
int *r_expired, int *r_revoked,
|
||||||
PKT_public_key *ret_pk);
|
PKT_public_key *ret_pk);
|
||||||
|
|
||||||
|
static int check_signature_end_simple (PKT_public_key *pk, PKT_signature *sig,
|
||||||
|
gcry_md_hd_t digest);
|
||||||
|
|
||||||
/* Check a signature. This is shorthand for check_signature2 with
|
/* Check a signature. This is shorthand for check_signature2 with
|
||||||
the unnamed arguments passed as NULL. */
|
the unnamed arguments passed as NULL. */
|
||||||
int
|
int
|
||||||
@ -376,14 +379,32 @@ check_signature_end (PKT_public_key *pk, PKT_signature *sig,
|
|||||||
gcry_md_hd_t digest,
|
gcry_md_hd_t digest,
|
||||||
int *r_expired, int *r_revoked, PKT_public_key *ret_pk)
|
int *r_expired, int *r_revoked, PKT_public_key *ret_pk)
|
||||||
{
|
{
|
||||||
gcry_mpi_t result = NULL;
|
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
const struct weakhash *weak;
|
|
||||||
|
|
||||||
if ((rc = check_signature_metadata_validity (pk, sig,
|
if ((rc = check_signature_metadata_validity (pk, sig,
|
||||||
r_expired, r_revoked)))
|
r_expired, r_revoked)))
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
if ((rc = check_signature_end_simple (pk, sig, digest)))
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
if(!rc && ret_pk)
|
||||||
|
copy_public_key(ret_pk,pk);
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This function is similar to check_signature_end, but it only checks
|
||||||
|
whether the signature was generated by PK. It does not check
|
||||||
|
expiration, revocation, etc. */
|
||||||
|
static int
|
||||||
|
check_signature_end_simple (PKT_public_key *pk, PKT_signature *sig,
|
||||||
|
gcry_md_hd_t digest)
|
||||||
|
{
|
||||||
|
gcry_mpi_t result = NULL;
|
||||||
|
int rc = 0;
|
||||||
|
const struct weakhash *weak;
|
||||||
|
|
||||||
if (!opt.flags.allow_weak_digest_algos)
|
if (!opt.flags.allow_weak_digest_algos)
|
||||||
for (weak = opt.weak_digests; weak; weak = weak->next)
|
for (weak = opt.weak_digests; weak; weak = weak->next)
|
||||||
if (sig->digest_algo == weak->algo)
|
if (sig->digest_algo == weak->algo)
|
||||||
@ -453,9 +474,6 @@ check_signature_end (PKT_public_key *pk, PKT_signature *sig,
|
|||||||
rc = GPG_ERR_BAD_SIGNATURE;
|
rc = GPG_ERR_BAD_SIGNATURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!rc && ret_pk)
|
|
||||||
copy_public_key(ret_pk,pk);
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user