data Crypto::RSA::PublicKey(der: Bytes)
An RSA public key.
pem = File.read("std/test/fixtures/crypto/rsa2048_spki.pem")
pub = Crypto::RSA::PublicKey.from_pem(pem)
pub.bits # => 2048
pub.fingerprint.size # => 32
Class methods
def self.new(der: Bytes) -> Crypto::RSA::PublicKey
Raises Crypto::Error when der is not an RSA public key (SPKI
or PKCS#1); it is kept as SPKI.
def self.from_pem(pem: String | Bytes) -> Crypto::RSA::PublicKey
The key in pem: one SPKI (PUBLIC KEY) or PKCS#1
(RSA PUBLIC KEY) block.
def self.from_der(der: Bytes) -> Crypto::RSA::PublicKey
The key in der: SPKI or PKCS#1.
Methods
def der -> Bytes
The key as SPKI DER, whatever it was read from.
def to_h -> Hash[Symbol, Object]
The fields as a Hash, by name.
def with(*, der: Bytes = …) -> Crypto::RSA::PublicKey
A copy with the fields given replaced.
def to_der -> Bytes
The key as DER: SPKI.
def to_pem -> String
The key as PEM: SPKI (PUBLIC KEY).
def bits -> Int
The modulus's size in bits.
def verify(data: Bytes | String, signature: Bytes, hash: Symbol) -> Bool
Whether signature is the RSASSA-PKCS1-v1_5 signature of data
with hash: false for any wrong signature, never an exception.
def verify_pss(data: Bytes | String, signature: Bytes, hash: Symbol) -> Bool
Whether signature is the RSASSA-PSS signature of data with
hash (MGF1 with the same hash), whatever the salt's length: it
is read from the signature, as OpenSSL's saltlen:auto and Go's
PSSSaltLengthAuto verify. False for any wrong signature.
def fingerprint -> Bytes
The SHA-256 of the SPKI DER: a key's identity, for key ids and pinning.
def inspect -> String
#<Crypto::RSA::PublicKey 2048 bits, fingerprint ab12cd34…>.
def to_s -> String
#<Crypto::RSA::PublicKey 2048 bits, fingerprint ab12cd34…>.