Class: Saml::Kit::Crypto::OaepCipher

Inherits:
Object
  • Object
show all
Defined in:
lib/saml/kit/crypto/oaep_cipher.rb

Constant Summary collapse

ALGORITHMS =
{
  'http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p' => true,
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(algorithm, key) ⇒ OaepCipher

Returns a new instance of OaepCipher.



8
9
10
# File 'lib/saml/kit/crypto/oaep_cipher.rb', line 8

def initialize(algorithm, key)
  @key = key
end

Class Method Details

.matches?(algorithm) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/saml/kit/crypto/oaep_cipher.rb', line 12

def self.matches?(algorithm)
  ALGORITHMS[algorithm]
end

Instance Method Details

#decrypt(cipher_text) ⇒ Object



16
17
18
# File 'lib/saml/kit/crypto/oaep_cipher.rb', line 16

def decrypt(cipher_text)
  @key.private_decrypt(cipher_text, OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING)
end