aboutsummaryrefslogtreecommitdiff
path: root/Types
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-05-10 16:50:31 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-05-10 16:50:31 -0400
commitac0b9506f2e38692b2a4e895f3c59d2d37a6886d (patch)
treea47285a6db28a08a42e9b4528c7ee9dc010e2908 /Types
parent07b1aa343b6d82e8f75de606a5647b0a789f76e0 (diff)
Added new encryption=sharedpubkey mode for special remotes.
This is useful for makking a special remote that anyone with a clone of the repo and your public keys can upload files to, but only you can decrypt the files stored in it.
Diffstat (limited to 'Types')
-rw-r--r--Types/Crypto.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/Types/Crypto.hs b/Types/Crypto.hs
index 79970c288..c5a00d032 100644
--- a/Types/Crypto.hs
+++ b/Types/Crypto.hs
@@ -10,6 +10,7 @@ module Types.Crypto (
StorableCipher(..),
EncryptedCipherVariant(..),
KeyIds(..),
+ cipherKeyIds,
Mac(..),
readMac,
showMac,
@@ -23,12 +24,19 @@ import Utility.Gpg (KeyIds(..))
-- XXX ideally, this would be a locked memory region
data Cipher = Cipher String | MacOnlyCipher String
-data StorableCipher = EncryptedCipher String EncryptedCipherVariant KeyIds
- | SharedCipher String
+data StorableCipher
+ = EncryptedCipher String EncryptedCipherVariant KeyIds
+ | SharedCipher String
+ | SharedPubKeyCipher String KeyIds
deriving (Ord, Eq)
data EncryptedCipherVariant = Hybrid | PubKey
deriving (Ord, Eq)
+cipherKeyIds :: StorableCipher -> Maybe KeyIds
+cipherKeyIds (EncryptedCipher _ _ ks) = Just ks
+cipherKeyIds (SharedPubKeyCipher _ ks) = Just ks
+cipherKeyIds (SharedCipher _) = Nothing
+
defaultMac :: Mac
defaultMac = HmacSha1