Class: Linzer::RSA::Key

Inherits:
Key
  • Object
show all
Defined in:
lib/linzer/rsa.rb

Overview

RSA PKCS#1 v1.5 signing key implementation.

Uses the rsa-v1_5-sha256 algorithm identifier.

Examples:

Generating a new key

key = Linzer.generate_rsa_v1_5_sha256_key(2048, "my-rsa-key")

Loading from PEM

key = Linzer.new_rsa_v1_5_sha256_key(File.read("rsa.pem"), "key-1")

See Also:

Instance Attribute Summary

Attributes inherited from Key

#material

Instance Method Summary collapse

Methods inherited from Key

#initialize, #key_id, #private?, #public?

Constructor Details

This class inherits a constructor from Linzer::Key

Instance Method Details

#sign(data) ⇒ String

Signs data using RSA PKCS#1 v1.5.

Raises:

  • (SigningError)

    If this key does not contain private key material



39
40
41
42
# File 'lib/linzer/rsa.rb', line 39

def sign(data)
  validate_signing_key
  material.sign(@params[:digest], data)
end

#validateObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
32
# File 'lib/linzer/rsa.rb', line 29

def validate
  super
  validate_digest
end

#verify(signature, data) ⇒ Boolean

Verifies an RSA PKCS#1 v1.5 signature.

Raises:

  • (VerifyError)

    If this key does not contain public key material



50
51
52
53
# File 'lib/linzer/rsa.rb', line 50

def verify(signature, data)
  validate_verify_key
  material.verify(@params[:digest], signature, data)
end