Secret Key Authenticators
These provide a means of verifying the integrity of a message, but only with the knowledge of a shared key. This can be a preshared key, or one that is derived through some cryptographic protocol.
Constant Summary collapseNumber of bytes in a valid key
0
Number of bytes in a valid authenticator
0
Compute authenticator for message.
The number of key bytes for this Auth class.
The number bytes in the tag or authenticator from this Auth class.
Verifies the given authenticator with the message.
Compute authenticator for message.
A new authenticator, ready for auth and verification.
The number of key bytes for this Auth instance.
The crypto primitive for this authenticator instance.
The number of bytes in the tag or authenticator for this Auth instance.
Verifies the given authenticator with the message.
A new authenticator, ready for auth and verification
23 24 25
# File 'lib/rbnacl/auth.rb', line 23 def initialize(key) @key = Util.check_string(key, key_bytes, "#{self.class} key") endClass Method Details .auth(key, message) ⇒ String
Compute authenticator for message
33 34 35
# File 'lib/rbnacl/auth.rb', line 33 def self.auth(key, message) new(key).auth(message) end.key_bytes ⇒ Integer
The number of key bytes for this Auth class
88 89 90
# File 'lib/rbnacl/auth.rb', line 88 def self.key_bytes self::KEYBYTES end.tag_bytes ⇒ Integer
The number bytes in the tag or authenticator from this Auth class
102 103 104
# File 'lib/rbnacl/auth.rb', line 102 def self.tag_bytes self::BYTES end.verify(key, authenticator, message) ⇒ Boolean
Verifies the given authenticator with the message.
47 48 49
# File 'lib/rbnacl/auth.rb', line 47 def self.verify(key, authenticator, message) new(key).verify(authenticator, message) endInstance Method Details #auth(message) ⇒ String
Compute authenticator for message
56 57 58 59 60 61
# File 'lib/rbnacl/auth.rb', line 56 def auth(message) authenticator = Util.zeros(tag_bytes) message = message.to_str compute_authenticator(authenticator, message) authenticator end#key_bytes ⇒ Integer
The number of key bytes for this Auth instance
95 96 97
# File 'lib/rbnacl/auth.rb', line 95 def key_bytes self.class.key_bytes end#primitive ⇒ Symbol
The crypto primitive for this authenticator instance
81 82 83
# File 'lib/rbnacl/auth.rb', line 81 def primitive self.class.primitive end#tag_bytes ⇒ Integer
The number of bytes in the tag or authenticator for this Auth instance
109 110 111
# File 'lib/rbnacl/auth.rb', line 109 def tag_bytes self.class.tag_bytes end#verify(authenticator, message) ⇒ Boolean
Verifies the given authenticator with the message.
72 73 74 75 76
# File 'lib/rbnacl/auth.rb', line 72 def verify(authenticator, message) auth = authenticator.to_s Util.check_length(auth, tag_bytes, "Provided authenticator") verify_message(auth, message) || raise(BadAuthenticatorError, "Invalid authenticator provided, message is corrupt") end
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4