diff options
author | Niels Möller <nisse@lysator.liu.se> | 2010-03-30 21:45:37 +0200 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2010-03-30 21:45:37 +0200 |
commit | ed5015c3bcbbf120b1471e117c5042276fbf9680 (patch) | |
tree | b4b9dd84e3d77761c8f0318cd56cbb2167d56573 /dsa-verify.c | |
parent | 525862bc5c5a4bdd07ef71db15249c2a3177aee5 (diff) | |
download | nettle-ed5015c3bcbbf120b1471e117c5042276fbf9680.tar.gz |
* Makefile.in (hogweed_SOURCES): Added dsa-sha1-sign.c,
dsa-sha1-verify.c, dsa-sha256-sign.c, and dsa-sha256-verify.c.
* dsa.h: Updated and added dsa declarations.
* dsa-sha256-verify.c (dsa_sha256_verify_digest): New file, new
function.
(dsa_sha256_verify): New function.
* dsa-sha256-sign.c (dsa_sha256_sign_digest): New file, new
function.
(dsa_sha256_sign): New function.
* dsa-sha1-verify.c (dsa_sha1_verify_digest): New file. Moved and
renamed function, from dsa_verify_digest, rewrote to use
_dsa_verify.
(dsa_sha1_verify): Analogous change, renamed from dsa_verify.
* dsa-sha1-sign.c (dsa_sha1_sign_digest): New file. Moved and
renamed function, from dsa_sign_digest, rewrote to use _dsa_sign,
and added return value.
(dsa_sha1_sign): Analogous change, renamed from dsa_sign.
* dsa-verify.c (_dsa_verify): New general verification function,
for any hash.
* dsa-sign.c (_dsa_sign): New general signing function, for any
hash. Returns success code, like the rsa signture functions.
Rev: nettle/ChangeLog:1.71
Rev: nettle/Makefile.in:1.22
Rev: nettle/dsa-sha1-sign.c:1.1
Rev: nettle/dsa-sha1-verify.c:1.1
Rev: nettle/dsa-sha256-sign.c:1.1
Rev: nettle/dsa-sha256-verify.c:1.1
Rev: nettle/dsa-sign.c:1.3
Rev: nettle/dsa-verify.c:1.3
Rev: nettle/dsa.h:1.4
Diffstat (limited to 'dsa-verify.c')
-rw-r--r-- | dsa-verify.c | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/dsa-verify.c b/dsa-verify.c index 519c4207..faea0a00 100644 --- a/dsa-verify.c +++ b/dsa-verify.c @@ -34,16 +34,20 @@ #include "bignum.h" int -dsa_verify_digest(const struct dsa_public_key *key, - const uint8_t *digest, - const struct dsa_signature *signature) +_dsa_verify(const struct dsa_public_key *key, + unsigned digest_size, + const uint8_t *digest, + const struct dsa_signature *signature) { mpz_t w; mpz_t tmp; mpz_t v; int res; - + + if (mpz_sizeinbase(key->q, 2) != 8 * digest_size) + return 0; + /* Check that r and s are in the proper range */ if (mpz_sgn(signature->r) <= 0 || mpz_cmp(signature->r, key->q) >= 0) return 0; @@ -67,7 +71,7 @@ dsa_verify_digest(const struct dsa_public_key *key, mpz_init(v); /* The message digest */ - nettle_mpz_set_str_256_u(tmp, SHA1_DIGEST_SIZE, digest); + nettle_mpz_set_str_256_u(tmp, digest_size, digest); /* v = g^{w * h (mod q)} (mod p) */ mpz_mul(tmp, tmp, w); @@ -95,14 +99,3 @@ dsa_verify_digest(const struct dsa_public_key *key, return res; } - -int -dsa_verify(const struct dsa_public_key *key, - struct sha1_ctx *hash, - const struct dsa_signature *signature) -{ - uint8_t digest[SHA1_DIGEST_SIZE]; - sha1_digest(hash, sizeof(digest), digest); - - return dsa_verify_digest(key, digest, signature); -} |