Class: JWT::JWA::HmacRbNaCl
- Inherits:
-
Object
- Object
- JWT::JWA::HmacRbNaCl
- Includes:
- SigningAlgorithm
- Defined in:
- lib/jwt/jwa/hmac_rbnacl.rb
Instance Attribute Summary
Attributes included from SigningAlgorithm
Instance Method Summary collapse
-
#initialize(alg, hmac) ⇒ HmacRbNaCl
constructor
A new instance of HmacRbNaCl.
- #sign(data:, signing_key:) ⇒ Object
- #verify(data:, signature:, verification_key:) ⇒ Object
Methods included from SigningAlgorithm
#header, included, #raise_sign_error!, #raise_verify_error!, #valid_alg?
Constructor Details
#initialize(alg, hmac) ⇒ HmacRbNaCl
Returns a new instance of HmacRbNaCl.
8 9 10 11 |
# File 'lib/jwt/jwa/hmac_rbnacl.rb', line 8 def initialize(alg, hmac) @alg = alg @hmac = hmac end |
Instance Method Details
#sign(data:, signing_key:) ⇒ Object
13 14 15 16 |
# File 'lib/jwt/jwa/hmac_rbnacl.rb', line 13 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
18 19 20 21 22 23 |
# File 'lib/jwt/jwa/hmac_rbnacl.rb', line 18 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 |