Class: LightJWT::JWA::JWS::BaseHandler
- Inherits:
-
Object
- Object
- LightJWT::JWA::JWS::BaseHandler
- Defined in:
- lib/light_jwt/jwa/jws.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#alg ⇒ Object
readonly
Returns the value of attribute alg.
-
#digest ⇒ Object
readonly
Returns the value of attribute digest.
Instance Method Summary collapse
-
#initialize(alg) ⇒ BaseHandler
constructor
A new instance of BaseHandler.
-
#secure_compare(a, b) ⇒ Object
Constant-time comparison algorithm to prevent timing attacks.
Constructor Details
#initialize(alg) ⇒ BaseHandler
Returns a new instance of BaseHandler.
61 62 63 64 |
# File 'lib/light_jwt/jwa/jws.rb', line 61 def initialize(alg) @alg = alg @digest = build_digest unless alg == 'none' end |
Instance Attribute Details
#alg ⇒ Object (readonly)
Returns the value of attribute alg.
59 60 61 |
# File 'lib/light_jwt/jwa/jws.rb', line 59 def alg @alg end |
#digest ⇒ Object (readonly)
Returns the value of attribute digest.
59 60 61 |
# File 'lib/light_jwt/jwa/jws.rb', line 59 def digest @digest end |
Instance Method Details
#secure_compare(a, b) ⇒ Object
Constant-time comparison algorithm to prevent timing attacks
67 68 69 70 71 |
# File 'lib/light_jwt/jwa/jws.rb', line 67 def secure_compare(a, b) return false if a.bytesize != b.bytesize a.bytes.zip(b.bytes).map { |x, y| x ^ y }.sum.zero? end |