Document supported curve functions.
[openssl.git] / crypto / cryptlib.c
index 8384b5d339e062185ea406670d992cf7298ca063..304c6b70627b2aeb88abe71a6863cfef2302bd6f 100644 (file)
@@ -504,7 +504,7 @@ void CRYPTO_THREADID_current(CRYPTO_THREADID *id)
        CRYPTO_THREADID_set_numeric(id, (unsigned long)find_thread(NULL));
 #else
        /* For everything else, default to using the address of 'errno' */
-       CRYPTO_THREADID_set_pointer(id, &errno);
+       CRYPTO_THREADID_set_pointer(id, (void*)&errno);
 #endif
        }
 
@@ -693,14 +693,18 @@ void OPENSSL_cpuid_setup(void)
     if (trigger)       return;
 
     trigger=1;
-    if ((env=getenv("OPENSSL_ia32cap")))
+    if ((env=getenv("OPENSSL_ia32cap"))) {
+       int off = (env[0]=='~')?1:0;
 #if defined(_WIN32)
-    {  if (!sscanf(env,"%I64i",&vec)) vec = strtoul(env,NULL,0);   }
+       if (!sscanf(env+off,"%I64i",&vec)) vec = strtoul(env+off,NULL,0);
 #else
-       vec = strtoull(env,NULL,0);
+       if (!sscanf(env+off,"%lli",(long long *)&vec)) vec = strtoul(env+off,NULL,0);
 #endif
+       if (off) vec = OPENSSL_ia32_cpuid()&~vec;
+    }
     else
        vec = OPENSSL_ia32_cpuid();
+
     /*
      * |(1<<10) sets a reserved bit to signal that variable
      * was initialized already... This is to avoid interference
@@ -921,3 +925,16 @@ void OpenSSLDie(const char *file,int line,const char *assertion)
        }
 
 void *OPENSSL_stderr(void)     { return stderr; }
+
+int CRYPTO_memcmp(const void *in_a, const void *in_b, size_t len)
+       {
+       size_t i;
+       const unsigned char *a = in_a;
+       const unsigned char *b = in_b;
+       unsigned char x = 0;
+
+       for (i = 0; i < len; i++)
+               x |= a[i] ^ b[i];
+
+       return x;
+       }