-
Notifications
You must be signed in to change notification settings - Fork 706
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c6cace9
commit 0392a51
Showing
5 changed files
with
26 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
# Initialization and Teardown | ||
The s2n-tls library must be initialized with `s2n_init()` before calling most library functions. `s2n_init()` MUST NOT be called more than once, even when an application uses multiple threads or processes. s2n attempts to clean up its thread-local memory at thread-exit and all other memory at process-exit. However, this may not work if you are using a thread library other than pthreads or other threads using s2n outlive the thread that called `s2n_init()`. In that case you should call `s2n_cleanup_thread()` from every thread or process created after `s2n_init()`. | ||
|
||
> Note: `s2n_cleanup_thread()` is currently considered unstable, meaning the API is subject to change in a future release. To access this API, include `api/unstable/cleanup.h`. | ||
## Initialization | ||
The s2n-tls library must be initialized with `s2n_init()` before using the library functions. `s2n_init()` will error if it is called more than once per process. | ||
|
||
Initialization can be modified by calling `s2n_crypto_disable_init()` or `s2n_disable_atexit()` before `s2n_init()`. | ||
|
||
An application can override s2n-tls’s internal memory management by calling `s2n_mem_set_callbacks` before calling s2n_init. | ||
An application can override s2n-tls’s internal memory management by calling `s2n_mem_set_callbacks` before calling `s2n_init()`. | ||
|
||
If you are trying to use FIPS mode, you must enable FIPS in your libcrypto library (probably by calling `FIPS_mode_set(1)`) before calling `s2n_init()`. | ||
|
||
## Teardown | ||
### Thread-local Memory | ||
s2n has thread-local memory that it attempts to clean up automatically at thread-exit. This is done using pthread destructors and may not work if you are using a threads library other than pthreads. You can call `s2n_cleanup()` from every thread or process created after `s2n_init()` if you notice thread-local memory leaks. | ||
|
||
### Library Cleanup | ||
A full cleanup and de-initialization of the library can be done by calling `s2n_cleanup_final()`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ | |
int s2n_init(void); | ||
int s2n_cleanup(void); | ||
bool s2n_is_initialized(void); | ||
int s2n_enable_atexit(void); |