diff --git a/src/sodium/lib_sodium.cr b/src/sodium/lib_sodium.cr index d782f36..ad27abb 100644 --- a/src/sodium/lib_sodium.cr +++ b/src/sodium/lib_sodium.cr @@ -36,6 +36,7 @@ module Sodium fun crypto_pwhash_saltbytes : LibC::SizeT fun crypto_pwhash_bytes_min : LibC::SizeT fun crypto_pwhash_bytes_max : LibC::SizeT + fun crypto_pwhash_alg_default : LibC::Int fun crypto_generichash_blake2b_statebytes : LibC::SizeT fun crypto_generichash_blake2b_bytes : LibC::SizeT fun crypto_generichash_blake2b_bytes_min : LibC::SizeT diff --git a/src/sodium/pwhash.cr b/src/sodium/pwhash.cr index ff011e1..27b2e6d 100644 --- a/src/sodium/pwhash.cr +++ b/src/sodium/pwhash.cr @@ -29,6 +29,11 @@ module Sodium enum Mode Argon2i13 = 1 Argon2id13 = 2 + + # The current libsodium default algorithm that may change between versions. + def default + Mode.new LibSodium.crypto_pwhash_alg_default + end end property opslimit = OPSLIMIT_INTERACTIVE diff --git a/src/sodium/secure_buffer.cr b/src/sodium/secure_buffer.cr index ded73a8..859342b 100644 --- a/src/sodium/secure_buffer.cr +++ b/src/sodium/secure_buffer.cr @@ -82,10 +82,12 @@ module Sodium self end + # Timing safe memory compare. def ==(other : self) Sodium.memcmp self.to_slice, other.to_slice end + # Timing safe memory compare. def ==(other : Bytes) Sodium.memcmp self.to_slice, other end