We're getting a clash with C++ because it has a type called 'list'.
[openssl.git] / crypto / engine / eng_fat.c
index d49aa7ed408e900c003c98918b6c8254a1a95786..1539ea039f741ef7c420a639e30b6bc66febe7f6 100644 (file)
  * Hudson (tjh@cryptsoft.com).
  *
  */
+/* ====================================================================
+ * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
+ * ECDH support in OpenSSL originally developed by 
+ * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
+ */
 
 #include <openssl/crypto.h>
 #include "cryptlib.h"
@@ -66,25 +71,33 @@ int ENGINE_set_default(ENGINE *e, unsigned int flags)
        if((flags & ENGINE_METHOD_DIGESTS) && !ENGINE_set_default_digests(e))
                return 0;
 #ifndef OPENSSL_NO_RSA
-       if((flags & ENGINE_METHOD_RSA) & !ENGINE_set_default_RSA(e))
+       if((flags & ENGINE_METHOD_RSA) && !ENGINE_set_default_RSA(e))
                return 0;
 #endif
 #ifndef OPENSSL_NO_DSA
-       if((flags & ENGINE_METHOD_DSA) & !ENGINE_set_default_DSA(e))
+       if((flags & ENGINE_METHOD_DSA) && !ENGINE_set_default_DSA(e))
                return 0;
 #endif
 #ifndef OPENSSL_NO_DH
-       if((flags & ENGINE_METHOD_DH) & !ENGINE_set_default_DH(e))
+       if((flags & ENGINE_METHOD_DH) && !ENGINE_set_default_DH(e))
+               return 0;
+#endif
+#ifndef OPENSSL_NO_ECDH
+       if((flags & ENGINE_METHOD_ECDH) && !ENGINE_set_default_ECDH(e))
                return 0;
 #endif
-       if((flags & ENGINE_METHOD_RAND) & !ENGINE_set_default_RAND(e))
+#ifndef OPENSSL_NO_ECDSA
+       if((flags & ENGINE_METHOD_ECDSA) && !ENGINE_set_default_ECDSA(e))
+               return 0;
+#endif
+       if((flags & ENGINE_METHOD_RAND) && !ENGINE_set_default_RAND(e))
                return 0;
        return 1;
        }
 
 /* Set default algorithms using a string */
 
-int int_def_cb(const char *alg, int len, void *arg)
+static int int_def_cb(const char *alg, int len, void *arg)
        {
        unsigned int *pflags = arg;
        if (!strncmp(alg, "ALL", len))
@@ -93,6 +106,10 @@ int int_def_cb(const char *alg, int len, void *arg)
                *pflags |= ENGINE_METHOD_RSA;
        else if (!strncmp(alg, "DSA", len))
                *pflags |= ENGINE_METHOD_DSA;
+       else if (!strncmp(alg, "ECDH", len))
+               *pflags |= ENGINE_METHOD_ECDH;
+       else if (!strncmp(alg, "ECDSA", len))
+               *pflags |= ENGINE_METHOD_ECDSA;
        else if (!strncmp(alg, "DH", len))
                *pflags |= ENGINE_METHOD_DH;
        else if (!strncmp(alg, "RAND", len))
@@ -107,14 +124,14 @@ int int_def_cb(const char *alg, int len, void *arg)
        }
 
 
-int ENGINE_set_default_string(ENGINE *e, const char *list)
+int ENGINE_set_default_string(ENGINE *e, const char *def_list)
        {
        unsigned int flags = 0;
-       if (!CONF_parse_list(list, ',', 1, int_def_cb, &flags))
+       if (!CONF_parse_list(def_list, ',', 1, int_def_cb, &flags))
                {
                ENGINEerr(ENGINE_F_ENGINE_SET_DEFAULT_STRING,
                                        ENGINE_R_INVALID_STRING);
-               ERR_add_error_data(2, "str=",list);
+               ERR_add_error_data(2, "str=",def_list);
                return 0;
                }
        return ENGINE_set_default(e, flags);
@@ -132,6 +149,12 @@ int ENGINE_register_complete(ENGINE *e)
 #endif
 #ifndef OPENSSL_NO_DH
        ENGINE_register_DH(e);
+#endif
+#ifndef OPENSSL_NO_ECDH
+       ENGINE_register_ECDH(e);
+#endif
+#ifndef OPENSSL_NO_ECDSA
+       ENGINE_register_ECDSA(e);
 #endif
        ENGINE_register_RAND(e);
        return 1;