Class: Virgil::Crypto::VirgilAccessTokenSigner
- Inherits:
-
Object
- Object
- Virgil::Crypto::VirgilAccessTokenSigner
- Defined in:
- lib/virgil/crypto/access_token_signer.rb
Overview
Provides a cryptographic operations in applications, such as signature generation and verification in an access token.
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
readonly
Represents used signature algorithm.
Instance Method Summary collapse
-
#generate_token_signature(token_bytes, private_key) ⇒ Object
Generates the digital signature for the specified token_bytes using the specified [VirgilPrivateKey] for which to compute the signature.
-
#initialize ⇒ VirgilAccessTokenSigner
constructor
Initializes a new instance of the [VirgilAccessTokenSigner] class.
-
#verify_token_signature(signature, token_bytes, public_key) ⇒ Boolean
Verifies that a digital signature is valid by checking the signature, provided public_key and token_bytes for which the signature has been generated.
Constructor Details
#initialize ⇒ VirgilAccessTokenSigner
Initializes a new instance of the [VirgilAccessTokenSigner] class.
46 47 48 49 |
# File 'lib/virgil/crypto/access_token_signer.rb', line 46 def initialize @virgil_crypto = VirgilCrypto.new @algorithm = 'VEDS512' end |
Instance Attribute Details
#algorithm ⇒ Object (readonly)
Represents used signature algorithm.
43 44 45 |
# File 'lib/virgil/crypto/access_token_signer.rb', line 43 def algorithm @algorithm end |
Instance Method Details
#generate_token_signature(token_bytes, private_key) ⇒ Object
Generates the digital signature for the specified token_bytes
using the specified [VirgilPrivateKey]
for which to compute the signature. bytes of access token.
58 59 60 |
# File 'lib/virgil/crypto/access_token_signer.rb', line 58 def generate_token_signature(token_bytes, private_key) @virgil_crypto.generate_signature(token_bytes, private_key) end |
#verify_token_signature(signature, token_bytes, public_key) ⇒ Boolean
Verifies that a digital signature is valid by checking the signature, provided public_key and token_bytes for which the signature has been generated. key for verification.
70 71 72 |
# File 'lib/virgil/crypto/access_token_signer.rb', line 70 def verify_token_signature(signature, token_bytes, public_key) @virgil_crypto.verify_signature(signature, token_bytes, public_key) end |