Class: Xml::Kit::Crypto::OaepCipher

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

Constant Summary collapse

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_algorithm, key) ⇒ OaepCipher

Returns a new instance of OaepCipher.



10
11
12
# File 'lib/xml/kit/crypto/oaep_cipher.rb', line 10

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

Class Method Details

.matches?(algorithm) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/xml/kit/crypto/oaep_cipher.rb', line 14

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

Instance Method Details

#decrypt(cipher_text) ⇒ Object



22
23
24
# File 'lib/xml/kit/crypto/oaep_cipher.rb', line 22

def decrypt(cipher_text)
  @key.private_decrypt(cipher_text, padding)
end

#encrypt(plain_text) ⇒ Object



18
19
20
# File 'lib/xml/kit/crypto/oaep_cipher.rb', line 18

def encrypt(plain_text)
  @key.public_encrypt(plain_text, padding)
end