Class: Strongroom::Decryptor

Inherits:
Object
  • Object
show all
Includes:
HasRsaKey
Defined in:
lib/strongroom/decryptor.rb

Defined Under Namespace

Classes: CipherLocator

Instance Method Summary (collapse)

Constructor Details

- (Decryptor) initialize(private_key, cipher_locator = nil)

A new instance of Decryptor



6
7
8
9
# File 'lib/strongroom/decryptor.rb', line 6

def initialize private_key, cipher_locator = nil
  @cipher_locator = cipher_locator || CipherLocator.new
  has_rsa_key private_key
end

Instance Method Details

- (Object) decrypt(enigma)



11
12
13
14
15
16
17
# File 'lib/strongroom/decryptor.rb', line 11

def decrypt enigma
  cipher = @cipher_locator.for(enigma)
  cipher.decrypt
  cipher.key = rsa_key.private_decrypt enigma.encrypted_key
  cipher.iv = enigma.iv
  cipher.update(enigma.ciphertext) << cipher.final
end