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_allocated, 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        int CRYPTO_secure_allocated(const void *ptr);
37        size_t CRYPTO_secure_used();
38

DESCRIPTION

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

RETURN VALUES

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

SEE ALSO

119       OPENSSL_malloc(3), BN_new(3)
120

HISTORY

122       The OPENSSL_secure_clear_free() function was added in OpenSSL 1.1.0g.
123
125       Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
126
127       Licensed under the OpenSSL license (the "License").  You may not use
128       this file except in compliance with the License.  You can obtain a copy
129       in the file LICENSE in the source distribution or at
130       <https://www.openssl.org/source/license.html>.
131
132
133
1341.1.1k                            2021-03-26          OPENSSL_SECURE_MALLOC(3)
Impressum