Make -CAcreateserial start from 1 instead of 0 for
[openssl.git] / apps / dgst.c
index 6d7a1787f4a12aec1e6f7b4f01397aa23d64bf4a..5f0506ed8cd6b65c4ceb797dd4fee994dd64563c 100644 (file)
@@ -1,5 +1,5 @@
 /* apps/dgst.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
  * This package is an SSL implementation written
 #include <string.h>
 #include <stdlib.h>
 #include "apps.h"
-#include "bio.h"
-#include "err.h"
-#include "evp.h"
-#include "objects.h"
-#include "x509.h"
-#include "pem.h"
+#include <openssl/bio.h>
+#include <openssl/err.h>
+#include <openssl/evp.h>
+#include <openssl/objects.h>
+#include <openssl/x509.h>
+#include <openssl/pem.h>
 
 #undef BUFSIZE
 #define BUFSIZE        1024*8
 #undef PROG
 #define PROG   dgst_main
 
-#ifndef NOPROTO
 void do_fp(unsigned char *buf,BIO *f,int sep);
-#else
-void do_fp();
-#endif
-
-int MAIN(argc,argv)
-int argc;
-char **argv;
+int MAIN(int argc, char **argv)
        {
        unsigned char *buf=NULL;
        int i,err=0;
-       EVP_MD *md=NULL,*m;
+       const EVP_MD *md=NULL,*m;
        BIO *in=NULL,*inp;
        BIO *bmd=NULL;
-       char *name;
+       const char *name;
 #define PROG_NAME_SIZE  16
-        char pname[PROG_NAME_SIZE];
+       char pname[PROG_NAME_SIZE];
        int separator=0;
        int debug=0;
 
@@ -103,16 +96,16 @@ char **argv;
                }
        if (bio_err == NULL)
                if ((bio_err=BIO_new(BIO_s_file())) != NULL)
-                       BIO_set_fp(bio_err,stderr,BIO_NOCLOSE);
+                       BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
 
        /* first check the program name */
-        program_name(argv[0],pname,PROG_NAME_SIZE);
+       program_name(argv[0],pname,PROG_NAME_SIZE);
 
        md=EVP_get_digestbyname(pname);
 
        argc--;
        argv++;
-       for (i=0; i<argc; i++)
+       while (argc > 0)
                {
                if ((*argv)[0] != '-') break;
                if (strcmp(*argv,"-c") == 0)
@@ -135,17 +128,19 @@ char **argv;
                BIO_printf(bio_err,"unknown option '%s'\n",*argv);
                BIO_printf(bio_err,"options are\n");
                BIO_printf(bio_err,"-c   to output the digest with separating colons\n");
-               BIO_printf(bio_err,"-c   to output debug info\n");
-               BIO_printf(bio_err,"-%3s to use the %s message digest alogorithm (default)\n",
+               BIO_printf(bio_err,"-d   to output debug info\n");
+               BIO_printf(bio_err,"-%3s to use the %s message digest algorithm (default)\n",
                        LN_md5,LN_md5);
-               BIO_printf(bio_err,"-%3s to use the %s message digest alogorithm\n",
+               BIO_printf(bio_err,"-%3s to use the %s message digest algorithm\n",
                        LN_md2,LN_md2);
-               BIO_printf(bio_err,"-%3s to use the %s message digest alogorithm\n",
+               BIO_printf(bio_err,"-%3s to use the %s message digest algorithm\n",
                        LN_sha1,LN_sha1);
-               BIO_printf(bio_err,"-%3s to use the %s message digest alogorithm\n",
+               BIO_printf(bio_err,"-%3s to use the %s message digest algorithm\n",
                        LN_sha,LN_sha);
-               BIO_printf(bio_err,"-%3s to use the %s message digest alogorithm\n",
+               BIO_printf(bio_err,"-%3s to use the %s message digest algorithm\n",
                        LN_mdc2,LN_mdc2);
+               BIO_printf(bio_err,"-%3s to use the %s message digest algorithm\n",
+                       LN_ripemd160,LN_ripemd160);
                err=1;
                goto end;
                }
@@ -187,7 +182,7 @@ char **argv;
                                }
                        printf("%s(%s)= ",name,argv[i]);
                        do_fp(buf,inp,separator);
-                       BIO_reset(bmd);
+                       (void)BIO_reset(bmd);
                        }
                }
 end:
@@ -201,10 +196,7 @@ end:
        EXIT(err);
        }
 
-void do_fp(buf,bp,sep)
-unsigned char *buf;
-BIO *bp;
-int sep;
+void do_fp(unsigned char *buf, BIO *bp, int sep)
        {
        int len;
        int i;