Class: Virgil::Crypto::VirgilAccessTokenSigner

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeVirgilAccessTokenSigner

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

#algorithmObject (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.

Parameters:

  • token_bytes (Bytes)

    The material representation bytes of access token

  • private_key (VirgilPrivateKey)

    The digital signature for the material representation

Returns:

  • The digital signature for the material representation 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.

Parameters:

  • signature (Bytes)

    The digital signature for the token_bytes

  • token_bytes (Bytes)

    The material representation bytes of access token

  • public_key (VirgilPublicKey)

    public

Returns:

  • (Boolean)

    True if signature is valid, False otherwise.



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