From 9fe7e6be7064d9c47e6c6fd4f1b3a70da604727d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 16 Apr 2011 16:41:46 -0400 Subject: [PATCH] add cipher field to AnnexState --- Annex.hs | 5 ++++- Crypto.hs | 13 +------------ CryptoTypes.hs | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+), 13 deletions(-) create mode 100644 CryptoTypes.hs diff --git a/Annex.hs b/Annex.hs index f4e5d599d0..9086db9bf7 100644 --- a/Annex.hs +++ b/Annex.hs @@ -22,6 +22,7 @@ import qualified GitRepo as Git import qualified GitQueue import qualified BackendClass import qualified RemoteClass +import qualified CryptoTypes -- git-annex's monad type Annex = StateT AnnexState IO @@ -41,7 +42,8 @@ data AnnexState = AnnexState , toremote :: Maybe String , fromremote :: Maybe String , exclude :: [String] - } deriving (Show) + , cipher :: Maybe CryptoTypes.Cipher + } newState :: Git.Repo -> [BackendClass.Backend Annex] -> AnnexState newState gitrepo allbackends = AnnexState @@ -58,6 +60,7 @@ newState gitrepo allbackends = AnnexState , toremote = Nothing , fromremote = Nothing , exclude = [] + , cipher = Nothing } {- Create and returns an Annex state object for the specified git repo. -} diff --git a/Crypto.hs b/Crypto.hs index 2e20dddb10..337aedff65 100644 --- a/Crypto.hs +++ b/Crypto.hs @@ -36,18 +36,7 @@ import Types import Key import RemoteClass import Utility - -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), "")] +import CryptoTypes {- Creates a new Cipher, encrypted as specified in the remote's configuration -} genCipher :: RemoteConfig -> IO EncryptedCipher diff --git a/CryptoTypes.hs b/CryptoTypes.hs new file mode 100644 index 0000000000..944a9d34e0 --- /dev/null +++ b/CryptoTypes.hs @@ -0,0 +1,22 @@ +{- git-annex crypto types + - + - Copyright 2011 Joey Hess + - + - 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), "")]