Class: Sodium::Auth
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Delegate
class_methods, included, #primitive
Constructor Details
#initialize(key) ⇒ Auth
Returns a new instance of Auth.
37
38
39
|
# File 'lib/sodium/auth.rb', line 37
def initialize(key)
@key = self.class._key(key)
end
|
Class Method Details
.auth(key, message) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/sodium/auth.rb', line 10
def self.auth(key, message)
key = self._key(key)
message = self._message(message)
Sodium::Buffer.empty self.implementation[:BYTES] do |authenticator|
self.implementation.nacl(
authenticator.to_ptr,
message .to_ptr,
message .bytesize,
key .to_ptr
) or raise Sodium::CryptoError, 'failed to generate an authenticator'
end
end
|
.key ⇒ Object
6
7
8
|
# File 'lib/sodium/auth.rb', line 6
def self.key
Sodium::Buffer.key self.implementation[:KEYBYTES]
end
|
.verify(key, message, authenticator) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/sodium/auth.rb', line 24
def self.verify(key, message, authenticator)
key = self._key(key)
message = self._message(message)
authenticator = self._authenticator(authenticator)
self.implementation.nacl_verify(
authenticator.to_ptr,
message .to_ptr,
message .bytesize,
key .to_ptr
)
end
|
Instance Method Details
#auth(message) ⇒ Object
41
42
43
|
# File 'lib/sodium/auth.rb', line 41
def auth(message)
self.class.auth(@key, message)
end
|
#verify(message, authenticator) ⇒ Object
45
46
47
|
# File 'lib/sodium/auth.rb', line 45
def verify(message, authenticator)
self.class.verify(@key, message, authenticator)
end
|