The new init functions can now fail so shouldn't be void
[openssl.git] / include / openssl / crypto.h
index a32f373724a55b6db05e661268296ad88d4878cf..d6cedecd60afee38f1c67fec1b384cd04937ee87 100644 (file)
@@ -1,6 +1,5 @@
-/* crypto/crypto.h */
 /* ====================================================================
- * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.
+ * Copyright (c) 1998-2016 The OpenSSL Project.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -206,7 +205,8 @@ extern "C" {
 # define CRYPTO_LOCK_COMP                38
 # define CRYPTO_LOCK_FIPS                39
 # define CRYPTO_LOCK_FIPS2               40
-# define CRYPTO_NUM_LOCKS                41
+# define CRYPTO_LOCK_INIT                41
+# define CRYPTO_NUM_LOCKS                42
 
 # define CRYPTO_LOCK             1
 # define CRYPTO_UNLOCK           2
@@ -273,15 +273,14 @@ DEFINE_STACK_OF(void)
 # define CRYPTO_EX_INDEX_X509_STORE_CTX   5
 # define CRYPTO_EX_INDEX_DH               6
 # define CRYPTO_EX_INDEX_DSA              7
-# define CRYPTO_EX_INDEX_ECDH             8
-# define CRYPTO_EX_INDEX_ECDSA            9
-# define CRYPTO_EX_INDEX_RSA             10
-# define CRYPTO_EX_INDEX_ENGINE          11
-# define CRYPTO_EX_INDEX_UI              12
-# define CRYPTO_EX_INDEX_BIO             13
-# define CRYPTO_EX_INDEX_STORE           14
-# define CRYPTO_EX_INDEX_APP             15
-# define CRYPTO_EX_INDEX__COUNT          16
+# define CRYPTO_EX_INDEX_EC_KEY           8
+# define CRYPTO_EX_INDEX_RSA              9
+# define CRYPTO_EX_INDEX_ENGINE          10
+# define CRYPTO_EX_INDEX_UI              11
+# define CRYPTO_EX_INDEX_BIO             12
+# define CRYPTO_EX_INDEX_STORE           13
+# define CRYPTO_EX_INDEX_APP             14
+# define CRYPTO_EX_INDEX__COUNT          15
 
 /*
  * This is the default callbacks, but we can have others as well: this is
@@ -314,6 +313,8 @@ int CRYPTO_mem_ctrl(int mode);
         CRYPTO_strndup(str, n, __FILE__, __LINE__)
 #  define OPENSSL_secure_malloc(num) \
         CRYPTO_secure_malloc(num, __FILE__, __LINE__)
+#  define OPENSSL_secure_zalloc(num) \
+        CRYPTO_secure_zalloc(num, __FILE__, __LINE__)
 #  define OPENSSL_secure_free(addr) \
         CRYPTO_secure_free(addr)
 #  define OPENSSL_secure_actual_size(ptr) \
@@ -339,6 +340,8 @@ int CRYPTO_mem_ctrl(int mode);
         CRYPTO_strndup(str, s, NULL, 0)
 #  define OPENSSL_secure_malloc(num) \
         CRYPTO_secure_malloc(num, NULL, 0)
+#  define OPENSSL_secure_zalloc(num) \
+        CRYPTO_secure_zalloc(num, NULL, 0)
 #  define OPENSSL_secure_free(addr) \
         CRYPTO_secure_free(addr)
 #  define OPENSSL_secure_actual_size(ptr) \
@@ -480,6 +483,7 @@ void *CRYPTO_clear_realloc(void *addr, size_t old_num, size_t num,
 int CRYPTO_secure_malloc_init(size_t sz, int minsize);
 void CRYPTO_secure_malloc_done(void);
 void *CRYPTO_secure_malloc(size_t num, const char *file, int line);
+void *CRYPTO_secure_zalloc(size_t num, const char *file, int line);
 void CRYPTO_secure_free(void *ptr);
 int CRYPTO_secure_allocated(const void *ptr);
 int CRYPTO_secure_malloc_initialized(void);
@@ -539,7 +543,64 @@ int OPENSSL_gmtime_diff(int *pday, int *psec,
  * into a defined order as the return value when a != b is undefined, other
  * than to be non-zero.
  */
-int CRYPTO_memcmp(const void *a, const void *b, size_t len);
+int CRYPTO_memcmp(const volatile void * volatile in_a,
+                  const volatile void * volatile in_b,
+                  size_t len);
+
+/* Standard initialisation options */
+# define OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS 0x000001
+# define OPENSSL_INIT_LOAD_CRYPTO_STRINGS    0x000002
+# define OPENSSL_INIT_ADD_ALL_CIPHERS        0x000004
+# define OPENSSL_INIT_ADD_ALL_DIGESTS        0x000008
+# define OPENSSL_INIT_NO_ADD_ALL_CIPHERS     0x000010
+# define OPENSSL_INIT_NO_ADD_ALL_DIGESTS     0x000020
+# define OPENSSL_INIT_LOAD_CONFIG            0x000040
+# define OPENSSL_INIT_NO_LOAD_CONFIG         0x000080
+# define OPENSSL_INIT_ASYNC                  0x000100
+# define OPENSSL_INIT_ENGINE_RDRAND          0x000200
+# define OPENSSL_INIT_ENGINE_DYNAMIC         0x000400
+# define OPENSSL_INIT_ENGINE_OPENSSL         0x000800
+# define OPENSSL_INIT_ENGINE_CRYPTODEV       0x001000
+# define OPENSSL_INIT_ENGINE_CAPI            0x002000
+# define OPENSSL_INIT_ENGINE_PADLOCK         0x004000
+# define OPENSSL_INIT_ENGINE_DASYNC          0x008000
+/* OPENSSL_INIT flag 0x010000 reserved for internal use */
+/* Max OPENSSL_INIT flag value is 0x80000000 */
+
+/* openssl and dasync not counted as builtin */
+# define OPENSSL_INIT_ENGINE_ALL_BUILTIN \
+    (OPENSSL_INIT_ENGINE_RDRAND | OPENSSL_INIT_ENGINE_DYNAMIC \
+    | OPENSSL_INIT_ENGINE_CRYPTODEV | OPENSSL_INIT_ENGINE_CAPI | \
+    OPENSSL_INIT_ENGINE_PADLOCK)
+
+
+
+/* Optional settings for initialisation */
+# define OPENSSL_INIT_SET_END                0
+# define OPENSSL_INIT_SET_CONF_FILENAME      1
+
+typedef struct ossl_init_settings_st {
+    int name;
+    union {
+        int type_int;
+        long type_long;
+        int32_t type_int32_t;
+        uint32_t type_uint32_t;
+        int64_t type_int64_t;
+        uint64_t type_uint64_t;
+        size_t type_size_t;
+        const char *type_string;
+        void *type_void_ptr;
+    } value;
+} OPENSSL_INIT_SETTINGS;
+
+typedef struct ossl_init_stop_st OPENSSL_INIT_STOP;
+
+/* Library initialisation functions */
+void OPENSSL_cleanup(void);
+int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+int OPENSSL_atexit(void (*handler)(void));
+void OPENSSL_thread_stop(void);
 
 /* BEGIN ERROR CODES */
 /*