Allow reusable nonces.
This commit is contained in:
parent
8ed9f94ead
commit
2d0ed351ea
@ -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
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user