Hello community, here is the log from the commit of package ghc-x509-store for openSUSE:Factory checked in at 2015-08-25 07:19:25 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-x509-store (Old) and /work/SRC/openSUSE:Factory/.ghc-x509-store.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-x509-store" Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-x509-store/ghc-x509-store.changes 2015-05-28 09:53:28.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-x509-store.new/ghc-x509-store.changes 2015-08-25 08:48:29.000000000 +0200 @@ -1,0 +2,5 @@ +Thu Aug 6 20:35:08 UTC 2015 - mimi...@gmail.com + +- update to 1.6.0 + +------------------------------------------------------------------- Old: ---- x509-store-1.5.0.tar.gz New: ---- x509-store-1.6.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-x509-store.spec ++++++ --- /var/tmp/diff_new_pack.6ccCl8/_old 2015-08-25 08:48:30.000000000 +0200 +++ /var/tmp/diff_new_pack.6ccCl8/_new 2015-08-25 08:48:30.000000000 +0200 @@ -17,8 +17,8 @@ %global pkg_name x509-store -Name: ghc-%{pkg_name} -Version: 1.5.0 +Name: ghc-x509-store +Version: 1.6.0 Release: 0 Summary: X.509 collection accessing and storing methods Group: System/Libraries @@ -35,7 +35,7 @@ BuildRequires: ghc-asn1-types-devel BuildRequires: ghc-bytestring-devel BuildRequires: ghc-containers-devel -BuildRequires: ghc-crypto-pubkey-types-devel +BuildRequires: ghc-cryptonite-devel BuildRequires: ghc-directory-devel BuildRequires: ghc-filepath-devel BuildRequires: ghc-mtl-devel ++++++ x509-store-1.5.0.tar.gz -> x509-store-1.6.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/x509-store-1.5.0/Data/X509/File.hs new/x509-store-1.6.0/Data/X509/File.hs --- old/x509-store-1.5.0/Data/X509/File.hs 2014-10-19 11:37:43.000000000 +0200 +++ new/x509-store-1.6.0/Data/X509/File.hs 2015-06-19 22:15:16.000000000 +0200 @@ -9,9 +9,9 @@ import Data.ASN1.Encoding import Data.Maybe import qualified Data.X509 as X509 +import Data.X509.Memory (pemToKey) import Data.PEM (pemParseLBS, pemContent, pemName, PEM) import qualified Data.ByteString.Lazy as L -import qualified Crypto.Types.PubKey.DSA as DSA readPEMs :: FilePath -> IO [PEM] readPEMs filepath = do @@ -33,20 +33,3 @@ -- | return all the public key that were successfully read from a file. readKeyFile :: FilePath -> IO [X509.PrivKey] readKeyFile path = catMaybes . foldl pemToKey [] <$> readPEMs path - where pemToKey acc pem = do - case decodeASN1' BER (pemContent pem) of - Left _ -> acc - Right asn1 -> case pemName pem of - "PRIVATE KEY" -> - tryRSA asn1 : tryDSA asn1 : acc - "RSA PRIVATE KEY" -> - tryRSA asn1 : acc - "DSA PRIVATE KEY" -> - tryDSA asn1 : acc - _ -> acc - tryRSA asn1 = case fromASN1 asn1 of - Left _ -> Nothing - Right (k,_) -> Just $ X509.PrivKeyRSA k - tryDSA asn1 = case fromASN1 asn1 of - Left _ -> Nothing - Right (k,_) -> Just $ X509.PrivKeyDSA $ DSA.toPrivateKey k diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/x509-store-1.5.0/Data/X509/Memory.hs new/x509-store-1.6.0/Data/X509/Memory.hs --- old/x509-store-1.5.0/Data/X509/Memory.hs 2014-10-19 11:37:43.000000000 +0200 +++ new/x509-store-1.6.0/Data/X509/Memory.hs 2015-06-19 22:15:16.000000000 +0200 @@ -9,6 +9,7 @@ module Data.X509.Memory ( readKeyFileFromMemory , readSignedObjectFromMemory + , pemToKey ) where import Data.ASN1.Types @@ -18,27 +19,11 @@ import qualified Data.X509 as X509 import Data.PEM (pemParseBS, pemContent, pemName, PEM) import qualified Data.ByteString as B -import qualified Crypto.Types.PubKey.DSA as DSA +import qualified Crypto.PubKey.DSA as DSA +import qualified Crypto.PubKey.RSA as RSA readKeyFileFromMemory :: B.ByteString -> [X509.PrivKey] readKeyFileFromMemory = either (const []) (catMaybes . foldl pemToKey []) . pemParseBS - where pemToKey acc pem = - case decodeASN1' BER (pemContent pem) of - Left _ -> acc - Right asn1 -> case pemName pem of - "PRIVATE KEY" -> - tryRSA asn1 : tryDSA asn1 : acc - "RSA PRIVATE KEY" -> - tryRSA asn1 : acc - "DSA PRIVATE KEY" -> - tryDSA asn1 : acc - _ -> acc - tryRSA asn1 = case fromASN1 asn1 of - Left _ -> Nothing - Right (k,_) -> Just $ X509.PrivKeyRSA k - tryDSA asn1 = case fromASN1 asn1 of - Left _ -> Nothing - Right (k,_) -> Just $ X509.PrivKeyDSA $ DSA.toPrivateKey k readSignedObjectFromMemory :: (ASN1Object a, Eq a, Show a) => B.ByteString @@ -48,3 +33,78 @@ case X509.decodeSignedObject $ pemContent pem of Left _ -> acc Right obj -> obj : acc + +pemToKey :: [Maybe X509.PrivKey] -> PEM -> [Maybe X509.PrivKey] +pemToKey acc pem = + case decodeASN1' BER (pemContent pem) of + Left _ -> acc + Right asn1 -> + case pemName pem of + "PRIVATE KEY" -> + tryRSA asn1 : tryDSA asn1 : acc + "RSA PRIVATE KEY" -> + tryRSA asn1 : acc + "DSA PRIVATE KEY" -> + tryDSA asn1 : acc + _ -> acc + where + tryRSA asn1 = case rsaFromASN1 asn1 of + Left _ -> Nothing + Right (k,_) -> Just $ X509.PrivKeyRSA k + tryDSA asn1 = case dsaFromASN1 asn1 of + Left _ -> Nothing + Right (k,_) -> Just $ X509.PrivKeyDSA $ DSA.toPrivateKey k + +dsaFromASN1 :: [ASN1] -> Either String (DSA.KeyPair, [ASN1]) +dsaFromASN1 (Start Sequence : IntVal n : xs) + | n /= 0 = Left "fromASN1: DSA.KeyPair: unknown format" + | otherwise = + case xs of + IntVal p : IntVal q : IntVal g : IntVal pub : IntVal priv : End Sequence : xs2 -> + let params = DSA.Params { DSA.params_p = p, DSA.params_g = g, DSA.params_q = q } + in Right (DSA.KeyPair params pub priv, xs2) + _ -> + Left "dsaFromASN1: DSA.KeyPair: invalid format (version=0)" +dsaFromASN1 _ = Left "dsaFromASN1: DSA.KeyPair: unexpected format" + +rsaFromASN1 :: [ASN1] -> Either String (RSA.PrivateKey, [ASN1]) +rsaFromASN1 (Start Sequence + : IntVal 0 + : IntVal n + : IntVal e + : IntVal d + : IntVal p1 + : IntVal p2 + : IntVal pexp1 + : IntVal pexp2 + : IntVal pcoef + : End Sequence + : xs) = Right (privKey, xs) + where + calculate_modulus m i = if (2 ^ (i * 8)) > m then i else calculate_modulus m (i+1) + pubKey = RSA.PublicKey { RSA.public_size = calculate_modulus n 1 + , RSA.public_n = n + , RSA.public_e = e + } + privKey = RSA.PrivateKey { RSA.private_pub = pubKey + , RSA.private_d = d + , RSA.private_p = p1 + , RSA.private_q = p2 + , RSA.private_dP = pexp1 + , RSA.private_dQ = pexp2 + , RSA.private_qinv = pcoef + } + +rsaFromASN1 ( Start Sequence + : IntVal 0 + : Start Sequence + : OID [1, 2, 840, 113549, 1, 1, 1] + : Null + : End Sequence + : OctetString bs + : xs) = + let inner = either strError rsaFromASN1 $ decodeASN1' BER bs + strError = Left . ("rsaFromASN1: RSA.PrivateKey: " ++) . show + in either Left (\(k, _) -> Right (k, xs)) inner +rsaFromASN1 _ = + Left "rsaFromASN1: unexpected format" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/x509-store-1.5.0/x509-store.cabal new/x509-store-1.6.0/x509-store.cabal --- old/x509-store-1.5.0/x509-store.cabal 2014-10-19 11:37:43.000000000 +0200 +++ new/x509-store-1.6.0/x509-store.cabal 2015-06-19 22:15:16.000000000 +0200 @@ -1,5 +1,5 @@ Name: x509-store -Version: 1.5.0 +Version: 1.6.0 Description: X.509 collection accessing and storing methods for certificate, crl, exception list License: BSD3 License-file: LICENSE @@ -13,14 +13,6 @@ Homepage: http://github.com/vincenthz/hs-certificate Cabal-Version: >=1.8 -Flag test - Description: Build unit test - Default: False - -Flag executable - Description: Build the executable - Default: False - Library Build-Depends: base >= 3 && < 5 , bytestring @@ -32,8 +24,8 @@ , pem >= 0.1 && < 0.3 , asn1-types >= 0.3 && < 0.4 , asn1-encoding >= 0.9 && < 0.10 - , crypto-pubkey-types >= 0.3 && < 0.5 - , x509 >= 1.5.0 && < 1.6 + , cryptonite + , x509 >= 1.6 && < 1.7 Exposed-modules: Data.X509.CertificateStore Data.X509.File Data.X509.Memory