Class: JWT::JWA::HmacRbNaCl
Instance Attribute Summary
#alg
Class Method Summary
collapse
Instance Method Summary
collapse
#header, included, #raise_sign_error!, #raise_verify_error!, #valid_alg?
Constructor Details
#initialize(alg, hmac) ⇒ HmacRbNaCl
Returns a new instance of HmacRbNaCl.
12
13
14
15
|
# File 'lib/jwt/jwa/hmac_rbnacl.rb', line 12
def initialize(alg, hmac)
@alg = alg
@hmac = hmac
end
|
Class Method Details
.from_algorithm(algorithm) ⇒ Object
8
9
10
|
# File 'lib/jwt/jwa/hmac_rbnacl.rb', line 8
def self.from_algorithm(algorithm)
new(algorithm, ::RbNaCl::HMAC.const_get(algorithm.upcase.gsub('HS', 'SHA')))
end
|
Instance Method Details
#sign(data:, signing_key:) ⇒ Object
17
18
19
20
|
# File 'lib/jwt/jwa/hmac_rbnacl.rb', line 17
def sign(data:, signing_key:)
Deprecations.warning("The use of the algorithm #{alg} is deprecated and will be removed in the next major version of ruby-jwt")
hmac.auth(key_for_rbnacl(hmac, signing_key).encode('binary'), data.encode('binary'))
end
|
#verify(data:, signature:, verification_key:) ⇒ Object
22
23
24
25
26
27
|
# File 'lib/jwt/jwa/hmac_rbnacl.rb', line 22
def verify(data:, signature:, verification_key:)
Deprecations.warning("The use of the algorithm #{alg} is deprecated and will be removed in the next major version of ruby-jwt")
hmac.verify(key_for_rbnacl(hmac, verification_key).encode('binary'), signature.encode('binary'), data.encode('binary'))
rescue ::RbNaCl::BadAuthenticatorError, ::RbNaCl::LengthError
false
end
|