In RSA, DSA, DH, and RAND - if the "***_new()" function fails because the
authorGeoff Thorpe <geoff@openssl.org>
Mon, 30 Apr 2001 15:24:41 +0000 (15:24 +0000)
committerGeoff Thorpe <geoff@openssl.org>
Mon, 30 Apr 2001 15:24:41 +0000 (15:24 +0000)
ENGINE code does not return a default, set an error.

crypto/dh/dh_lib.c
crypto/dsa/dsa_lib.c
crypto/rand/rand.h
crypto/rand/rand_err.c
crypto/rand/rand_lib.c
crypto/rsa/rsa_lib.c

index c0a2472751f600d5162c50437b953c4c7f8f49f2..b3c609e8be08127014384e323b3b41438047556a 100644 (file)
@@ -148,6 +148,7 @@ DH *DH_new_method(ENGINE *engine)
                {
                if((ret->engine=ENGINE_get_default_DH()) == NULL)
                        {
+                       DHerr(DH_F_DH_NEW,ERR_LIB_ENGINE);
                        OPENSSL_free(ret);
                        return NULL;
                        }
index 2abdd08c9066f29aca7fa2ccd40cf00642c6d875..1b33705f46357721761b431b1a59d55f215c0f9b 100644 (file)
@@ -152,6 +152,7 @@ DSA *DSA_new_method(ENGINE *engine)
                {
                if((ret->engine=ENGINE_get_default_DSA()) == NULL)
                        {
+                       DSAerr(DSA_F_DSA_NEW,ERR_LIB_ENGINE);
                        OPENSSL_free(ret);
                        return NULL;
                        }
index 2252186ecdec8d40e17f88bac876eb51b7867c9c..0bfccac18f7fcb3957edd248f85af2927e6071c4 100644 (file)
@@ -96,7 +96,6 @@ int RAND_status(void);
 int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);
 int RAND_egd(const char *path);
 int RAND_egd_bytes(const char *path,int bytes);
-void ERR_load_RAND_strings(void);
 int RAND_poll(void);
 
 #if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
@@ -110,10 +109,12 @@ int RAND_event(UINT, WPARAM, LPARAM);
 /* The following lines are auto generated by the script mkerr.pl. Any changes
  * made after this point may be overwritten when the script is next run.
  */
+void ERR_load_RAND_strings(void);
 
 /* Error codes for the RAND functions. */
 
 /* Function codes. */
+#define RAND_F_RAND_GET_RAND_METHOD                     101
 #define RAND_F_SSLEAY_RAND_BYTES                        100
 
 /* Reason codes. */
@@ -123,4 +124,3 @@ int RAND_event(UINT, WPARAM, LPARAM);
 }
 #endif
 #endif
-
index 6ffa1c4f25da4a9f3cff0cda202f4d0ee448ece0..b77267e213bae3553b19fee6a06775afcfed0c81 100644 (file)
@@ -66,6 +66,7 @@
 #ifndef OPENSSL_NO_ERR
 static ERR_STRING_DATA RAND_str_functs[]=
        {
+{ERR_PACK(0,RAND_F_RAND_GET_RAND_METHOD,0),    "RAND_get_rand_method"},
 {ERR_PACK(0,RAND_F_SSLEAY_RAND_BYTES,0),       "SSLEAY_RAND_BYTES"},
 {0,NULL}
        };
index 597c098d3e389119edae8154e7a2aa29debc3997..38cea799380cc49af62e69fcdb4e8b51fd072dd5 100644 (file)
@@ -58,6 +58,7 @@
 
 #include <stdio.h>
 #include <time.h>
+#include "cryptlib.h"
 #include <openssl/rand.h>
 #include <openssl/engine.h>
 
@@ -86,7 +87,10 @@ const RAND_METHOD *RAND_get_rand_method(void)
        {
        if (rand_engine == NULL
                && (rand_engine = ENGINE_get_default_RAND()) == NULL)
+               {
+               RANDerr(RAND_F_RAND_GET_RAND_METHOD,ERR_LIB_ENGINE);
                return NULL;
+               }
        return ENGINE_get_RAND(rand_engine);
        }
 
index d3a602f0a5be91bb9944b03c03e6b77760850f9d..3a4760c8d4e31ae4a54d441e8f246d3552184ba2 100644 (file)
@@ -166,6 +166,7 @@ RSA *RSA_new_method(ENGINE *engine)
                {
                if((ret->engine=ENGINE_get_default_RSA()) == NULL)
                        {
+                       RSAerr(RSA_F_RSA_NEW_METHOD,ERR_LIB_ENGINE);
                        OPENSSL_free(ret);
                        return NULL;
                        }