module Crypto::PwHash::ScryptSalsa208SHA256
Constants
- MEMLIMIT_INTERACTIVE
- MEMLIMIT_SENSITIVE
- OPSLIMIT_INTERACTIVE
- OPSLIMIT_SENSITIVE
- PRIMITIVE
- SALTBYTES
- STRBYTES
- STRPREFIX
Public Class Methods
crypto_pwhash_scryptsalsa208sha256_primitive()
click to toggle source
# File lib/crypto/pw_hash/scrypt_salsa208_sha256.rb, line 18 def crypto_pwhash_scryptsalsa208sha256_primitive PRIMITIVE end
Also aliased as: primitive
Public Instance Methods
salt()
click to toggle source
# File lib/crypto/pw_hash/scrypt_salsa208_sha256.rb, line 47 def salt RandomBytes.buf(SALTBYTES) end
scryptsalsa208sha256(outlen, passwd, salt, opslimit = OPSLIMIT_INTERACTIVE, memlimit = MEMLIMIT_INTERACTIVE)
click to toggle source
# File lib/crypto/pw_hash/scrypt_salsa208_sha256.rb, line 51 def scryptsalsa208sha256(outlen, passwd, salt, opslimit = OPSLIMIT_INTERACTIVE, memlimit = MEMLIMIT_INTERACTIVE) check_length(salt, SALTBYTES, :Salt) out = Sodium::SecretBuffer.new(outlen) if crypto_pwhash_scryptsalsa208sha256(out, outlen, passwd, passwd.bytesize, salt, opslimit, memlimit) == -1 raise NoMemoryError, "Failed to allocate memory max size=#{memlimit} bytes", caller end out.noaccess out end
str(passwd, opslimit = OPSLIMIT_INTERACTIVE, memlimit = MEMLIMIT_INTERACTIVE)
click to toggle source
# File lib/crypto/pw_hash/scrypt_salsa208_sha256.rb, line 63 def str(passwd, opslimit = OPSLIMIT_INTERACTIVE, memlimit = MEMLIMIT_INTERACTIVE) hashed_password = zeros(STRBYTES) if crypto_pwhash_scryptsalsa208sha256_str(hashed_password, passwd, passwd.bytesize, opslimit, memlimit) == -1 raise NoMemoryError, "Failed to allocate memory max size=#{memlimit} bytes", caller end hashed_password.chop! end
str_verify(str, passwd)
click to toggle source
# File lib/crypto/pw_hash/scrypt_salsa208_sha256.rb, line 72 def str_verify(str, passwd) check_length(str, STRBYTES - 1, :Str) crypto_pwhash_scryptsalsa208sha256_str_verify(str, passwd, passwd.bytesize) == 0 end