Class: WSS4R::Security::Crypto::AsymmetricEncrypter

Inherits:
Object
  • Object
show all
Defined in:
lib/wss4r/security/crypto/cipher.rb

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ AsymmetricEncrypter

Returns a new instance of AsymmetricEncrypter.



144
145
146
# File 'lib/wss4r/security/crypto/cipher.rb', line 144

def initialize(filename)
  @private_key = RSA.new(File.read(filename))
end

Instance Method Details

#decrypt_symmetrickey_from_b64(text) ⇒ Object



148
149
150
151
152
153
154
155
156
# File 'lib/wss4r/security/crypto/cipher.rb', line 148

def decrypt_symmetrickey_from_b64(text)
  ciphertext  = @private_rsa_key.private_decrypt(text)
  iv = ciphertext[0..7]
  key = ciphertext[8..-1]
  symmetric_key = Cipher.new(@symmetric_algorithm)
  symmetric_key.decrypt(key, iv)
  symmetric_key.key = key
  symmetric_key
end