class Acme::Client::JWK::RSA

def initialize(private_key)

Returns nothing.

private_key - A OpenSSL::PKey::RSA instance.

Instantiate a new RSA JWK.
def initialize(private_key)
  unless private_key.is_a?(OpenSSL::PKey::RSA)
    raise ArgumentError, 'private_key must be a OpenSSL::PKey::RSA'
  end
  @private_key = private_key
end

def jwa_alg

Returns a String.

The name of the algorithm as needed for the `alg` member of a JWS object.
def jwa_alg
  # https://tools.ietf.org/html/rfc7518#section-3.1
  # RSASSA-PKCS1-v1_5 using SHA-256
  'RS256'
end

def public_key

def public_key
  @private_key.public_key
end

def sign(message)

Returns a String signature.

message - A String message to sign.

Sign a message with the private key.
def sign(message)
  @private_key.sign(DIGEST.new, message)
end

def to_h

Returns a Hash.

Get this JWK as a Hash for JSON serialization.
def to_h
  {
    e: Acme::Client::Util.urlsafe_base64(public_key.e.to_s(2)),
    kty: 'RSA',
    n: Acme::Client::Util.urlsafe_base64(public_key.n.to_s(2))
  }
end