diff options
author | Niels Möller <nisse@lysator.liu.se> | 2006-11-27 23:08:38 +0100 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2006-11-27 23:08:38 +0100 |
commit | 81a882036321eaee33bf44a769e65dc446bb4c14 (patch) | |
tree | c9b326152902f1d886fedb8f47dd3969a5bcbc85 /rsa-sha256-verify.c | |
parent | 75d006827a8fa18d928b59f31545d12b8600d157 (diff) | |
download | nettle-81a882036321eaee33bf44a769e65dc446bb4c14.tar.gz |
New files.
Rev: src/nettle/pkcs1-rsa-sha256.c:1.1
Rev: src/nettle/rsa-sha256-sign.c:1.1
Rev: src/nettle/rsa-sha256-verify.c:1.1
Diffstat (limited to 'rsa-sha256-verify.c')
-rw-r--r-- | rsa-sha256-verify.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/rsa-sha256-verify.c b/rsa-sha256-verify.c new file mode 100644 index 00000000..a0235a48 --- /dev/null +++ b/rsa-sha256-verify.c @@ -0,0 +1,77 @@ +/* rsa-sha256-verify.c + * + * Verifying signatures created with RSA and SHA256. + */ + +/* nettle, low-level cryptographics library + * + * Copyright (C) 2001, 2003, 2006 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 + * the Free Software Foundation; either version 2.1 of the License, or (at your + * option) any later version. + * + * The nettle library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the nettle library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + */ + +#if HAVE_CONFIG_H +# include "config.h" +#endif + +#if WITH_PUBLIC_KEY + +#include <assert.h> + +#include "rsa.h" + +#include "bignum.h" +#include "pkcs1.h" + +int +rsa_sha256_verify(const struct rsa_public_key *key, + struct sha256_ctx *hash, + const mpz_t s) +{ + int res; + mpz_t m; + + assert(key->size >= RSA_MINIMUM_N_OCTETS); + mpz_init(m); + + pkcs1_rsa_sha256_encode(m, key->size - 1, hash); + res = _rsa_verify(key, m, s); + + mpz_clear(m); + + return res; +} + +int +rsa_sha256_verify_digest(const struct rsa_public_key *key, + const uint8_t *digest, + const mpz_t s) +{ + int res; + mpz_t m; + + assert(key->size >= RSA_MINIMUM_N_OCTETS); + mpz_init(m); + + pkcs1_rsa_sha256_encode_digest(m, key->size - 1, digest); + res = _rsa_verify(key, m, s); + + mpz_clear(m); + + return res; +} + +#endif /* WITH_PUBLIC_KEY */ |