Add default Sodium::Pwhash algorithm.

This commit is contained in:
Didactic Drunk 2019-08-24 14:15:37 -07:00
parent ac15f86705
commit 2dda619026
3 changed files with 8 additions and 0 deletions

View File

@ -36,6 +36,7 @@ module Sodium
fun crypto_pwhash_saltbytes : LibC::SizeT fun crypto_pwhash_saltbytes : LibC::SizeT
fun crypto_pwhash_bytes_min : LibC::SizeT fun crypto_pwhash_bytes_min : LibC::SizeT
fun crypto_pwhash_bytes_max : 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_statebytes : LibC::SizeT
fun crypto_generichash_blake2b_bytes : LibC::SizeT fun crypto_generichash_blake2b_bytes : LibC::SizeT
fun crypto_generichash_blake2b_bytes_min : LibC::SizeT fun crypto_generichash_blake2b_bytes_min : LibC::SizeT

View File

@ -29,6 +29,11 @@ module Sodium
enum Mode enum Mode
Argon2i13 = 1 Argon2i13 = 1
Argon2id13 = 2 Argon2id13 = 2
# The current libsodium default algorithm that may change between versions.
def default
Mode.new LibSodium.crypto_pwhash_alg_default
end
end end
property opslimit = OPSLIMIT_INTERACTIVE property opslimit = OPSLIMIT_INTERACTIVE

View File

@ -82,10 +82,12 @@ module Sodium
self self
end end
# Timing safe memory compare.
def ==(other : self) def ==(other : self)
Sodium.memcmp self.to_slice, other.to_slice Sodium.memcmp self.to_slice, other.to_slice
end end
# Timing safe memory compare.
def ==(other : Bytes) def ==(other : Bytes)
Sodium.memcmp self.to_slice, other Sodium.memcmp self.to_slice, other
end end