diff options
Diffstat (limited to 'lib/tfa/storage.rb')
| -rw-r--r-- | lib/tfa/storage.rb | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/lib/tfa/storage.rb b/lib/tfa/storage.rb index c2caf27..02f8961 100644 --- a/lib/tfa/storage.rb +++ b/lib/tfa/storage.rb @@ -43,30 +43,6 @@ module TFA end end - def encrypt!(passphrase) - cipher = OpenSSL::Cipher.new("AES-256-CBC") - cipher.encrypt - cipher.key = digest_for(passphrase) - #iv = cipher.random_iv - #cipher.iv = iv - - plain_text = read_all - #cipher_text = iv + cipher.update(plain_text) + cipher.final - cipher_text = cipher.update(plain_text) + cipher.final - flush(cipher_text) - end - - def decrypt!(passphrase) - cipher_text = read_all - decipher = OpenSSL::Cipher.new("AES-256-CBC") - decipher.decrypt - #decipher.iv = cipher_text[0..decipher.iv_len-1] - decipher.key = digest_for(passphrase) - #data = cipher_text[decipher.iv_len..-1] - data = cipher_text - flush(decipher.update(data) + decipher.final) - end - private def open_readonly @@ -74,17 +50,5 @@ module TFA yield @storage end end - - def read_all - IO.read(path) - end - - def flush(data) - IO.write(path, data) - end - - def digest_for(passphrase) - Digest::SHA256.digest(passphrase) - end end end |
