1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-23 20:15:19 -07:00
libsodium/README.markdown

111 lines
3.5 KiB
Markdown
Raw Normal View History

2013-01-31 00:24:04 -07:00
![libsodium](https://raw.github.com/jedisct1/libsodium/logo.png)
2013-01-31 00:16:54 -07:00
============
2013-01-20 01:03:34 -07:00
2013-01-20 17:56:17 -07:00
[NaCl](http://nacl.cr.yp.to/) (pronounced "salt") is a new easy-to-use
high-speed software library for network communication, encryption,
decryption, signatures, etc.
2013-01-20 01:03:34 -07:00
2013-01-20 17:56:17 -07:00
NaCl's goal is to provide all of the core operations needed to build
higher-level cryptographic tools.
2013-01-20 17:58:41 -07:00
Sodium is a portable, cross-compilable, installable, packageable,
API-compatible version of NaCl.
2013-01-20 17:56:17 -07:00
2013-01-21 21:34:14 -07:00
## Portability
2013-01-20 17:56:17 -07:00
In order to pick the fastest working implementation of each primitive,
NaCl performs tests and benchmarks at compile-time. Unfortunately, the
resulting library is not garanteed to work on different hardware.
Sodium only ships portable reference implementations.
2013-01-20 17:56:17 -07:00
Optimized implementations (including NEON optimizations) will eventually
be supported, but tests and benchmarks will be performed at run-time,
so that the same binary package can still run everywhere.
Sodium is tested on a variety of compilers and operating systems,
including Windows, iOS and Android.
2013-01-21 21:34:14 -07:00
## Installation
2013-01-20 17:56:17 -07:00
Sodium is a shared library with a machine-independant set of
headers, so that it can easily be used by 3rd party projects.
The library is built using autotools, making it easy to package.
Installation is trivial, and both compilation and testing can take
2013-01-21 21:34:14 -07:00
advantage of multiple CPU cores.
Download a
[tarball of libsodium](http://download.dnscrypt.org/libsodium/releases/),
2013-01-21 21:34:14 -07:00
then follow the ritual:
2013-01-20 17:56:17 -07:00
./configure
make && make check && make install
2013-01-20 17:56:17 -07:00
## Comparison with vanilla NaCl
2013-01-20 17:57:26 -07:00
Sodium does not ship C++ bindings. These might be part of a distinct
package.
2013-01-20 17:56:17 -07:00
The default public-key signature system in NaCl was a prototype that
shouldn't be used any more.
Sodium ships with the SUPERCOP reference implementation of
[Ed25519](http://ed25519.cr.yp.to/), and uses this system by default
for `crypto_sign*` operations.
For backward compatibility, the previous system is still compiled in,
as `crypto_sign_edwards25519sha512batch*`.
## Additional features
The Sodium library provides some convenience functions in order to retrieve
the current version of the library:
const char *sodium_version_string(void);
const int sodium_version_major(void);
const int sodium_version_minor(void);
Headers are installed in `${prefix}/include/sodium`.
A convenience header includes everything you need to use the library:
#include <sodium.h>
2013-01-20 13:10:51 -07:00
2013-01-21 15:15:23 -07:00
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.
uint32_t randombytes_random(void);
Return a random 32-bit unsigned value.
void randombytes_stir(void);
Generate a new key for the pseudorandom number generator. The file
descriptor for the entropy source is kept open, so that the generator
can be reseeded even in a chroot() jail.
uint32_t randombytes_uniform(const uint32_t upper_bound);
Return a value between 0 and upper_bound using a uniform distribution.
void randombytes_buf(void * const buf, const size_t size);
Fill the buffer `buf` with `size` random bytes.
int randombytes_close(void);
Close the file descriptor or the handle for the cryptographic service
provider.
A custom implementation of these functions can be registered with
`randombytes_set_implementation()`.
2013-01-21 20:57:11 -07:00
## Bindings for other languages
* Ruby: [RbNaCl](https://github.com/cryptosphere/rbnacl)