summaryrefslogtreecommitdiffhomepage
path: root/keysafe.hs
diff options
context:
space:
mode:
Diffstat (limited to 'keysafe.hs')
-rw-r--r--keysafe.hs10
1 files changed, 3 insertions, 7 deletions
diff --git a/keysafe.hs b/keysafe.hs
index 4666dd3..efdd068 100644
--- a/keysafe.hs
+++ b/keysafe.hs
@@ -15,6 +15,7 @@ import Encryption
import Entropy
import ExpensiveHash
import Cost
+import SecretKey
import Shard
import Storage
import qualified Gpg
@@ -61,10 +62,6 @@ dispatch cmdline ui tunables = do
go CmdLine.Benchmark _ =
benchmarkTunables tunables
-getSecretKey :: SecretKeySource -> IO SecretKey
-getSecretKey (GpgKey kid) = Gpg.getSecretKey kid
-getSecretKey (KeyFile f) = SecretKey <$> B.readFile f
-
backup :: Storage -> UI -> Tunables -> SecretKeySource -> SecretKey -> IO ()
backup storage ui tunables secretkeysource secretkey = do
username <- userName
@@ -166,10 +163,9 @@ restore storage ui secretkeydest = do
(decryptdesc cost) $ \setpercent -> do
case decrypt candidatekeys esk of
Nothing -> showError ui "Decryption failed! Unknown why it would fail at this point."
- Just (SecretKey secretkey) -> do
+ Just secretkey -> do
setpercent 100
- -- TODO save
- print secretkey
+ writeSecretKey secretkeydest secretkey
showInfo ui "Success" "Your secret key successfully restored!"
where
-- TODO: derive by probing to find objects