From 051e4b171782df1a384c3fc5763c69e35d9f46ba Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Sun, 15 Apr 2012 12:35:00 -0500 Subject: Debianize --- debian/changelog | 6 +++ debian/compat | 1 + debian/control | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ debian/copyright | 13 ++++++ debian/rules | 7 ++++ 5 files changed, 151 insertions(+) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100755 debian/rules (limited to 'debian') diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..31d5882 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,6 @@ +haskell-openpgp (0.3-1~hackage1) unstable; urgency=low + + * Debianization generated by cabal-debian + + -- Stephen Paul Weber Sun, 15 Apr 2012 12:22:30 -0500 + diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..c793025 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +7 \ No newline at end of file diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..a4b9165 --- /dev/null +++ b/debian/control @@ -0,0 +1,124 @@ +Source: haskell-openpgp +Priority: extra +Section: haskell +Maintainer: Stephen Paul Weber +Build-Depends: debhelper (>= 7.0), + haskell-devscripts (>= 0.8), + cdbs, + ghc, + ghc-prof, + libghc-crypto-dev, + libghc-crypto-prof, + libghc-binary-dev, + libghc-binary-prof, + libghc-bzlib-dev, + libghc-bzlib-prof, + libghc-utf8-string-dev, + libghc-utf8-string-prof, + libghc-zlib-dev, + libghc-zlib-prof +Build-Depends-Indep: ghc-doc, + libghc-crypto-doc, + libghc-binary-doc, + libghc-bzlib-doc, + libghc-utf8-string-doc, + libghc-zlib-doc +Standards-Version: 3.9.1 +Homepage: http://github.com/singpolyma/OpenPGP-Haskell + +Package: libghc-openpgp-dev +Architecture: any +Depends: ${shlibs:Depends}, + ${haskell:Depends}, + ${misc:Depends} +Recommends: ${haskell:Recommends} +Suggests: ${haskell:Suggests} +Provides: ${haskell:Provides} +Description: Implementation of the OpenPGP message format + This is an OpenPGP library inspired by my work on OpenPGP libraries in + Ruby , + PHP , + and Python . + . + It defines types to represent OpenPGP messages as a series of packets + and then defines instances of Data.Binary for each to facilitate + encoding/decoding. + . + There is also a wrapper around + that currently does fingerprint generation, signature generation, and + signature verification (for RSA keys only). + . + It is intended that you use qualified imports with this library. If importing + both modules, something like this will do: + . + > import qualified Data.OpenPGP as OpenPGP + > import qualified Data.OpenPGP.Crypto as OpenPGP + . + Author: Stephen Paul Weber + Upstream-Maintainer: Stephen Paul Weber + . + This package contains the normal library files. + +Package: libghc-openpgp-prof +Architecture: any +Depends: ${haskell:Depends}, + ${misc:Depends} +Recommends: ${haskell:Recommends} +Suggests: ${haskell:Suggests} +Provides: ${haskell:Provides} +Description: Implementation of the OpenPGP message format + This is an OpenPGP library inspired by my work on OpenPGP libraries in + Ruby , + PHP , + and Python . + . + It defines types to represent OpenPGP messages as a series of packets + and then defines instances of Data.Binary for each to facilitate + encoding/decoding. + . + There is also a wrapper around + that currently does fingerprint generation, signature generation, and + signature verification (for RSA keys only). + . + It is intended that you use qualified imports with this library. If importing + both modules, something like this will do: + . + > import qualified Data.OpenPGP as OpenPGP + > import qualified Data.OpenPGP.Crypto as OpenPGP + . + Author: Stephen Paul Weber + Upstream-Maintainer: Stephen Paul Weber + . + This package contains the libraries compiled with profiling enabled. + +Package: libghc-openpgp-doc +Architecture: all +Section: doc +Depends: ${haskell:Depends}, + ${misc:Depends} +Recommends: ${haskell:Recommends} +Suggests: ${haskell:Suggests} +Description: Implementation of the OpenPGP message format + This is an OpenPGP library inspired by my work on OpenPGP libraries in + Ruby , + PHP , + and Python . + . + It defines types to represent OpenPGP messages as a series of packets + and then defines instances of Data.Binary for each to facilitate + encoding/decoding. + . + There is also a wrapper around + that currently does fingerprint generation, signature generation, and + signature verification (for RSA keys only). + . + It is intended that you use qualified imports with this library. If importing + both modules, something like this will do: + . + > import qualified Data.OpenPGP as OpenPGP + > import qualified Data.OpenPGP.Crypto as OpenPGP + . + Author: Stephen Paul Weber + Upstream-Maintainer: Stephen Paul Weber + . + This package contains the documentation files. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..55234e7 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,13 @@ +Copyright © 2011, Stephen Paul Weber + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..cc204b3 --- /dev/null +++ b/debian/rules @@ -0,0 +1,7 @@ +#!/usr/bin/make -f +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/class/hlibrary.mk + +# How to install an extra file into the documentation package +#binary-fixup/libghc-openpgp-doc:: +# echo "Some informative text" > debian/libghc-openpgp-doc/usr/share/doc/libghc-openpgp-doc/AnExtraDocFile -- cgit v1.2.3 From 6b743222684f2b8151dfbdef42f0dc890e590c41 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Wed, 25 Apr 2012 17:19:07 -0500 Subject: Split OpenPGP.Crypto out into a seperate package --- Data/OpenPGP/Crypto.hs | 183 ----------------------------------- Makefile | 23 ++--- README | 8 +- debian/control | 27 ++---- examples/keygen.hs | 43 -------- examples/sign.hs | 23 ----- examples/verify.hs | 14 --- openpgp.cabal | 22 ++--- tests/data/encryption-sym-aes256.gpg | 1 - tests/data/encryption-sym-cast5.gpg | Bin 72 -> 0 bytes tests/data/encryption.gpg | Bin 860 -> 0 bytes tests/data/msg1.asc | 7 -- tests/suite.hs | 57 +---------- 13 files changed, 28 insertions(+), 380 deletions(-) delete mode 100644 Data/OpenPGP/Crypto.hs delete mode 100644 examples/keygen.hs delete mode 100644 examples/sign.hs delete mode 100644 examples/verify.hs delete mode 100644 tests/data/encryption-sym-aes256.gpg delete mode 100644 tests/data/encryption-sym-cast5.gpg delete mode 100644 tests/data/encryption.gpg delete mode 100644 tests/data/msg1.asc (limited to 'debian') diff --git a/Data/OpenPGP/Crypto.hs b/Data/OpenPGP/Crypto.hs deleted file mode 100644 index 54fb81e..0000000 --- a/Data/OpenPGP/Crypto.hs +++ /dev/null @@ -1,183 +0,0 @@ --- | This is a wrapper around --- that currently does fingerprint generation and signature verification. --- --- The recommended way to import this module is: --- --- > import qualified Data.OpenPGP.Crypto as OpenPGP -module Data.OpenPGP.Crypto (sign, verify, fingerprint) where - -import Numeric -import Data.Word -import Data.Char -import Data.List (find) -import Data.Map ((!)) -import qualified Data.ByteString.Lazy as LZ -import qualified Data.ByteString.Lazy.UTF8 as LZ (fromString) - -import Data.Binary -import Codec.Utils (fromOctets) -import qualified Codec.Encryption.RSA as RSA -import qualified Data.Digest.MD5 as MD5 -import qualified Data.Digest.SHA1 as SHA1 -import qualified Data.Digest.SHA256 as SHA256 -import qualified Data.Digest.SHA384 as SHA384 -import qualified Data.Digest.SHA512 as SHA512 - -import qualified Data.OpenPGP as OpenPGP - --- | Generate a key fingerprint from a PublicKeyPacket or SecretKeyPacket --- -fingerprint :: OpenPGP.Packet -> String -fingerprint p - | OpenPGP.version p == 4 = - map toUpper $ (`showHex` "") $ SHA1.toInteger $ SHA1.hash $ - LZ.unpack (LZ.concat (OpenPGP.fingerprint_material p)) - | OpenPGP.version p `elem` [2, 3] = - map toUpper $ foldr (pad `oo` showHex) "" $ - MD5.hash $ LZ.unpack (LZ.concat (OpenPGP.fingerprint_material p)) - | otherwise = error "Unsupported Packet version or type in fingerprint" - where - oo = (.) . (.) - pad s | odd $ length s = '0':s - | otherwise = s - -find_key :: OpenPGP.Message -> String -> Maybe OpenPGP.Packet -find_key (OpenPGP.Message (x@(OpenPGP.PublicKeyPacket {}):xs)) keyid = - find_key_ x xs keyid -find_key (OpenPGP.Message (x@(OpenPGP.SecretKeyPacket {}):xs)) keyid = - find_key_ x xs keyid -find_key (OpenPGP.Message (_:xs)) keyid = - find_key (OpenPGP.Message xs) keyid -find_key _ _ = Nothing - -find_key_ :: OpenPGP.Packet -> [OpenPGP.Packet] -> String -> Maybe OpenPGP.Packet -find_key_ x xs keyid - | thisid == keyid = Just x - | otherwise = find_key (OpenPGP.Message xs) keyid - where - thisid = reverse $ take (length keyid) (reverse (fingerprint x)) - -keyfield_as_octets :: OpenPGP.Packet -> Char -> [Word8] -keyfield_as_octets k f = - LZ.unpack $ LZ.drop 2 (encode (k' ! f)) - where k' = OpenPGP.key k - --- http://tools.ietf.org/html/rfc3447#page-43 -emsa_pkcs1_v1_5_hash_padding :: OpenPGP.HashAlgorithm -> [Word8] -emsa_pkcs1_v1_5_hash_padding OpenPGP.MD5 = [0x30, 0x20, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x05, 0x05, 0x00, 0x04, 0x10] -emsa_pkcs1_v1_5_hash_padding OpenPGP.SHA1 = [0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14] -emsa_pkcs1_v1_5_hash_padding OpenPGP.SHA256 = [0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20] -emsa_pkcs1_v1_5_hash_padding OpenPGP.SHA384 = [0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30] -emsa_pkcs1_v1_5_hash_padding OpenPGP.SHA512 = [0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40] -emsa_pkcs1_v1_5_hash_padding _ = - error "Unsupported HashAlgorithm in emsa_pkcs1_v1_5_hash_padding." - -hash :: OpenPGP.HashAlgorithm -> [Word8] -> [Word8] -hash OpenPGP.MD5 = MD5.hash -hash OpenPGP.SHA1 = drop 2 . LZ.unpack . encode . OpenPGP.MPI . SHA1.toInteger . SHA1.hash -hash OpenPGP.SHA256 = SHA256.hash -hash OpenPGP.SHA384 = SHA384.hash -hash OpenPGP.SHA512 = SHA512.hash -hash _ = error "Unsupported HashAlgorithm in hash." - -emsa_pkcs1_v1_5_encode :: [Word8] -> Int -> OpenPGP.HashAlgorithm -> [Word8] -emsa_pkcs1_v1_5_encode m emLen algo = - [0, 1] ++ replicate (emLen - length t - 3) 0xff ++ [0] ++ t - where t = emsa_pkcs1_v1_5_hash_padding algo ++ hash algo m - --- | Verify a message signature. Only supports RSA keys for now. -verify :: OpenPGP.Message -- ^ Keys that may have made the signature - -> OpenPGP.Message -- ^ LiteralData message to verify - -> Int -- ^ Index of signature to verify (0th, 1st, etc) - -> Bool -verify keys message sigidx = - encoded == RSA.encrypt (n, e) raw_sig - where - raw_sig = LZ.unpack $ LZ.drop 2 $ encode (OpenPGP.signature sig) - encoded = emsa_pkcs1_v1_5_encode signature_over - (length n) (OpenPGP.hash_algorithm sig) - signature_over = LZ.unpack $ dta `LZ.append` OpenPGP.trailer sig - (n, e) = (keyfield_as_octets k 'n', keyfield_as_octets k 'e') - Just k = find_key keys issuer - Just issuer = OpenPGP.signature_issuer sig - sig = sigs !! sigidx - (sigs, (OpenPGP.LiteralDataPacket {OpenPGP.content = dta}):_) = - OpenPGP.signatures_and_data message - --- | Sign data or key/userID pair. Only supports RSA keys for now. -sign :: OpenPGP.Message -- ^ SecretKeys, one of which will be used - -> OpenPGP.Message -- ^ Message containing data or key to sign, and optional signature packet - -> OpenPGP.HashAlgorithm -- ^ HashAlgorithm to use in signature - -> String -- ^ KeyID of key to choose or @[]@ for first - -> Integer -- ^ Timestamp for signature (unless sig supplied) - -> OpenPGP.Packet -sign keys message hsh keyid timestamp = - -- WARNING: this style of update is unsafe on most fields - -- it is safe on signature and hash_head, though - sig { - OpenPGP.signature = OpenPGP.MPI $ toNum final, - OpenPGP.hash_head = toNum $ take 2 final - } - where - -- toNum has explicit param so that it can remain polymorphic - toNum l = fromOctets (256::Integer) l - final = dropWhile (==0) $ RSA.decrypt (n, d) encoded - encoded = emsa_pkcs1_v1_5_encode dta (length n) hsh - (n, d) = (keyfield_as_octets k 'n', keyfield_as_octets k 'd') - dta = LZ.unpack $ case signOver of { - OpenPGP.LiteralDataPacket {OpenPGP.content = c} -> c; - _ -> LZ.concat $ OpenPGP.fingerprint_material signOver ++ [ - LZ.singleton 0xB4, - encode (fromIntegral (length firstUserID) :: Word32), - LZ.fromString firstUserID - ] - } `LZ.append` OpenPGP.trailer sig - sig = findSigOrDefault (find OpenPGP.isSignaturePacket m) - - -- Either a SignaturePacket was found, or we need to make one - findSigOrDefault (Just s) = OpenPGP.signaturePacket - (OpenPGP.version s) - (OpenPGP.signature_type s) - OpenPGP.RSA -- force key and hash algorithm - hsh - (OpenPGP.hashed_subpackets s) - (OpenPGP.unhashed_subpackets s) - (OpenPGP.hash_head s) - (OpenPGP.signature s) - findSigOrDefault Nothing = OpenPGP.signaturePacket - 4 - defaultStype - OpenPGP.RSA - hsh - ([ - -- Do we really need to pass in timestamp just for the default? - OpenPGP.SignatureCreationTimePacket $ fromIntegral timestamp, - OpenPGP.IssuerPacket keyid' - ] ++ (case signOver of - OpenPGP.LiteralDataPacket {} -> [] - _ -> [] -- TODO: OpenPGP.KeyFlagsPacket [0x01, 0x02] - )) - [] - undefined - undefined - - keyid' = reverse $ take 16 $ reverse $ fingerprint k - Just k = find_key keys keyid - - Just (OpenPGP.UserIDPacket firstUserID) = find isUserID m - - defaultStype = case signOver of - OpenPGP.LiteralDataPacket {OpenPGP.format = f} -> - if f == 'b' then 0x00 else 0x01 - _ -> 0x13 - - Just signOver = find isSignable m - OpenPGP.Message m = message - - isSignable (OpenPGP.LiteralDataPacket {}) = True - isSignable (OpenPGP.PublicKeyPacket {}) = True - isSignable (OpenPGP.SecretKeyPacket {}) = True - isSignable _ = False - - isUserID (OpenPGP.UserIDPacket {}) = True - isUserID _ = False diff --git a/Makefile b/Makefile index 10f66fa..85dc9db 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ VERSION=0.3 .PHONY: all clean doc install debian test -all: sign verify keygen test report.html doc dist/build/libHSopenpgp-$(VERSION).a dist/openpgp-$(VERSION).tar.gz +all: test report.html doc dist/build/libHSopenpgp-$(VERSION).a dist/openpgp-$(VERSION).tar.gz install: dist/build/libHSopenpgp-$(VERSION).a cabal install @@ -14,20 +14,11 @@ debian: debian/control test: tests/suite tests/suite -sign: examples/sign.hs Data/*.hs Data/OpenPGP/*.hs +tests/suite: tests/suite.hs Data/OpenPGP.hs ghc --make $(GHCFLAGS) -o $@ $^ -verify: examples/verify.hs Data/*.hs Data/OpenPGP/*.hs - ghc --make $(GHCFLAGS) -o $@ $^ - -keygen: examples/keygen.hs Data/*.hs Data/OpenPGP/*.hs - ghc --make $(GHCFLAGS) -o $@ $^ - -tests/suite: tests/suite.hs Data/*.hs Data/OpenPGP/*.hs - ghc --make $(GHCFLAGS) -o $@ $^ - -report.html: examples/*.hs Data/*.hs Data/OpenPGP/*.hs tests/*.hs - -hlint $(HLINTFLAGS) --report Data examples +report.html: Data/OpenPGP.hs tests/suite.hs + -hlint $(HLINTFLAGS) --report $^ doc: dist/doc/html/openpgp/index.html README @@ -37,7 +28,7 @@ README: openpgp.cabal -printf ',s/ //g\n,s/^.$$//g\nw\nq\n' | ed $@ $(RM) .$@ -dist/doc/html/openpgp/index.html: dist/setup-config Data/OpenPGP.hs Data/OpenPGP/Crypto.hs +dist/doc/html/openpgp/index.html: dist/setup-config Data/OpenPGP.hs cabal haddock --hyperlink-source dist/setup-config: openpgp.cabal @@ -51,9 +42,9 @@ clean: debian/control: openpgp.cabal cabal-debian --update-debianization -dist/build/libHSopenpgp-$(VERSION).a: openpgp.cabal dist/setup-config Data/OpenPGP.hs Data/OpenPGP/Crypto.hs +dist/build/libHSopenpgp-$(VERSION).a: openpgp.cabal dist/setup-config Data/OpenPGP.hs cabal build --ghc-options="$(GHCFLAGS)" -dist/openpgp-$(VERSION).tar.gz: openpgp.cabal dist/setup-config Data/OpenPGP.hs Data/OpenPGP/Crypto.hs README +dist/openpgp-$(VERSION).tar.gz: openpgp.cabal dist/setup-config Data/OpenPGP.hs README cabal check cabal sdist diff --git a/README b/README index b5d1332..0bed65f 100644 --- a/README +++ b/README @@ -7,12 +7,8 @@ It defines types to represent OpenPGP messages as a series of packets and then defines instances of Data.Binary for each to facilitate encoding/decoding. -There is also a wrapper around -that currently does fingerprint generation, signature generation, and -signature verification (for RSA keys only). +For performing cryptography, see -It is intended that you use qualified imports with this library. If importing -both modules, something like this will do: +It is intended that you use qualified imports with this library. > import qualified Data.OpenPGP as OpenPGP -> import qualified Data.OpenPGP.Crypto as OpenPGP diff --git a/debian/control b/debian/control index a4b9165..679e316 100644 --- a/debian/control +++ b/debian/control @@ -7,8 +7,6 @@ Build-Depends: debhelper (>= 7.0), cdbs, ghc, ghc-prof, - libghc-crypto-dev, - libghc-crypto-prof, libghc-binary-dev, libghc-binary-prof, libghc-bzlib-dev, @@ -18,7 +16,6 @@ Build-Depends: debhelper (>= 7.0), libghc-zlib-dev, libghc-zlib-prof Build-Depends-Indep: ghc-doc, - libghc-crypto-doc, libghc-binary-doc, libghc-bzlib-doc, libghc-utf8-string-doc, @@ -44,15 +41,11 @@ Description: Implementation of the OpenPGP message format and then defines instances of Data.Binary for each to facilitate encoding/decoding. . - There is also a wrapper around - that currently does fingerprint generation, signature generation, and - signature verification (for RSA keys only). + For performing cryptography, see . - It is intended that you use qualified imports with this library. If importing - both modules, something like this will do: + It is intended that you use qualified imports with this library. . > import qualified Data.OpenPGP as OpenPGP - > import qualified Data.OpenPGP.Crypto as OpenPGP . Author: Stephen Paul Weber Upstream-Maintainer: Stephen Paul Weber @@ -76,15 +69,11 @@ Description: Implementation of the OpenPGP message format and then defines instances of Data.Binary for each to facilitate encoding/decoding. . - There is also a wrapper around - that currently does fingerprint generation, signature generation, and - signature verification (for RSA keys only). + For performing cryptography, see . - It is intended that you use qualified imports with this library. If importing - both modules, something like this will do: + It is intended that you use qualified imports with this library. . > import qualified Data.OpenPGP as OpenPGP - > import qualified Data.OpenPGP.Crypto as OpenPGP . Author: Stephen Paul Weber Upstream-Maintainer: Stephen Paul Weber @@ -108,15 +97,11 @@ Description: Implementation of the OpenPGP message format and then defines instances of Data.Binary for each to facilitate encoding/decoding. . - There is also a wrapper around - that currently does fingerprint generation, signature generation, and - signature verification (for RSA keys only). + For performing cryptography, see . - It is intended that you use qualified imports with this library. If importing - both modules, something like this will do: + It is intended that you use qualified imports with this library. . > import qualified Data.OpenPGP as OpenPGP - > import qualified Data.OpenPGP.Crypto as OpenPGP . Author: Stephen Paul Weber Upstream-Maintainer: Stephen Paul Weber diff --git a/examples/keygen.hs b/examples/keygen.hs deleted file mode 100644 index 65c3e33..0000000 --- a/examples/keygen.hs +++ /dev/null @@ -1,43 +0,0 @@ -import System.Time (getClockTime, ClockTime(..)) -import qualified Data.Map as Map -import qualified Data.ByteString.Lazy as LZ - -import Data.Binary -import OpenSSL.RSA -import Control.Arrow (second) -import Codec.Encryption.RSA.NumberTheory (extEuclGcd) - -import qualified Data.OpenPGP as OpenPGP -import qualified Data.OpenPGP.Crypto as OpenPGP - -main :: IO () -main = do - time <- getClockTime - let TOD t _ = time - - nkey <- generateRSAKey' 1042 65537 - - let secretKey = OpenPGP.SecretKeyPacket { - OpenPGP.version = 4, - OpenPGP.timestamp = fromIntegral t, - OpenPGP.key_algorithm = OpenPGP.RSA, - OpenPGP.key = Map.fromList $ map (second OpenPGP.MPI) - [('n', rsaN nkey), ('e', rsaE nkey), - ('d', rsaD nkey), ('p', rsaP nkey), ('q', rsaQ nkey), - ('u', fst $ extEuclGcd (rsaP nkey) (rsaQ nkey))], - OpenPGP.s2k_useage = 0, - OpenPGP.symmetric_type = undefined, - OpenPGP.s2k_type = undefined, - OpenPGP.s2k_hash_algorithm = undefined, - OpenPGP.s2k_salt = undefined, - OpenPGP.s2k_count = undefined, - OpenPGP.encrypted_data = undefined, - OpenPGP.private_hash = undefined } - - let userID = OpenPGP.UserIDPacket "Test " - let message = OpenPGP.Message[ secretKey, userID ] - - let message' = OpenPGP.Message [ secretKey, userID, - OpenPGP.sign message message OpenPGP.SHA256 [] (fromIntegral t)] - - LZ.putStr $ encode message' diff --git a/examples/sign.hs b/examples/sign.hs deleted file mode 100644 index e8bea1a..0000000 --- a/examples/sign.hs +++ /dev/null @@ -1,23 +0,0 @@ -import System (getArgs) -import System.Time (getClockTime, ClockTime(..)) - -import Data.Binary - -import qualified Data.OpenPGP as OpenPGP -import qualified Data.OpenPGP.Crypto as OpenPGP -import qualified Data.ByteString.Lazy as LZ -import qualified Data.ByteString.Lazy.UTF8 as LZ - -main :: IO () -main = do - argv <- getArgs - time <- getClockTime - let TOD t _ = time - keys <- decodeFile (argv !! 0) - let dataPacket = OpenPGP.LiteralDataPacket 'u' "t.txt" - (fromIntegral t) (LZ.fromString "This is a message.") - let message = OpenPGP.Message [ - OpenPGP.sign keys (OpenPGP.Message [dataPacket]) - OpenPGP.SHA256 [] (fromIntegral t), - dataPacket] - LZ.putStr $ encode message diff --git a/examples/verify.hs b/examples/verify.hs deleted file mode 100644 index b123bd1..0000000 --- a/examples/verify.hs +++ /dev/null @@ -1,14 +0,0 @@ -import System (getArgs) - -import Data.Binary - -import qualified Data.OpenPGP as OpenPGP () -import qualified Data.OpenPGP.Crypto as OpenPGP - -main :: IO () -main = do - argv <- getArgs - keys <- decodeFile (argv !! 0) - message <- decodeFile (argv !! 1) - -- Just verify first signature - print $ OpenPGP.verify keys message 0 diff --git a/openpgp.cabal b/openpgp.cabal index 0a40b94..3f3d592 100644 --- a/openpgp.cabal +++ b/openpgp.cabal @@ -23,15 +23,11 @@ description: and then defines instances of Data.Binary for each to facilitate encoding/decoding. . - There is also a wrapper around - that currently does fingerprint generation, signature generation, and - signature verification (for RSA keys only). + For performing cryptography, see . - It is intended that you use qualified imports with this library. If importing - both modules, something like this will do: + It is intended that you use qualified imports with this library. . > import qualified Data.OpenPGP as OpenPGP - > import qualified Data.OpenPGP.Crypto as OpenPGP extra-source-files: README, @@ -114,19 +110,19 @@ extra-source-files: tests/data/000076-007.secret_subkey, tests/data/000077-002.sig, tests/data/000078-012.ring_trust, + tests/data/compressedsig-bzip2.gpg, + tests/data/compressedsig.gpg, + tests/data/compressedsig-zlib.gpg, + tests/data/onepass_sig, tests/data/pubring.gpg, tests/data/secring.gpg, - tests/data/compressedsig.gpg, - tests/data/msg1.asc, - tests/data/uncompressed-ops-rsa.gpg, tests/data/uncompressed-ops-dsa.gpg, tests/data/uncompressed-ops-dsa-sha384.txt.gpg, - tests/data/encryption.gpg + tests/data/uncompressed-ops-rsa.gpg library exposed-modules: Data.OpenPGP - Data.OpenPGP.Crypto build-depends: base == 4.*, @@ -135,8 +131,7 @@ library utf8-string, binary, zlib, - bzlib, - Crypto + bzlib test-suite tests type: exitcode-stdio-1.0 @@ -150,7 +145,6 @@ test-suite tests binary, zlib, bzlib, - Crypto, HUnit, QuickCheck >= 2.4.1.1, test-framework, diff --git a/tests/data/encryption-sym-aes256.gpg b/tests/data/encryption-sym-aes256.gpg deleted file mode 100644 index 264ae11..0000000 --- a/tests/data/encryption-sym-aes256.gpg +++ /dev/null @@ -1 +0,0 @@ -  '6*W`VLEQjNp(Y3N*?!M**ۈ; hL2+!x̄&&\J{q<16.-D ޿ \ No newline at end of file diff --git a/tests/data/encryption-sym-cast5.gpg b/tests/data/encryption-sym-cast5.gpg deleted file mode 100644 index 2c552ac..0000000 Binary files a/tests/data/encryption-sym-cast5.gpg and /dev/null differ diff --git a/tests/data/encryption.gpg b/tests/data/encryption.gpg deleted file mode 100644 index 9781572..0000000 Binary files a/tests/data/encryption.gpg and /dev/null differ diff --git a/tests/data/msg1.asc b/tests/data/msg1.asc deleted file mode 100644 index 832d3bb..0000000 --- a/tests/data/msg1.asc +++ /dev/null @@ -1,7 +0,0 @@ ------BEGIN PGP MESSAGE----- -Version: OpenPrivacy 0.99 - -yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS -vBSFjNSiVHsuAA== -=njUN ------END PGP MESSAGE----- diff --git a/tests/suite.hs b/tests/suite.hs index 7ea5e57..ad7a8f2 100644 --- a/tests/suite.hs +++ b/tests/suite.hs @@ -7,9 +7,7 @@ import Test.HUnit hiding (Test) import Data.Word import Data.Binary import qualified Data.OpenPGP as OpenPGP -import qualified Data.OpenPGP.Crypto as OpenPGP import qualified Data.ByteString.Lazy as LZ -import qualified Data.ByteString.Lazy.UTF8 as LZ (fromString) instance Arbitrary OpenPGP.HashAlgorithm where arbitrary = elements [OpenPGP.MD5, OpenPGP.SHA1, OpenPGP.SHA256, OpenPGP.SHA384, OpenPGP.SHA512] @@ -18,8 +16,8 @@ testSerialization :: FilePath -> Assertion testSerialization fp = do bs <- LZ.readFile $ "tests/data/" ++ fp nullShield "First" (decode bs) (\firstpass -> - nullShield "Second" (decode $ encode firstpass) (\secondpass -> - assertEqual ("for " ++ fp) firstpass secondpass + nullShield "Second" (decode $ encode firstpass) ( + assertEqual ("for " ++ fp) firstpass ) ) where @@ -27,38 +25,12 @@ testSerialization fp = do assertFailure $ pass ++ " pass of " ++ fp ++ " decoded to nothing." nullShield _ m f = f m -testFingerprint :: FilePath -> String -> Assertion -testFingerprint fp kf = do - bs <- LZ.readFile $ "tests/data/" ++ fp - let (OpenPGP.Message [packet]) = decode bs - assertEqual ("for " ++ fp) kf (OpenPGP.fingerprint packet) - -testVerifyMessage :: FilePath -> FilePath -> Assertion -testVerifyMessage keyring message = do - keys <- fmap decode $ LZ.readFile $ "tests/data/" ++ keyring - m <- fmap decode $ LZ.readFile $ "tests/data/" ++ message - let verification = OpenPGP.verify keys m 0 - assertEqual (keyring ++ " for " ++ message) True verification - -prop_sign_and_verify :: OpenPGP.Message -> String -> OpenPGP.HashAlgorithm -> String -> String -> Bool -prop_sign_and_verify secring kid halgo filename msg = - let - m = OpenPGP.LiteralDataPacket { - OpenPGP.format = 'u', - OpenPGP.filename = filename, - OpenPGP.timestamp = 12341234, - OpenPGP.content = LZ.fromString msg - } - sig = OpenPGP.sign secring (OpenPGP.Message [m]) halgo kid 12341234 - in - OpenPGP.verify secring (OpenPGP.Message [m,sig]) 0 - prop_s2k_count :: Word8 -> Bool prop_s2k_count c = c == OpenPGP.encode_s2k_count (OpenPGP.decode_s2k_count c) -tests :: OpenPGP.Message -> [Test] -tests secring = +tests :: [Test] +tests = [ testGroup "Serialization" [ testCase "000001-006.public_key" (testSerialization "000001-006.public_key"), @@ -148,29 +120,10 @@ tests secring = testCase "uncompressed-ops-dsa.gpg" (testSerialization "uncompressed-ops-dsa.gpg"), testCase "uncompressed-ops-rsa.gpg" (testSerialization "uncompressed-ops-rsa.gpg") ], - testGroup "Fingerprint" [ - testCase "000001-006.public_key" (testFingerprint "000001-006.public_key" "421F28FEAAD222F856C8FFD5D4D54EA16F87040E"), - testCase "000016-006.public_key" (testFingerprint "000016-006.public_key" "AF95E4D7BAC521EE9740BED75E9F1523413262DC"), - testCase "000027-006.public_key" (testFingerprint "000027-006.public_key" "1EB20B2F5A5CC3BEAFD6E5CB7732CF988A63EA86"), - testCase "000035-006.public_key" (testFingerprint "000035-006.public_key" "CB7933459F59C70DF1C3FBEEDEDC3ECF689AF56D") - ], - testGroup "Message verification" [ - --testCase "uncompressed-ops-dsa" (testVerifyMessage "pubring.gpg" "uncompressed-ops-dsa.gpg"), - --testCase "uncompressed-ops-dsa-sha384" (testVerifyMessage "pubring.gpg" "uncompressed-ops-dsa-sha384.txt.gpg"), - testCase "uncompressed-ops-rsa" (testVerifyMessage "pubring.gpg" "uncompressed-ops-rsa.gpg"), - testCase "compressedsig" (testVerifyMessage "pubring.gpg" "compressedsig.gpg"), - testCase "compressedsig-zlib" (testVerifyMessage "pubring.gpg" "compressedsig-zlib.gpg"), - testCase "compressedsig-bzip2" (testVerifyMessage "pubring.gpg" "compressedsig-bzip2.gpg") - ], - testGroup "Signing" [ - testProperty "Crypto signatures verify" (prop_sign_and_verify secring "FEF8AFA0F661C3EE") - ], testGroup "S2K count" [ testProperty "S2K count encode reverses decode" prop_s2k_count ] ] main :: IO () -main = do - secring <- fmap decode $ LZ.readFile "tests/data/secring.gpg" - defaultMain (tests secring) +main = defaultMain tests -- cgit v1.2.3 From 1ef98205821990faa671dcb8efd949134e5e4c02 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Fri, 30 Nov 2012 17:53:25 -0500 Subject: Stop using !! 0 --- Data/OpenPGP.hs | 12 +++++++----- Makefile | 2 +- debian/changelog | 6 ++++++ debian/control | 12 +++++++++--- 4 files changed, 23 insertions(+), 9 deletions(-) (limited to 'debian') diff --git a/Data/OpenPGP.hs b/Data/OpenPGP.hs index a268dff..94bcb6d 100644 --- a/Data/OpenPGP.hs +++ b/Data/OpenPGP.hs @@ -1093,11 +1093,13 @@ parse_signature_subpacket tag = signature_issuer :: Packet -> Maybe String signature_issuer (SignaturePacket {hashed_subpackets = hashed, unhashed_subpackets = unhashed}) = - if length issuers > 0 then Just issuer else Nothing - where IssuerPacket issuer = issuers !! 0 - issuers = filter isIssuer hashed ++ filter isIssuer unhashed - isIssuer (IssuerPacket {}) = True - isIssuer _ = False + case issuers of + IssuerPacket issuer : _ -> Just issuer + _ -> Nothing + where + issuers = filter isIssuer hashed ++ filter isIssuer unhashed + isIssuer (IssuerPacket {}) = True + isIssuer _ = False signature_issuer _ = Nothing find_key :: (Packet -> String) -> Message -> String -> Maybe Packet diff --git a/Makefile b/Makefile index 67e823b..076b00a 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ else GHCFLAGS=-Wall -O2 -fno-warn-name-shadowing -XHaskell98 endif -HLINTFLAGS=-XHaskell98 -XCPP -i 'Use camelCase' -i 'Use String' -i 'Use head' -i 'Use string literal' -i 'Use list comprehension' --utf8 +HLINTFLAGS=-u -XHaskell98 -XCPP -i 'Use camelCase' -i 'Use String' -i 'Use string literal' -i 'Use list comprehension' VERSION=0.4 .PHONY: all clean doc install debian test diff --git a/debian/changelog b/debian/changelog index 31d5882..60634f7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +haskell-openpgp (0.4-1~hackage1) unstable; urgency=low + + * Debianization generated by cabal-debian + + -- Stephen Paul Weber Thu, 01 Nov 2012 14:31:20 -0500 + haskell-openpgp (0.3-1~hackage1) unstable; urgency=low * Debianization generated by cabal-debian diff --git a/debian/control b/debian/control index 679e316..14b26b0 100644 --- a/debian/control +++ b/debian/control @@ -41,7 +41,9 @@ Description: Implementation of the OpenPGP message format and then defines instances of Data.Binary for each to facilitate encoding/decoding. . - For performing cryptography, see + For performing cryptography, see + or + . It is intended that you use qualified imports with this library. . @@ -69,7 +71,9 @@ Description: Implementation of the OpenPGP message format and then defines instances of Data.Binary for each to facilitate encoding/decoding. . - For performing cryptography, see + For performing cryptography, see + or + . It is intended that you use qualified imports with this library. . @@ -97,7 +101,9 @@ Description: Implementation of the OpenPGP message format and then defines instances of Data.Binary for each to facilitate encoding/decoding. . - For performing cryptography, see + For performing cryptography, see + or + . It is intended that you use qualified imports with this library. . -- cgit v1.2.3 From 37d5a99e9f2303780a7cdbf4730ace6eff58a466 Mon Sep 17 00:00:00 2001 From: joe Date: Tue, 28 Jan 2014 00:24:06 -0500 Subject: Backport to wheezy --- debian/changelog | 6 ++++++ openpgp.cabal | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 60634f7..1c40103 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +haskell-openpgp (0.6.1.1~samizdat1) UNRELEASED; urgency=medium + + * Backport to wheezy, ecdsa-support. + + -- Anonymous Mon, 27 Jan 2014 23:22:10 -0500 + haskell-openpgp (0.4-1~hackage1) unstable; urgency=low * Debianization generated by cabal-debian diff --git a/openpgp.cabal b/openpgp.cabal index d9af124..c23e4ad 100644 --- a/openpgp.cabal +++ b/openpgp.cabal @@ -1,5 +1,5 @@ name: openpgp -version: 0.6.1 +version: 0.6.1.1 cabal-version: >= 1.8 license: OtherLicense license-file: COPYING @@ -138,7 +138,7 @@ library base == 4.*, bytestring, utf8-string, - binary >= 0.5.1.1, + binary >= 0.5.1.0, zlib, bzlib -- cgit v1.2.3