initremote: show gpg keys

This commit is contained in:
Joey Hess 2011-04-17 18:18:27 -04:00
parent a91a51fc03
commit 86f7feb278
3 changed files with 13 additions and 4 deletions

View file

@ -13,6 +13,7 @@ module Crypto (
EncryptedCipher, EncryptedCipher,
genCipher, genCipher,
updateCipher, updateCipher,
describeCipher,
storeCipher, storeCipher,
extractCipher, extractCipher,
decryptCipher, decryptCipher,
@ -95,6 +96,13 @@ updateCipher c encipher@(EncryptedCipher _ ks) = do
where where
combine (KeyIds a) (KeyIds b) = KeyIds $ a ++ b combine (KeyIds a) (KeyIds b) = KeyIds $ a ++ b
describeCipher :: EncryptedCipher -> String
describeCipher (EncryptedCipher _ (KeyIds ks)) =
"with gpg " ++ keys ks ++ " " ++ unwords ks
where
keys [_] = "key"
keys _ = "keys"
{- Stores an EncryptedCipher in a remote's configuration. -} {- Stores an EncryptedCipher in a remote's configuration. -}
storeCipher :: RemoteConfig -> EncryptedCipher -> RemoteConfig storeCipher :: RemoteConfig -> EncryptedCipher -> RemoteConfig
storeCipher c (EncryptedCipher t ks) = storeCipher c (EncryptedCipher t ks) =

View file

@ -27,11 +27,12 @@ encryptionSetup c =
(Just "none", Nothing) -> return c (Just "none", Nothing) -> return c
(Just "none", Just _) -> error "Cannot change encryption type of existing remote." (Just "none", Just _) -> error "Cannot change encryption type of existing remote."
(Nothing, Just _) -> return c (Nothing, Just _) -> return c
(Just _, Nothing) -> use $ genCipher c (Just _, Nothing) -> use "encryption setup" $ genCipher c
(Just _, Just v) -> use $ updateCipher c v (Just _, Just v) -> use "encryption updated" $ updateCipher c v
where where
use a = do use m a = do
cipher <- liftIO a cipher <- liftIO a
showNote $ m ++ " " ++ describeCipher cipher
return $ M.delete "encryption" $ storeCipher c cipher return $ M.delete "encryption" $ storeCipher c cipher
{- Modifies a Remote to support encryption. {- Modifies a Remote to support encryption.

View file

@ -15,7 +15,7 @@ like "2512E3C7"
Next, create the S3 remote, and describe it. Next, create the S3 remote, and describe it.
# git annex initremote cloud type=S3 encryption=2512E3C7 # git annex initremote cloud type=S3 encryption=2512E3C7
initremote cloud (checking bucket) (creating bucket in US) ok initremote cloud (encryption setup with gpg key C910D9222512E3C7) (checking bucket) (creating bucket in US) ok
# git annex describe cloud "at Amazon's US datacenter" # git annex describe cloud "at Amazon's US datacenter"
describe cloud ok describe cloud ok