Previously, the default RSA_METHOD was NULL until the first RSA structure was
authorGeoff Thorpe <geoff@openssl.org>
Thu, 20 Apr 2000 06:44:18 +0000 (06:44 +0000)
committerGeoff Thorpe <geoff@openssl.org>
Thu, 20 Apr 2000 06:44:18 +0000 (06:44 +0000)
initialised, at which point an appropriate default was chosen. This meant a
call to RSA_get_default_method might have returned FALSE.

This change fixes that; now any called to RSA_new(), RSA_new_method(NULL), or
RSA_get_default_method() will ensure that a default is chosen if it wasn't
already.

CHANGES
crypto/rsa/rsa_lib.c

diff --git a/CHANGES b/CHANGES
index 03b1f0059eabbfb445494578833700dca19255b4..71587e2494d851dbcd2305a25e8a82ee4865d4fe 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,13 @@
 
  Changes between 0.9.5a and 0.9.6  [xx XXX 2000]
 
+  *) RSA_get_default_method() will now cause a default
+     RSA_METHOD to be chosen if one doesn't exist already.
+     Previously this was only set during a call to RSA_new()
+     or RSA_new_method(NULL) meaning it was possible for
+     RSA_get_default_method() to return NULL.
+     [Geoff Thorpe]
+
   *) Added native name translation to the existing DSO code
      that will convert (if the flag to do so is set) filenames
      that are sufficiently small and have no path information
index 074a4f5074b44e4b8aab81ef7cd9ced2bffd5ebd..88d93a46ddbdca1f4d8bcce504b2cee762ca74c8 100644 (file)
@@ -81,6 +81,19 @@ void RSA_set_default_method(RSA_METHOD *meth)
 
 RSA_METHOD *RSA_get_default_method(void)
 {
+       if (default_RSA_meth == NULL)
+               {
+#ifdef RSA_NULL
+               default_RSA_meth=RSA_null_method();
+#else
+#ifdef RSAref
+               default_RSA_meth=RSA_PKCS1_RSAref();
+#else
+               default_RSA_meth=RSA_PKCS1_SSLeay();
+#endif
+#endif
+               }
+
        return default_RSA_meth;
 }
 
@@ -103,18 +116,6 @@ RSA *RSA_new_method(RSA_METHOD *meth)
        {
        RSA *ret;
 
-       if (default_RSA_meth == NULL)
-               {
-#ifdef RSA_NULL
-               default_RSA_meth=RSA_null_method();
-#else
-#ifdef RSAref
-               default_RSA_meth=RSA_PKCS1_RSAref();
-#else
-               default_RSA_meth=RSA_PKCS1_SSLeay();
-#endif
-#endif
-               }
        ret=(RSA *)Malloc(sizeof(RSA));
        if (ret == NULL)
                {
@@ -123,7 +124,7 @@ RSA *RSA_new_method(RSA_METHOD *meth)
                }
 
        if (meth == NULL)
-               ret->meth=default_RSA_meth;
+               ret->meth=RSA_get_default_method();
        else
                ret->meth=meth;