typo
[openssl.git] / crypto / ec / ec_key.c
index 790d930225e3df6d854155ced0e235fd219e8e9b..aef3934c174562c808052dd37494c51f1c3f2eee 100644 (file)
  * Hudson (tjh@cryptsoft.com).
  *
  */
+/* ====================================================================
+ * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
+ * Portions originally developed by SUN MICROSYSTEMS, INC., and 
+ * contributed to the OpenSSL project.
+ */
 
+#include <string.h>
 #include "ec_lcl.h"
 #include <openssl/err.h>
+#include <string.h>
 
 EC_KEY *EC_KEY_new(void)
        {
@@ -111,7 +118,7 @@ void EC_KEY_free(EC_KEY *r)
        if (r->meth_data && r->meth_data->finish)
                r->meth_data->finish(r);
 
-       memset((void *)r, 0x0, sizeof(EC_KEY));
+       OPENSSL_cleanse((void *)r, sizeof(EC_KEY));
 
        OPENSSL_free(r);
        }
@@ -192,7 +199,7 @@ EC_KEY *EC_KEY_dup(const EC_KEY *eckey)
        /* copy the private key */
        if (eckey->priv_key)
                {
-               ret->priv_key = BN_dup(ret->priv_key);
+               ret->priv_key = BN_dup(eckey->priv_key);
                if (ret->priv_key == NULL)
                        ok = 0;
                }
@@ -210,6 +217,22 @@ EC_KEY *EC_KEY_dup(const EC_KEY *eckey)
        return ret;
        }
 
+int EC_KEY_up_ref(EC_KEY *r)
+       {
+       int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_EC);
+#ifdef REF_PRINT
+       REF_PRINT("EC_KEY",r);
+#endif
+#ifdef REF_CHECK
+       if (i < 2)
+               {
+               fprintf(stderr, "EC_KEY_up, bad reference count\n");
+               abort();
+               }
+#endif
+       return ((i > 1) ? 1 : 0);
+       }
+
 int EC_KEY_generate_key(EC_KEY *eckey)
        {       
        int     ok = 0;