3 Copyright (C) 2002 Niels Möller
5 This file is part of GNU Nettle.
7 GNU Nettle is free software: you can redistribute it and/or
8 modify it under the terms of either:
10 * the GNU Lesser General Public License as published by the Free
11 Software Foundation; either version 3 of the License, or (at your
12 option) any later version.
16 * the GNU General Public License as published by the Free
17 Software Foundation; either version 2 of the License, or (at your
18 option) any later version.
20 or both in parallel, as here.
22 GNU Nettle is distributed in the hope that it will be useful,
23 but WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 General Public License for more details.
27 You should have received copies of the GNU General Public License and
28 the GNU Lesser General Public License along with this program. If
29 not, see http://www.gnu.org/licenses/.
45 read_signature(const char *name, mpz_t s)
51 length = read_file(name, 0, &buffer);
55 res = (mpz_set_str(s, buffer, 16) == 0);
62 main(int argc, char **argv)
64 struct rsa_public_key key;
70 werror("Usage: rsa-verify PUBLIC-KEY SIGNATURE-FILE < FILE\n");
74 rsa_public_key_init(&key);
76 if (!read_rsa_key(argv[1], &key, NULL))
78 werror("Invalid key\n");
84 if (!read_signature(argv[2], s))
86 werror("Failed to read signature file `%s'\n",
92 if (!hash_file(&nettle_sha1, &hash, stdin))
94 werror("Failed reading stdin: %s\n",
99 if (!rsa_sha1_verify(&key, &hash, s))
101 werror("Invalid signature!\n");
106 rsa_public_key_clear(&key);