]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
* examples/rsa-sign.c: No need to include config.h. Use werror
authorNiels Möller <nisse@lysator.liu.se>
Tue, 1 Oct 2002 14:04:01 +0000 (16:04 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Tue, 1 Oct 2002 14:04:01 +0000 (16:04 +0200)
instead of fprintf.
* examples/rsa-verify.c: Likewise.

Rev: src/nettle/examples/rsa-sign.c:1.3
Rev: src/nettle/examples/rsa-verify.c:1.2

examples/rsa-sign.c
examples/rsa-verify.c

index 2645af4404b92de6a8671f25c9f2905485bd547d..a96d3b1e6f9d56a718f5a55fba663849d351619d 100644 (file)
  * MA 02111-1307, USA.
  */
 
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif /* HAVE_CONFIG_H */
-
-#if !WITH_PUBLIC_KEY
-int
-main(int argc, char **argv)
-{
-  fprintf(stderr,
-         "You need to install GMP somewhere where Nettle can find it,\n"
-         "and recompile Nettle\n");
-  return EXIT_FAILURE;
-}
-#else /* WITH_PUBLIC_KEY */
-
 #include <errno.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 
+/* string.h must be included before gmp.h */
 #include "rsa.h"
 #include "io.h"
 
@@ -54,7 +40,7 @@ main(int argc, char **argv)
   
   if (argc != 2)
     {
-      fprintf(stderr, "Usage: rsa-sign PRIVATE-KEY < file\n");
+      werror("Usage: rsa-sign PRIVATE-KEY < file\n");
       return EXIT_FAILURE;
     }
 
@@ -62,14 +48,14 @@ main(int argc, char **argv)
   
   if (!read_rsa_key(argv[1], NULL, &key))
     {
-      fprintf(stderr, "Invalid key\n");
+      werror("Invalid key\n");
       return EXIT_FAILURE;
     }
 
   sha1_init(&hash);
   if (!hash_file(&nettle_sha1, &hash, stdin))
     {
-      fprintf(stderr, "Failed reading stdin: %s\n",
+      werror("Failed reading stdin: %s\n",
              strerror(errno));
       return 0;
     }
@@ -79,7 +65,7 @@ main(int argc, char **argv)
 
   if (!mpz_out_str(stdout, 16, s))
     {
-      fprintf(stderr, "Failed writing signature: %s\n",
+      werror("Failed writing signature: %s\n",
              strerror(errno));
       return 0;
     }
@@ -91,4 +77,3 @@ main(int argc, char **argv)
 
   return EXIT_SUCCESS;
 }
-#endif /* WITH_PUBLIC_KEY */
index 77e25694c5b8912f2ee7fbdc03cd266a1e1a1027..5dcd90b248965d441ecf7fa5343f23a93190783c 100644 (file)
  * MA 02111-1307, USA.
  */
 
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif /* HAVE_CONFIG_H */
 
-#if !WITH_PUBLIC_KEY
-int
-main(int argc, char **argv)
-{
-  fprintf(stderr,
-         "You need to install GMP somewhere where Nettle can find it,\n"
-         "and recompile Nettle\n");
-  return EXIT_FAILURE;
-}
-#else /* WITH_PUBLIC_KEY */
+#include "rsa.h"
+#include "io.h"
 
 #include <errno.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 
-#include "rsa.h"
-#include "io.h"
-
 static int
 read_signature(const char *name, mpz_t s)
 {
@@ -71,7 +57,7 @@ main(int argc, char **argv)
   
   if (argc != 3)
     {
-      fprintf(stderr, "Usage: rsa-sign PUBLIC-KEY SIGNATURE-FILE < file\n");
+      werror("Usage: rsa-sign PUBLIC-KEY SIGNATURE-FILE < file\n");
       return EXIT_FAILURE;
     }
 
@@ -79,7 +65,7 @@ main(int argc, char **argv)
   
   if (!read_rsa_key(argv[1], &key, NULL))
     {
-      fprintf(stderr, "Invalid key\n");
+      werror("Invalid key\n");
       return EXIT_FAILURE;
     }
 
@@ -87,7 +73,7 @@ main(int argc, char **argv)
 
   if (!read_signature(argv[2], s))
     {
-      fprintf(stderr, "Failed to read signature file `%s'\n",
+      werror("Failed to read signature file `%s'\n",
              argv[2]);
       return EXIT_FAILURE;
     }
@@ -95,14 +81,14 @@ main(int argc, char **argv)
   sha1_init(&hash);
   if (!hash_file(&nettle_sha1, &hash, stdin))
     {
-      fprintf(stderr, "Failed reading stdin: %s\n",
+      werror("Failed reading stdin: %s\n",
              strerror(errno));
       return 0;
     }
 
   if (!rsa_sha1_verify(&key, &hash, s))
     {
-      fprintf(stderr, "Invalid signature!\n");
+      werror("Invalid signature!\n");
       return EXIT_FAILURE;
     }
     
@@ -111,4 +97,3 @@ main(int argc, char **argv)
 
   return EXIT_SUCCESS;
 }
-#endif /* WITH_PUBLIC_KEY */