add cipher field to AnnexState

This commit is contained in:
Joey Hess 2011-04-16 16:41:46 -04:00
parent 5efd413270
commit 9fe7e6be70
3 changed files with 27 additions and 13 deletions

View file

@ -22,6 +22,7 @@ import qualified GitRepo as Git
import qualified GitQueue import qualified GitQueue
import qualified BackendClass import qualified BackendClass
import qualified RemoteClass import qualified RemoteClass
import qualified CryptoTypes
-- git-annex's monad -- git-annex's monad
type Annex = StateT AnnexState IO type Annex = StateT AnnexState IO
@ -41,7 +42,8 @@ data AnnexState = AnnexState
, toremote :: Maybe String , toremote :: Maybe String
, fromremote :: Maybe String , fromremote :: Maybe String
, exclude :: [String] , exclude :: [String]
} deriving (Show) , cipher :: Maybe CryptoTypes.Cipher
}
newState :: Git.Repo -> [BackendClass.Backend Annex] -> AnnexState newState :: Git.Repo -> [BackendClass.Backend Annex] -> AnnexState
newState gitrepo allbackends = AnnexState newState gitrepo allbackends = AnnexState
@ -58,6 +60,7 @@ newState gitrepo allbackends = AnnexState
, toremote = Nothing , toremote = Nothing
, fromremote = Nothing , fromremote = Nothing
, exclude = [] , exclude = []
, cipher = Nothing
} }
{- Create and returns an Annex state object for the specified git repo. -} {- Create and returns an Annex state object for the specified git repo. -}

View file

@ -36,18 +36,7 @@ import Types
import Key import Key
import RemoteClass import RemoteClass
import Utility import Utility
import CryptoTypes
data Cipher = Cipher String -- XXX ideally, this would be a locked memory region
data EncryptedCipher = EncryptedCipher String KeyIds
data KeyIds = KeyIds [String]
instance Show KeyIds where
show (KeyIds ks) = join "," ks
instance Read KeyIds where
readsPrec _ s = [(KeyIds (split "," s), "")]
{- Creates a new Cipher, encrypted as specified in the remote's configuration -} {- Creates a new Cipher, encrypted as specified in the remote's configuration -}
genCipher :: RemoteConfig -> IO EncryptedCipher genCipher :: RemoteConfig -> IO EncryptedCipher

22
CryptoTypes.hs Normal file
View file

@ -0,0 +1,22 @@
{- git-annex crypto types
-
- Copyright 2011 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module CryptoTypes where
import Data.String.Utils
data Cipher = Cipher String -- XXX ideally, this would be a locked memory region
data EncryptedCipher = EncryptedCipher String KeyIds
data KeyIds = KeyIds [String]
instance Show KeyIds where
show (KeyIds ks) = join "," ks
instance Read KeyIds where
readsPrec _ s = [(KeyIds (split "," s), "")]