Class: JWE::Alg::RsaOaep

Inherits:
Object
  • Object
show all
Defined in:
lib/jwe/alg/rsa_oaep.rb

Overview

RSA-OAEP key encryption algorithm.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ RsaOaep

Returns a new instance of RsaOaep.


7
8
9
# File 'lib/jwe/alg/rsa_oaep.rb', line 7

def initialize(key)
  self.key = key
end

Instance Attribute Details

#keyObject

Returns the value of attribute key


5
6
7
# File 'lib/jwe/alg/rsa_oaep.rb', line 5

def key
  @key
end

Instance Method Details

#decrypt(encrypted_cek) ⇒ Object


15
16
17
# File 'lib/jwe/alg/rsa_oaep.rb', line 15

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

#encrypt(cek) ⇒ Object


11
12
13
# File 'lib/jwe/alg/rsa_oaep.rb', line 11

def encrypt(cek)
  key.public_encrypt(cek, OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING)
end