Class: Xml::Kit::Crypto::OaepCipher
- Inherits:
-
Object
- Object
- Xml::Kit::Crypto::OaepCipher
- Defined in:
- lib/xml/kit/crypto/oaep_cipher.rb
Constant Summary collapse
- ALGORITHM =
"#{::Xml::Kit::Namespaces::XMLENC}rsa-oaep-mgf1p"
- ALGORITHMS =
{ ALGORITHM => true }.freeze
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
readonly
Returns the value of attribute algorithm.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Class Method Summary collapse
Instance Method Summary collapse
- #decrypt(cipher_text) ⇒ Object
- #encrypt(plain_text) ⇒ Object
-
#initialize(algorithm, key) ⇒ OaepCipher
constructor
A new instance of OaepCipher.
Constructor Details
#initialize(algorithm, key) ⇒ OaepCipher
Returns a new instance of OaepCipher.
13 14 15 16 |
# File 'lib/xml/kit/crypto/oaep_cipher.rb', line 13 def initialize(algorithm, key) @algorithm = algorithm @key = key end |
Instance Attribute Details
#algorithm ⇒ Object (readonly)
Returns the value of attribute algorithm.
11 12 13 |
# File 'lib/xml/kit/crypto/oaep_cipher.rb', line 11 def algorithm @algorithm end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
11 12 13 |
# File 'lib/xml/kit/crypto/oaep_cipher.rb', line 11 def key @key end |
Class Method Details
.matches?(algorithm) ⇒ Boolean
18 19 20 |
# File 'lib/xml/kit/crypto/oaep_cipher.rb', line 18 def self.matches?(algorithm) ALGORITHMS[algorithm] end |
Instance Method Details
#decrypt(cipher_text) ⇒ Object
26 27 28 |
# File 'lib/xml/kit/crypto/oaep_cipher.rb', line 26 def decrypt(cipher_text) @key.private_decrypt(cipher_text, padding) end |
#encrypt(plain_text) ⇒ Object
22 23 24 |
# File 'lib/xml/kit/crypto/oaep_cipher.rb', line 22 def encrypt(plain_text) @key.public_encrypt(plain_text, padding) end |