1OPENSSL_SECURE_MALLOC(3)            OpenSSL           OPENSSL_SECURE_MALLOC(3)
2
3
4

NAME

6       CRYPTO_secure_malloc_init, CRYPTO_secure_malloc_initialized,
7       CRYPTO_secure_malloc_done, OPENSSL_secure_malloc, CRYPTO_secure_malloc,
8       OPENSSL_secure_zalloc, CRYPTO_secure_zalloc, OPENSSL_secure_free,
9       CRYPTO_secure_free, OPENSSL_secure_clear_free,
10       CRYPTO_secure_clear_free, OPENSSL_secure_actual_size,
11       CRYPTO_secure_used - secure heap storage
12

SYNOPSIS

14        #include <openssl/crypto.h>
15
16        int CRYPTO_secure_malloc_init(size_t size, int minsize);
17
18        int CRYPTO_secure_malloc_initialized();
19
20        int CRYPTO_secure_malloc_done();
21
22        void *OPENSSL_secure_malloc(size_t num);
23        void *CRYPTO_secure_malloc(size_t num, const char *file, int line);
24
25        void *OPENSSL_secure_zalloc(size_t num);
26        void *CRYPTO_secure_zalloc(size_t num, const char *file, int line);
27
28        void OPENSSL_secure_free(void* ptr);
29        void CRYPTO_secure_free(void *ptr, const char *, int);
30
31        void OPENSSL_secure_clear_free(void* ptr, size_t num);
32        void CRYPTO_secure_clear_free(void *ptr, size_t num, const char *, int);
33
34        size_t OPENSSL_secure_actual_size(const void *ptr);
35
36        size_t CRYPTO_secure_used();
37

DESCRIPTION

39       In order to help protect applications (particularly long-running
40       servers) from pointer overruns or underruns that could return arbitrary
41       data from the program's dynamic memory area, where keys and other
42       sensitive information might be stored, OpenSSL supports the concept of
43       a "secure heap."  The level and type of security guarantees depend on
44       the operating system.  It is a good idea to review the code and see if
45       it addresses your threat model and concerns.
46
47       If a secure heap is used, then private key BIGNUM values are stored
48       there.  This protects long-term storage of private keys, but will not
49       necessarily put all intermediate values and computations there.
50
51       CRYPTO_secure_malloc_init() creates the secure heap, with the specified
52       "size" in bytes. The "minsize" parameter is the minimum size to
53       allocate from the heap. Both "size" and "minsize" must be a power of
54       two.
55
56       CRYPTO_secure_malloc_initialized() indicates whether or not the secure
57       heap as been initialized and is available.
58
59       CRYPTO_secure_malloc_done() releases the heap and makes the memory
60       unavailable to the process if all secure memory has been freed.  It can
61       take noticeably long to complete.
62
63       OPENSSL_secure_malloc() allocates "num" bytes from the heap.  If
64       CRYPTO_secure_malloc_init() is not called, this is equivalent to
65       calling OPENSSL_malloc().  It is a macro that expands to
66       CRYPTO_secure_malloc() and adds the "__FILE__" and "__LINE__"
67       parameters.
68
69       OPENSSL_secure_zalloc() and CRYPTO_secure_zalloc() are like
70       OPENSSL_secure_malloc() and CRYPTO_secure_malloc(), respectively,
71       except that they call memset() to zero the memory before returning.
72
73       OPENSSL_secure_free() releases the memory at "ptr" back to the heap.
74       It must be called with a value previously obtained from
75       OPENSSL_secure_malloc().  If CRYPTO_secure_malloc_init() is not called,
76       this is equivalent to calling OPENSSL_free().  It exists for
77       consistency with OPENSSL_secure_malloc() , and is a macro that expands
78       to CRYPTO_secure_free() and adds the "__FILE__" and "__LINE__"
79       parameters..
80
81       OPENSSL_secure_clear_free() is similar to OPENSSL_secure_free() except
82       that it has an additional "num" parameter which is used to clear the
83       memory if it was not allocated from the secure heap.  If
84       CRYPTO_secure_malloc_init() is not called, this is equivalent to
85       calling OPENSSL_clear_free().
86
87       OPENSSL_secure_actual_size() tells the actual size allocated to the
88       pointer; implementations may allocate more space than initially
89       requested, in order to "round up" and reduce secure heap fragmentation.
90
91       CRYPTO_secure_used() returns the number of bytes allocated in the
92       secure heap.
93

RETURN VALUES

95       CRYPTO_secure_malloc_init() returns 0 on failure, 1 if successful, and
96       2 if successful but the heap could not be protected by memory mapping.
97
98       CRYPTO_secure_malloc_initialized() returns 1 if the secure heap is
99       available (that is, if CRYPTO_secure_malloc_init() has been called, but
100       CRYPTO_secure_malloc_done() has not been called or failed) or 0 if not.
101
102       OPENSSL_secure_malloc() and OPENSSL_secure_zalloc() return a pointer
103       into the secure heap of the requested size, or "NULL" if memory could
104       not be allocated.
105
106       CRYPTO_secure_allocated() returns 1 if the pointer is in the secure
107       heap, or 0 if not.
108
109       CRYPTO_secure_malloc_done() returns 1 if the secure memory area is
110       released, or 0 if not.
111
112       OPENSSL_secure_free() and OPENSSL_secure_clear_free() return no values.
113

SEE ALSO

115       OPENSSL_malloc(3), BN_new(3)
116

HISTORY

118       The OPENSSL_secure_clear_free() function was added in OpenSSL 1.1.0g.
119
121       Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
122
123       Licensed under the OpenSSL license (the "License").  You may not use
124       this file except in compliance with the License.  You can obtain a copy
125       in the file LICENSE in the source distribution or at
126       <https://www.openssl.org/source/license.html>.
127
128
129
1301.1.1c                            2019-05-28          OPENSSL_SECURE_MALLOC(3)
Impressum