Fix crash in BN_rshift.
[oweals/openssl.git] / apps / ts.c
index b8fb50b3b58d64533219b1e283f256668befe3fb..edeab8231801ab2a53ed6a53be0a65ae7bd83edd 100644 (file)
--- a/apps/ts.c
+++ b/apps/ts.c
@@ -65,6 +65,7 @@
 #include <openssl/pem.h>
 #include <openssl/rand.h>
 #include <openssl/ts.h>
+#include <openssl/bn.h>
 
 #undef PROG
 #define PROG   ts_main
@@ -191,16 +192,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;
@@ -296,6 +287,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;
                }
@@ -1047,6 +1042,8 @@ static TS_VERIFY_CTX *create_verify_ctx(char *data, char *digest,
                if (!(request = d2i_TS_REQ_bio(input, NULL))) goto err;
                if (!(ctx = TS_REQ_to_TS_VERIFY_CTX(request, NULL))) goto err;
                }
+       else
+               return NULL;
 
        /* Add the signature verification flag and arguments. */
        ctx->flags |= TS_VFY_SIGNATURE;