Add more information about thread safety until we provide a thread-safe API.

This commit is contained in:
Frank Denis 2013-04-26 17:27:55 -07:00
parent 1b87626e9f
commit edc5faffd6
5 changed files with 27 additions and 1 deletions

View File

@ -94,7 +94,7 @@ Sodium also provides helper functions to generate random numbers,
leveraging `/dev/urandom` or `/dev/random` on *nix and the cryptographic
service provider on Windows. The interface is similar to
`arc4random(3)`. It is `fork(2)`-safe but not thread-safe. This holds
true for `crypto_sign_keypair()` as well.
true for `crypto_sign_keypair()` and `crypto_box_keypair()` as well.
uint32_t randombytes_random(void);

View File

@ -1,6 +1,13 @@
#ifndef crypto_box_H
#define crypto_box_H
/*
* THREAD SAFETY: crypto_box_keypair() is thread-safe,
* provided that you called sodium_init() once before using any
* other libsodium function.
* Other functions are always thread-safe.
*/
#include <stdlib.h>
#include "crypto_box_curve25519xsalsa20poly1305.h"

View File

@ -1,6 +1,13 @@
#ifndef crypto_sign_H
#define crypto_sign_H
/*
* THREAD SAFETY: crypto_sign_keypair() is thread-safe,
* provided that you called sodium_init() once before using any
* other libsodium function.
* Other functions, including crypto_sign_seed_keypair() are always thread-safe.
*/
#include <stdlib.h>
#include "crypto_sign_ed25519.h"

View File

@ -2,6 +2,12 @@
#ifndef randombytes_salsa20_random_H
#define randombytes_salsa20_random_H
/*
* THREAD SAFETY: randombytes_salsa20_random*() functions are
* fork()-safe but not thread-safe.
* Always wrap them in a mutex if you need thread safety.
*/
#include <stdint.h>
#include <stdlib.h>

View File

@ -2,6 +2,12 @@
#ifndef randombytes_sysrandom_H
#define randombytes_sysrandom_H
/*
* THREAD SAFETY: randombytes_sysrandom() functions are thread-safe,
* provided that you called sodium_init() once before using any
* other libsodium function.
*/
#include <stdint.h>
#include <stdlib.h>