aboutsummaryrefslogtreecommitdiff
path: root/Crypto.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-02-24 15:16:56 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-02-24 15:16:56 -0400
commit2f868db90c7ba16eee901b9b1472b1e1a889dd93 (patch)
tree8a366a36cc50cf1c3899aeaddf10e02d9cffc847 /Crypto.hs
parent13fb898fb2379a9ed9b7df2b645453059d296488 (diff)
add KeyVariety type
Where before the "name" of a key and a backend was a string, this makes it a concrete data type. This is groundwork for allowing some varieties of keys to be disabled in file2key, so git-annex won't use them at all. Benchmarks ran in my big repo: old git-annex info: real 0m3.338s user 0m3.124s sys 0m0.244s new git-annex info: real 0m3.216s user 0m3.024s sys 0m0.220s new git-annex find: real 0m7.138s user 0m6.924s sys 0m0.252s old git-annex find: real 0m7.433s user 0m7.240s sys 0m0.232s Surprising result; I'd have expected it to be slower since it now parses all the key varieties. But, the parser is very simple and perhaps sharing KeyVarieties uses less memory or something like that. This commit was supported by the NSF-funded DataLad project.
Diffstat (limited to 'Crypto.hs')
-rw-r--r--Crypto.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/Crypto.hs b/Crypto.hs
index dc1d2e6d2..a37528619 100644
--- a/Crypto.hs
+++ b/Crypto.hs
@@ -42,6 +42,7 @@ import Annex.Common
import qualified Utility.Gpg as Gpg
import Types.Crypto
import Types.Remote
+import Types.Key
{- The beginning of a Cipher is used for MAC'ing; the remainder is used
- as the GPG symmetric encryption passphrase when using the hybrid
@@ -159,14 +160,16 @@ type EncKey = Key -> Key
encryptKey :: Mac -> Cipher -> EncKey
encryptKey mac c k = stubKey
{ keyName = macWithCipher mac c (key2file k)
- , keyBackendName = encryptedBackendNamePrefix ++ showMac mac
+ , keyVariety = OtherKey (encryptedBackendNamePrefix ++ showMac mac)
}
encryptedBackendNamePrefix :: String
encryptedBackendNamePrefix = "GPG"
isEncKey :: Key -> Bool
-isEncKey k = encryptedBackendNamePrefix `isPrefixOf` keyBackendName k
+isEncKey k = case keyVariety k of
+ OtherKey s -> encryptedBackendNamePrefix `isPrefixOf` s
+ _ -> False
type Feeder = Handle -> IO ()
type Reader m a = Handle -> m a