module Crypto::OneTimeAuth
Constants
- BYTES
- KEYBYTES
- PRIMITIVE
Public Instance Methods
final(state)
click to toggle source
# File lib/crypto/one_time_auth.rb, line 72 def final(state) mac = zeros(BYTES) crypto_onetimeauth_final(state, mac) mac end
init(key)
click to toggle source
# File lib/crypto/one_time_auth.rb, line 56 def init(key) check_length(key, KEYBYTES, :SecretKey) state = State.new key.readonly if key.is_a?(Sodium::SecretBuffer) crypto_onetimeauth_init(state, key) state ensure key.noaccess if key.is_a?(Sodium::SecretBuffer) end
onetimeauth(message, key)
click to toggle source
# File lib/crypto/one_time_auth.rb, line 34 def onetimeauth(message, key) check_length(key, KEYBYTES, :SecretKey) mac = zeros(BYTES) key.readonly if key.is_a?(Sodium::SecretBuffer) crypto_onetimeauth(mac, message, get_size(message), key) mac ensure key.noaccess if key.is_a?(Sodium::SecretBuffer) end
update(state, message)
click to toggle source
# File lib/crypto/one_time_auth.rb, line 68 def update(state, message) crypto_onetimeauth_update(state, message, get_size(message)) end
verify(mac, message, key)
click to toggle source
# File lib/crypto/one_time_auth.rb, line 46 def verify(mac, message, key) check_length(mac, BYTES, :Mac) check_length(key, KEYBYTES, :SecretKey) key.readonly if key.is_a?(Sodium::SecretBuffer) crypto_onetimeauth_verify(mac, message, get_size(message), key) == 0 ensure key.noaccess if key.is_a?(Sodium::SecretBuffer) end