Copyright | (c) Reto Hablützel 2014 |
---|---|
License | MIT |
Maintainer | rethab@rethab.ch |
Stability | experimental |
Portability | untested |
Safe Haskell | None |
Language | Haskell2010 |
High Level Binding for GnuPG Made Easy (gpgme)
Most of these functions are a one-to-one translation from GnuPG API with some Haskell idiomatics to make the API more convenient.
See the GnuPG manual for more information: https://www.gnupg.org/documentation/manuals/gpgme.pdf
Example (from the tests):
let alice_pub_fpr = "EAACEB8A" -- encrypt enc <- withCtx "test/bob" "C" openPGP $ \bCtx -> withKey bCtx alice_pub_fpr noSecret $ \aPubKey -> encrypt bCtx [aPubKey] noFlag plain -- decrypt dec <- withCtx "test/alice" "C" openPGP $ \aCtx -> decrypt aCtx (fromJustAndRight enc)
- data Ctx
- newCtx :: String -> String -> Protocol -> IO Ctx
- freeCtx :: Ctx -> IO ()
- withCtx :: String -> String -> Protocol -> (Ctx -> IO a) -> IO a
- data Key
- getKey :: Ctx -> Fpr -> IncludeSecret -> IO (Maybe Key)
- freeKey :: Key -> IO ()
- withKey :: Ctx -> Fpr -> IncludeSecret -> (Key -> IO a) -> IO (Maybe a)
- encrypt :: Ctx -> [Key] -> Flag -> Plain -> IO (Either [InvalidKey] Encrypted)
- encryptSign :: Ctx -> [Key] -> Flag -> Plain -> IO (Either [InvalidKey] Encrypted)
- encrypt' :: String -> Fpr -> Plain -> IO (Either String Encrypted)
- encryptSign' :: String -> Fpr -> Plain -> IO (Either String Encrypted)
- decrypt :: Ctx -> Encrypted -> IO (Either DecryptError Plain)
- decrypt' :: String -> Encrypted -> IO (Either DecryptError Plain)
- decryptVerify :: Ctx -> Encrypted -> IO (Either DecryptError Plain)
- decryptVerify' :: String -> Encrypted -> IO (Either DecryptError Plain)
- type Fpr = ByteString
- type Encrypted = ByteString
- type Plain = ByteString
- data Protocol
- openPGP :: Protocol
- type InvalidKey = (String, Int)
- data IncludeSecret
- noSecret :: IncludeSecret
- secret :: IncludeSecret
- data Flag
- alwaysTrust :: Flag
- noFlag :: Flag
- data DecryptError
Context
Context to be passed around with operations. Use newCtx
or
withCtx
in order to obtain an instance.
Keys
Encryption
encrypt :: Ctx -> [Key] -> Flag -> Plain -> IO (Either [InvalidKey] Encrypted) Source
encrypt for a list of recipients
encryptSign :: Ctx -> [Key] -> Flag -> Plain -> IO (Either [InvalidKey] Encrypted) Source
encrypt and sign for a list of recipients
decryptVerify :: Ctx -> Encrypted -> IO (Either DecryptError Plain) Source
Decrypts and verifies a ciphertext
decryptVerify' :: String -> Encrypted -> IO (Either DecryptError Plain) Source
Other Types
type Fpr = ByteString Source
a fingerprint
type Encrypted = ByteString Source
an ciphertext
type Plain = ByteString Source
a plaintext
type InvalidKey = (String, Int) Source
The fingerprint and an error code
data IncludeSecret Source
Whether to include secret keys when searching
noSecret :: IncludeSecret Source
do not consider secret keys when searching
secret :: IncludeSecret Source
consider secret keys when searching