From c4990a41c430d541cefe27a53a39e7eb60e217a8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 5 Sep 2013 11:12:01 -0400 Subject: rename constructor for clariy --- Crypto.hs | 12 ++++++------ Remote/Helper/Encryptable.hs | 10 +++++----- Test.hs | 6 +++--- Types/Crypto.hs | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Crypto.hs b/Crypto.hs index 8b91c2dea..f99f8cbf1 100644 --- a/Crypto.hs +++ b/Crypto.hs @@ -78,8 +78,8 @@ genEncryptedCipher keyid variant highQuality = do encryptCipher (mkCipher random) variant ks where (mkCipher, size) = case variant of - HybridCipher -> (Cipher, cipherSize) -- used for MAC + symmetric - PubKeyCipher -> (MacOnlyCipher, cipherBeginning) -- only used for MAC + Hybrid -> (Cipher, cipherSize) -- used for MAC + symmetric + PubKey -> (MacOnlyCipher, cipherBeginning) -- only used for MAC {- Creates a new, shared Cipher. -} genSharedCipher :: Bool -> IO StorableCipher @@ -110,8 +110,8 @@ describeCipher (EncryptedCipher _ variant (KeyIds ks)) = scheme ++ " with gpg " ++ keys ks ++ " " ++ unwords ks where scheme = case variant of - HybridCipher -> "hybrid cipher" - PubKeyCipher -> "pubkey crypto" + Hybrid -> "hybrid cipher" + PubKey -> "pubkey crypto" keys [_] = "key" keys _ = "keys" @@ -135,8 +135,8 @@ decryptCipher (EncryptedCipher t variant _) = mkCipher <$> Gpg.pipeStrict [ Param "--decrypt" ] t where mkCipher = case variant of - HybridCipher -> Cipher - PubKeyCipher -> MacOnlyCipher + Hybrid -> Cipher + PubKey -> MacOnlyCipher {- 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 diff --git a/Remote/Helper/Encryptable.hs b/Remote/Helper/Encryptable.hs index 5c661eaa7..a6e79ddc4 100644 --- a/Remote/Helper/Encryptable.hs +++ b/Remote/Helper/Encryptable.hs @@ -36,9 +36,9 @@ encryptionSetup c = maybe genCipher updateCipher $ extractCipher c -- hybrid encryption is the default when a keyid is -- specified but no encryption _ | maybe (M.member "keyid" c) (== "hybrid") encryption -> - use "encryption setup" . genEncryptedCipher key HybridCipher + use "encryption setup" . genEncryptedCipher key Hybrid =<< highRandomQuality - Just "pubkey" -> use "encryption setup" . genEncryptedCipher key PubKeyCipher + Just "pubkey" -> use "encryption setup" . genEncryptedCipher key PubKey =<< highRandomQuality _ -> error $ "Specify " ++ intercalate " or " (map ("encryption=" ++) @@ -52,7 +52,7 @@ encryptionSetup c = maybe genCipher updateCipher $ extractCipher c updateCipher v = case v of SharedCipher _ | maybe True (== "shared") encryption -> return c' EncryptedCipher _ variant _ - | maybe True (== if variant == HybridCipher then "hybrid" else "pubkey") encryption -> + | maybe True (== if variant == Hybrid then "hybrid" else "pubkey") encryption -> use "encryption update" $ updateEncryptedCipher newkeys v _ -> cannotchange use m a = do @@ -154,9 +154,9 @@ extractCipher c = case (M.lookup "cipher" c, M.lookup "cipherkeys" c, M.lookup "encryption" c) of (Just t, Just ks, encryption) | maybe True (== "hybrid") encryption -> - Just $ EncryptedCipher (fromB64 t) HybridCipher (readkeys ks) + Just $ EncryptedCipher (fromB64 t) Hybrid (readkeys ks) (Just t, Just ks, Just "pubkey") -> - Just $ EncryptedCipher (fromB64 t) PubKeyCipher (readkeys ks) + Just $ EncryptedCipher (fromB64 t) PubKey (readkeys ks) (Just t, Nothing, encryption) | maybe True (== "shared") encryption -> Just $ SharedCipher (fromB64 t) _ -> Nothing diff --git a/Test.hs b/Test.hs index 9eb99379e..83b4e9ee6 100644 --- a/Test.hs +++ b/Test.hs @@ -930,8 +930,8 @@ test_crypto env = "git-annex crypto" ~: TestList $ flip map ["shared","hybrid"," maybe False (\(Utility.Gpg.KeyIds ks2) -> sort (nub ks2) == sort (nub ks')) ks checkCipher encipher = Utility.Gpg.checkEncryptionStream encipher . Just - checkScheme Types.Crypto.HybridCipher = scheme == "hybrid" - checkScheme Types.Crypto.PubKeyCipher = scheme == "pubkey" + checkScheme Types.Crypto.Hybrid = scheme == "hybrid" + checkScheme Types.Crypto.PubKey = scheme == "pubkey" checkKeys cip mvariant = do cipher <- Crypto.decryptCipher cip files <- filterM doesFileExist $ @@ -939,7 +939,7 @@ test_crypto env = "git-annex crypto" ~: TestList $ flip map ["shared","hybrid"," return (not $ null files) <&&> allM (checkFile mvariant) files checkFile mvariant filename = Utility.Gpg.checkEncryptionFile filename $ - if mvariant == Just Types.Crypto.PubKeyCipher then ks else Nothing + if mvariant == Just Types.Crypto.PubKey then ks else Nothing key2files cipher = Locations.keyPaths . Crypto.encryptKey Types.Crypto.HmacSha1 cipher #else diff --git a/Types/Crypto.hs b/Types/Crypto.hs index 487a29391..6d4131129 100644 --- a/Types/Crypto.hs +++ b/Types/Crypto.hs @@ -28,7 +28,7 @@ data Cipher = Cipher String | MacOnlyCipher String data StorableCipher = EncryptedCipher String EncryptedCipherVariant KeyIds | SharedCipher String deriving (Ord, Eq) -data EncryptedCipherVariant = HybridCipher | PubKeyCipher +data EncryptedCipherVariant = Hybrid | PubKey deriving (Ord, Eq) {- File names are (client-side) MAC'ed on special remotes. -- cgit v1.2.3