diff options
author | Joey Hess <joey@kitenet.net> | 2011-10-11 14:43:45 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-10-11 14:43:45 -0400 |
commit | b505ba83e8b62a9ed0ec2fb96448c5fc801184d9 (patch) | |
tree | 664eb4af9f274dfc13eb9abfab86421ebe38e881 /Crypto.hs | |
parent | 025ded4a2dfb58a6ec0cb47b9d625d593a4e1977 (diff) |
minor syntax changes
Diffstat (limited to 'Crypto.hs')
-rw-r--r-- | Crypto.hs | 25 |
1 files changed, 12 insertions, 13 deletions
@@ -135,13 +135,12 @@ decryptCipher _ (EncryptedCipher encipher _) = {- Generates an encrypted form of a Key. The encryption does not need to be - reversable, nor does it need to be the same type of encryption used - on content. It does need to be repeatable. -} -encryptKey :: Cipher -> Key -> IO Key -encryptKey c k = - return Key { - keyName = hmacWithCipher c (show k), - keyBackendName = "GPGHMACSHA1", - keySize = Nothing, -- size and mtime omitted - keyMtime = Nothing -- to avoid leaking data +encryptKey :: Cipher -> Key -> Key +encryptKey c k = Key + { keyName = hmacWithCipher c (show k) + , keyBackendName = "GPGHMACSHA1" + , keySize = Nothing -- size and mtime omitted + , keyMtime = Nothing -- to avoid leaking data } {- Runs an action, passing it a handle from which it can @@ -223,18 +222,18 @@ gpgCipherHandle params c a b = do return ret configKeyIds :: RemoteConfig -> IO KeyIds -configKeyIds c = do - let k = configGet c "encryption" - s <- gpgRead [Params "--with-colons --list-public-keys", Param k] - return $ KeyIds $ parseWithColons s +configKeyIds c = parse <$> gpgRead params where - parseWithColons s = map keyIdField $ filter pubKey $ lines s + params = [Params "--with-colons --list-public-keys", + Param $ configGet c "encryption"] + parse = KeyIds . map keyIdField . filter pubKey . lines pubKey = isPrefixOf "pub:" keyIdField s = split ":" s !! 4 configGet :: RemoteConfig -> String -> String configGet c key = fromMaybe missing $ M.lookup key c - where missing = error $ "missing " ++ key ++ " in remote config" + where + missing = error $ "missing " ++ key ++ " in remote config" hmacWithCipher :: Cipher -> String -> String hmacWithCipher c = hmacWithCipher' (cipherHmac c) |