nskinkel / libredsalt

2 stars 1 forks source link

Fix #23 #28

Closed nskinkel closed 9 years ago

nskinkel commented 9 years ago

This PR uses the lazy_static crate to use a persistent OsRng instance in randombytes.rs. This lets of avoid creating a new OsRng on every randombytes call (i.e. opening/closing /dev/urandom on Linux or creating/destroying a crypto context on Windows).

In the future, we may want to consider implementing this in a custom way to be more efficient since we don't actually need the atomicity checks going on here, since tweetnacl itself is threadsafe.

This PR closes #23