diff options
author | Niels Möller <nisse@lysator.liu.se> | 2003-01-23 23:43:22 +0100 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2003-01-23 23:43:22 +0100 |
commit | a3399cff809345becc0f2b4f72268ce32aa84b86 (patch) | |
tree | 9ff0c39cf278eb2edcdcde319b2ac60589eabf0c /dsa-verify.c | |
parent | ed7977cb6ed129b6a839017d6cf7f5ee63d226af (diff) | |
download | nettle-a3399cff809345becc0f2b4f72268ce32aa84b86.tar.gz |
* dsa-verify.c (dsa_verify_digest): New function.
(dsa_verify): Most of the code moved to dsa_verify_digest, which
is used here.
* dsa-sign.c (dsa_sign_digest): New function.
(dsa_sign): Most of the code moved to dsa_sign_digest, which is
used here.
* dsa.c (_dsa_hash): Deleted function.
Rev: src/nettle/dsa-sign.c:1.5
Rev: src/nettle/dsa-verify.c:1.3
Diffstat (limited to 'dsa-verify.c')
-rw-r--r-- | dsa-verify.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/dsa-verify.c b/dsa-verify.c index 43d76c77..87c2a48a 100644 --- a/dsa-verify.c +++ b/dsa-verify.c @@ -5,7 +5,7 @@ /* nettle, low-level cryptographics library * - * Copyright (C) 2002 Niels Möller + * Copyright (C) 2002, 2003 Niels Möller * * The nettle library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -31,12 +31,14 @@ #include "dsa.h" +#include "bignum.h" + #include <stdlib.h> int -dsa_verify(const struct dsa_public_key *key, - struct sha1_ctx *hash, - const struct dsa_signature *signature) +dsa_verify_digest(const struct dsa_public_key *key, + const uint8_t *digest, + const struct dsa_signature *signature) { mpz_t w; mpz_t tmp; @@ -65,12 +67,11 @@ dsa_verify(const struct dsa_public_key *key, mpz_init(tmp); mpz_init(v); - - /* Compute hash */ - _dsa_hash(tmp, hash); + + /* The message digest */ + nettle_mpz_set_str_256_u(tmp, SHA1_DIGEST_SIZE, digest); /* v = g^{w * h (mod q)} (mod p) */ - mpz_mul(tmp, tmp, w); mpz_fdiv_r(tmp, tmp, key->q); @@ -97,4 +98,15 @@ dsa_verify(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); +} + #endif /* WITH_PUBLIC_KEY */ |