Allow reusable nonces.

This commit is contained in:
Didactic Drunk 2019-08-06 22:56:49 -07:00
parent 8ed9f94ead
commit 2d0ed351ea
2 changed files with 6 additions and 4 deletions

View File

@ -43,7 +43,7 @@ loop do
loop do loop do
# p pwhash # p pwhash
t = Time.measure { pwhash.store pass }.to_f t = Time.measure { pwhash.create pass }.to_f
ostr = "%7d" % pwhash.opslimit ostr = "%7d" % pwhash.opslimit
header << ostr if data.size == 2 header << ostr if data.size == 2
if t >= time_min if t >= time_min

View File

@ -10,8 +10,10 @@ module Sodium
NONCE_SIZE = LibSodium::NONCE_SIZE.to_i NONCE_SIZE = LibSodium::NONCE_SIZE.to_i
getter? used getter? used = false
@used = false
# Only use with single use keys.
property? reusable = false
# Returns bytes # Returns bytes
delegate to_slice, to: @bytes delegate to_slice, to: @bytes
@ -37,7 +39,7 @@ module Sodium
def used! def used!
raise Error::Reused.new("attempted nonce reuse") if @used raise Error::Reused.new("attempted nonce reuse") if @used
@used = true @used = true unless @reusable
end end
end end
end end