packages feed

hOpenPGP 0.5.1 → 0.5.2

raw patch · 3 files changed

+35/−30 lines, 3 filesdep ~cryptocipher

Dependency ranges changed: cryptocipher

Files

Codec/Encryption/OpenPGP/Serialize.hs view
@@ -538,7 +538,7 @@             | t == 5 = do                           bs <- getBytes len                           let ps = flip runGet bs $ do pkp <- getPKPayload-                                                       ska <- getSKAddendum (pubKeyAlgo pkp)+                                                       ska <- getSKAddendum pkp                                                        return $ SecretKeyPkt pkp ska                           case ps of                               Left err -> error err@@ -549,7 +549,7 @@             | t == 7 = do                           bs <- getBytes len                           let ps = flip runGet bs $ do pkp <- getPKPayload-                                                       ska <- getSKAddendum (pubKeyAlgo pkp)+                                                       ska <- getSKAddendum pkp                                                        return $ SecretSubkeyPkt pkp ska                           case ps of                               Left err -> error err@@ -765,23 +765,24 @@ putPubkey :: PKey -> Put putPubkey p = mapM_ put (pubkeyToMPIs p) -getSecretKey :: PubKeyAlgorithm -> Get SKey-getSecretKey RSA = do MPI d <- get-                      MPI p <- get-                      MPI q <- get-                      MPI _ <- get-                      let n = p * q-                      let dP = 0-                      let dQ = 0-                      let qinv = 0-                      return $ RSAPrivateKey (R.PrivateKey 0 n d p q dP dQ qinv)-getSecretKey RSAEncryptOnly = getSecretKey RSA-getSecretKey RSASignOnly = getSecretKey RSA-getSecretKey DSA = do MPI x <- get-                      return $ DSAPrivateKey (D.PrivateKey (0,0,0) x)-getSecretKey ElgamalEncryptOnly = getSecretKey Elgamal-getSecretKey Elgamal = do MPI x <- get-                          return $ ElGamalPrivateKey [x]+getSecretKey :: PKPayload -> Get SKey+getSecretKey pkp+    | pubKeyAlgo pkp `elem` [RSA, RSAEncryptOnly, RSASignOnly] =+        do MPI d <- get+           MPI p <- get+           MPI q <- get+           MPI _ <- get -- u+           let n = p * q+               dP = 0+               dQ = 0+               qinv = 0+               pub = (\(RSAPubKey x) -> x) (pubKeyKey pkp)+           return $ RSAPrivateKey (R.PrivateKey pub d p q dP dQ qinv)+    | pubKeyAlgo pkp == DSA = do MPI x <- get+                                 return $ DSAPrivateKey (D.PrivateKey (0,0,0) x)+    | pubKeyAlgo pkp `elem` [ElgamalEncryptOnly,Elgamal] =+        do MPI x <- get+           return $ ElGamalPrivateKey [x]  -- indefiniteMPIs :: ByteString -> [MPI] -- indefiniteMPIs bs = do@@ -831,11 +832,15 @@ pubKeyAlgo (DeprecatedPubV3 _ _ pka _) = pka pubKeyAlgo (PubV4 _ pka _) = pka -getSKAddendum :: PubKeyAlgorithm -> Get SKAddendum-getSKAddendum pka = do+pubKeyKey :: PKPayload -> PKey+pubKeyKey (DeprecatedPubV3 _ _ _ k) = k+pubKeyKey (PubV4 _ _ k) = k++getSKAddendum :: PKPayload -> Get SKAddendum+getSKAddendum pkp = do     s2kusage <- getWord8     case s2kusage of-        0 -> do sk <- getSecretKey pka+        0 -> do sk <- getSecretKey pkp                 checksum <- getWord16be                 return $ SUUnencrypted sk checksum         255 -> do symenc <- getWord8
Codec/Encryption/OpenPGP/Types.hs view
@@ -68,7 +68,7 @@ import Data.ByteString (ByteString) import Data.Char (toLower, toUpper) import qualified Data.ByteString as B-import Data.List.Split (splitEvery)+import Data.List.Split (chunksOf) import Data.Map (Map) import Data.Set (Set) import Data.Word (Word8, Word16, Word32)@@ -565,22 +565,22 @@     show = w8sToHex . B.unpack . unEOKI  instance Read EightOctetKeyId where-    readsPrec _ = map ((EightOctetKeyId . B.pack *** concat) . unzip) . splitEvery 8 . hexToW8s+    readsPrec _ = map ((EightOctetKeyId . B.pack *** concat) . unzip) . chunksOf 8 . hexToW8s  newtype TwentyOctetFingerprint = TwentyOctetFingerprint {unTOF :: ByteString}     deriving (Eq)  instance Show TwentyOctetFingerprint where-    show = take 50 . concatMap (++" ") . concatMap (++[""]) . splitEvery 5 . splitEvery 4 . w8sToHex . B.unpack . unTOF+    show = take 50 . concatMap (++" ") . concatMap (++[""]) . chunksOf 5 . chunksOf 4 . w8sToHex . B.unpack . unTOF  instance Read TwentyOctetFingerprint where-    readsPrec _ = map ((TwentyOctetFingerprint . B.pack *** concat) . unzip) . splitEvery 20 . hexToW8s . filter (/= ' ')+    readsPrec _ = map ((TwentyOctetFingerprint . B.pack *** concat) . unzip) . chunksOf 20 . hexToW8s . filter (/= ' ')  w8sToHex :: [Word8] -> String w8sToHex = map toUpper . concatMap ((\x -> if length x == 1 then '0':x else x) . flip showHex "")  hexToW8s :: ReadS Word8-hexToW8s = concatMap readHex . splitEvery 2 . map toLower+hexToW8s = concatMap readHex . chunksOf 2 . map toLower  data TK = TK {     tkPKP :: PKPayload
hOpenPGP.cabal view
@@ -1,5 +1,5 @@ Name:                hOpenPGP-Version:             0.5.1+Version:             0.5.2 Synopsis:            native Haskell implementation of OpenPGP (RFC4880) Description:         native Haskell implementation of OpenPGP (RFC4880) Homepage:            http://floss.scru.org/hOpenPGP/@@ -136,7 +136,7 @@                , cereal-conduit        >= 0.6    && < 0.7                , conduit               >= 0.5    && < 0.6                , containers-               , cryptocipher+               , cryptocipher          >= 0.3.6                , cryptohash                , mtl                , openpgp-asciiarmor                 >= 0.1@@ -160,7 +160,7 @@                , cereal-conduit        >= 0.6    && < 0.7                , conduit               >= 0.5    && < 0.6                , containers-               , cryptocipher+               , cryptocipher          >= 0.3.6                , cryptohash                , mtl                , openpgp-asciiarmor                 >= 0.1