Permalink
Browse files

Support sodium_init()

Automatically call sodium_init() on startup in a Thread.exclusive block,
selecting the best available ciphers for the platform.
  • Loading branch information...
tarcieri committed Sep 10, 2013
1 parent ad1cd17 commit 25444979d161fa0f02a61a5003768c2173cfa2ee
Showing with 5 additions and 0 deletions.
  1. +3 −0 lib/rbnacl.rb
  2. +2 −0 lib/rbnacl/nacl.rb
@@ -42,5 +42,8 @@ class IncorrectPrimitiveError < ArgumentError; end
require "rbnacl/random_nonce_box"
require "rbnacl/test_vectors"
# Select platform-optimized versions of algorithms
Thread.exclusive { RbNaCl::NaCl.sodium_init }
# Perform self test on load
require "rbnacl/self_test"
@@ -46,6 +46,8 @@ def self.#{name}(*args)
eos
end
attach_function :sodium_init, [], :int
SHA256BYTES = 32
wrap_nacl_function :crypto_hash_sha256,
:crypto_hash_sha256_ref,

0 comments on commit 2544497

Please sign in to comment.