Class: Xmlenc::Algorithms::RsaOaepMgf1p

Inherits:
Object
  • Object
show all
Defined in:
lib/xmlenc/algorithms/rsa_oaep_mgf1p.rb

Constant Summary collapse

DIGEST_METHODS =
%w(http://www.w3.org/2000/09/xmldsig#sha1)

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ RsaOaepMgf1p

Returns a new instance of RsaOaepMgf1p.



6
7
8
# File 'lib/xmlenc/algorithms/rsa_oaep_mgf1p.rb', line 6

def initialize(key)
  @key = key
end

Instance Method Details

#decrypt(cipher_value, options = {}) ⇒ Object



10
11
12
13
# File 'lib/xmlenc/algorithms/rsa_oaep_mgf1p.rb', line 10

def decrypt(cipher_value, options = {})
  verify_algorithm(options[:node]) if options[:node]
  @key.private_decrypt(cipher_value, OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING)
end

#encrypt(data, options = {}) ⇒ Object



15
16
17
# File 'lib/xmlenc/algorithms/rsa_oaep_mgf1p.rb', line 15

def encrypt(data, options = {})
  @key.public_encrypt(data, OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING)
end