class RSA::Key

An RSA public or private key.

Refer to PKCS #1 v2.1, section 3, pp. 6-8.

@see www.rsa.com/rsalabs/node.asp?id=2125 @see en.wikipedia.org/wiki/Public-key_cryptography

Attributes

d[RW]

The RSA public or private exponent, a positive integer.

@return [Integer]

e[RW]

The RSA public or private exponent, a positive integer.

@return [Integer]

exponent[RW]

The RSA public or private exponent, a positive integer.

@return [Integer]

modulus[RW]

The RSA modulus, a positive integer.

@return [Integer]

n[RW]

The RSA modulus, a positive integer.

@return [Integer]

Public Class Methods

new(modulus, exponent, options = {}) click to toggle source

Initializes a new key.

@param [Integer, to_i] modulus @param [Integer, to_i] exponent @param [Hash{Symbol => Object}] options

# File lib/rsa-g/key.rb, line 31
def initialize(modulus, exponent, options = {})
  @modulus  = modulus.to_i
  @exponent = exponent.to_i
  @options  = options.dup
end

Public Instance Methods

to_a() click to toggle source

Returns a two-element array containing the modulus and exponent.

@return [Array]

# File lib/rsa-g/key.rb, line 50
def to_a
  [modulus, exponent]
end
valid?() click to toggle source

Returns `true` if this is a valid RSA key according to {RSA::PKCS1 PKCS #1}.

@return [Boolean]

# File lib/rsa-g/key.rb, line 42
def valid?
  true # TODO: PKCS #1 v2.1, sections 3.1 and 3.2, pp. 6-7.
end