TS bugfixes: Do not hardcode message digest algorithms; fix ASN1 decoding.
[openssl.git] / apps / ts.c
index 7edd538..0083f9a 100644 (file)
--- a/apps/ts.c
+++ b/apps/ts.c
@@ -118,6 +118,7 @@ static X509_STORE *create_cert_store(char *ca_path, char *ca_file);
 static int MS_CALLBACK verify_cb(int ok, X509_STORE_CTX *ctx);
 
 /* Main function definition. */
+int MAIN(int, char **);
 
 int MAIN(int argc, char **argv)
        {
@@ -190,16 +191,6 @@ int MAIN(int argc, char **argv)
                        if (argc-- < 1) goto usage;
                        digest = *++argv;
                        }
-               else if (strcmp(*argv, "-md2") == 0
-                       || strcmp(*argv, "-md4") == 0
-                       || strcmp(*argv, "-md5") == 0
-                       || strcmp(*argv, "-sha") == 0
-                       || strcmp(*argv, "-sha1") == 0
-                       || strcmp(*argv, "-mdc2") == 0
-                       || strcmp(*argv, "-ripemd160") == 0)
-                       {
-                       md = EVP_get_digestbyname(*argv + 1);
-                       }
                else if (strcmp(*argv, "-rand") == 0)
                        {
                        if (argc-- < 1) goto usage;
@@ -295,6 +286,10 @@ int MAIN(int argc, char **argv)
                        if (argc-- < 1) goto usage;
                        engine = *++argv;
                        }
+               else if ((md = EVP_get_digestbyname(*argv + 1)) != NULL)
+                       {
+                       /* empty. */
+                       }
                else
                        goto usage;
                }