Class: Linzer::JWS::Key
Overview
JWS-compatible signing key implementation.
Wraps a JWT::JWK key object to provide the Linzer Key interface. This enables using JWK-format keys with HTTP Message Signatures.
Instance Attribute Summary
Attributes inherited from Key
Instance Method Summary collapse
-
#private? ⇒ Boolean
True if this key can create signatures.
-
#public? ⇒ Boolean
True if this key can verify signatures.
-
#sign(data) ⇒ String
Signs data using the JWS key.
-
#verify(signature, data) ⇒ Boolean
Verifies a signature using the JWS key.
Methods inherited from Key
Constructor Details
This class inherits a constructor from Linzer::Key
Instance Method Details
#private? ⇒ Boolean
Returns true if this key can create signatures.
110 111 112 |
# File 'lib/linzer/jws.rb', line 110 def private? !!signing_key end |
#public? ⇒ Boolean
Returns true if this key can verify signatures.
105 106 107 |
# File 'lib/linzer/jws.rb', line 105 def public? !!verify_key end |
#sign(data) ⇒ String
Signs data using the JWS key.
86 87 88 89 90 |
# File 'lib/linzer/jws.rb', line 86 def sign(data) validate_signing_key algo = resolve_algorithm algo.sign(data: data, signing_key: signing_key) end |
#verify(signature, data) ⇒ Boolean
Verifies a signature using the JWS key.
98 99 100 101 102 |
# File 'lib/linzer/jws.rb', line 98 def verify(signature, data) validate_verify_key algo = resolve_algorithm algo.verify(data: data, signature: signature, verification_key: verify_key) end |