diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-08-12 01:04:06 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-08-12 01:04:06 -0400 |
commit | f74151ead49895f86257c9abfbe90c027d91d456 (patch) | |
tree | b3be9d579348c953d3348de3715eef95b8680d50 /keysafe.hs | |
parent | ad93e84990f4205182a2ae68ec2ad485af4b4da4 (diff) | |
download | keysafe-f74151ead49895f86257c9abfbe90c027d91d456.tar.gz |
option parsing
Diffstat (limited to 'keysafe.hs')
-rw-r--r-- | keysafe.hs | 29 |
1 files changed, 18 insertions, 11 deletions
@@ -9,6 +9,7 @@ module Main where import Types import Tunables +import qualified CmdLine import Encryption import Cost import Shard @@ -17,11 +18,21 @@ import Storage.LocalFiles main :: IO () main = do - storedemo - retrievedemo + cmdline <- CmdLine.get + let name = CmdLine.name cmdline + let keytype = CmdLine.keytype cmdline + -- TODO determine gpg key id by examining secret key, + -- or retrieving public key from keyserver and examining it. + let keyid = KeyId keytype "dummy key id" + case CmdLine.mode cmdline of + CmdLine.Backup -> storedemo name keyid $ + if CmdLine.testMode cmdline + then testModeTunables + else defaultTunables + CmdLine.Restore -> retrievedemo name keyid -storedemo :: IO () -storedemo = do +storedemo :: Name -> KeyId -> Tunables -> IO () +storedemo name keyid tunables = do kek <- genKeyEncryptionKey tunables name password putStrLn "Very rough estimate of cost to brute-force the password:" print $ estimateAttack spotAWS $ estimateBruteforceOf kek @@ -33,13 +44,10 @@ storedemo = do print =<< obscureShards localFiles where password = Password "correct horse battery staple" - name = Name "bar" - tunables = testModeTunables -- defaultTunables - keyid = KeyId gpgKey "foobar" secretkey = SecretKey "this is a gpg private key" -retrievedemo :: IO () -retrievedemo = do +retrievedemo :: Name -> KeyId -> IO () +retrievedemo name keyid = do let sis = shardIdents tunables name keyid -- we drop 1 to simulate not getting all shards from the servers let l = drop 1 $ zip [1..] (getIdents sis) @@ -56,6 +64,5 @@ retrievedemo = do Nothing -> go esk rest password = Password "correct horse battery staple" - name = Name "bar" + -- TODO: derive by probing to find objects tunables = testModeTunables -- defaultTunables - keyid = KeyId gpgKey "foobar" |