summaryrefslogtreecommitdiffhomepage
path: root/keysafe.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-08-17 15:52:08 -0400
committerJoey Hess <joeyh@joeyh.name>2016-08-17 15:52:08 -0400
commit19e3dc5541a74fe1c323c629bdf214b8690640e5 (patch)
treed4c16b9bb027887e9b7ea323997d30e00ba9ebdb /keysafe.hs
parented8d1ed03c3520ccd4b3c775817bef122457f224 (diff)
downloadkeysafe-19e3dc5541a74fe1c323c629bdf214b8690640e5.tar.gz
save restored secret key to gpg or file
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