commit ghc-x509 for openSUSE:Factory
Hello community, here is the log from the commit of package ghc-x509 for openSUSE:Factory checked in at 2017-08-31 21:01:47 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-x509 (Old) and /work/SRC/openSUSE:Factory/.ghc-x509.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "ghc-x509" Thu Aug 31 21:01:47 2017 rev:9 rq:513540 version:1.7.1 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-x509/ghc-x509.changes 2017-01-12 15:53:04.994828527 +0100 +++ /work/SRC/openSUSE:Factory/.ghc-x509.new/ghc-x509.changes 2017-08-31 21:01:48.230396550 +0200 @@ -1,0 +2,5 @@ +Thu Jul 27 14:07:19 UTC 2017 - psimons@suse.com + +- Update to version 1.7.1. + +------------------------------------------------------------------- Old: ---- x509-1.6.5.tar.gz New: ---- x509-1.7.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-x509.spec ++++++ --- /var/tmp/diff_new_pack.mw8w3y/_old 2017-08-31 21:01:49.534213361 +0200 +++ /var/tmp/diff_new_pack.mw8w3y/_new 2017-08-31 21:01:49.550211113 +0200 @@ -1,7 +1,7 @@ # # spec file for package ghc-x509 # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %global pkg_name x509 %bcond_with tests Name: ghc-%{pkg_name} -Version: 1.6.5 +Version: 1.7.1 Release: 0 Summary: X509 reader and writer License: BSD-3-Clause ++++++ x509-1.6.5.tar.gz -> x509-1.7.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/x509-1.6.5/Data/X509/Ext.hs new/x509-1.7.1/Data/X509/Ext.hs --- old/x509-1.6.5/Data/X509/Ext.hs 2016-12-03 08:26:55.000000000 +0100 +++ new/x509-1.7.1/Data/X509/Ext.hs 2017-07-21 18:29:07.000000000 +0200 @@ -8,7 +8,7 @@ -- extension processing module. -- {-# LANGUAGE FlexibleContexts #-} - +{-# LANGUAGE ScopedTypeVariables #-} module Data.X509.Ext ( Extension(..) -- * Common extension usually found in x509v3 @@ -21,6 +21,7 @@ , ExtSubjectAltName(..) , ExtAuthorityKeyId(..) , ExtCrlDistributionPoints(..) + , ExtNetscapeComment(..) , AltName(..) , DistributionPoint(..) , ReasonFlag(..) @@ -35,11 +36,15 @@ import qualified Data.ByteString.Char8 as BC import Data.ASN1.Types import Data.ASN1.Parse +import Data.ASN1.Encoding +import Data.ASN1.BinaryEncoding import Data.ASN1.BitArray +import Data.Proxy import Data.List (find) import Data.X509.ExtensionRaw import Data.X509.DistinguishedName import Control.Applicative +import Control.Monad -- | key usage flag that is found in the key usage extension field. data ExtKeyUsageFlag = @@ -65,10 +70,23 @@ -- -- each extension have a unique OID associated, and a way -- to encode and decode an ASN1 stream. +-- +-- Errata: turns out, the content is not necessarily ASN1, +-- it could be data that is only parsable by the extension +-- e.g. raw ascii string. Add method to parse and encode with +-- ByteString class Extension a where - extOID :: a -> OID - extEncode :: a -> [ASN1] - extDecode :: [ASN1] -> Either String a + extOID :: a -> OID + extHasNestedASN1 :: Proxy a -> Bool + extEncode :: a -> [ASN1] + extDecode :: [ASN1] -> Either String a + + extDecodeBs :: B.ByteString -> Either String a + extDecodeBs = (either (Left . show) Right . decodeASN1' BER) >=> extDecode + + extEncodeBs :: a -> B.ByteString + extEncodeBs = encodeASN1' DER . extEncode + -- | Get a specific extension from a lists of raw extensions extensionGet :: Extension a => Extensions -> Maybe a @@ -94,16 +112,17 @@ -- * Nothing, the OID doesn't match -- * Just Left, the OID matched, but the extension couldn't be decoded -- * Just Right, the OID matched, and the extension has been succesfully decoded -extensionDecode :: Extension a => ExtensionRaw -> Maybe (Either String a) -extensionDecode = doDecode undefined - where doDecode :: Extension a => a -> ExtensionRaw -> Maybe (Either String a) - doDecode dummy (ExtensionRaw oid _ asn1) - | extOID dummy == oid = Just (extDecode asn1) - | otherwise = Nothing +extensionDecode :: forall a . Extension a => ExtensionRaw -> Maybe (Either String a) +extensionDecode er@(ExtensionRaw oid _ content) + | extOID (undefined :: a) /= oid = Nothing + | extHasNestedASN1 (Proxy :: Proxy a) = Just (tryExtRawASN1 er >>= extDecode) + | otherwise = Just (extDecodeBs content) -- | Encode an Extension to extensionRaw -extensionEncode :: Extension a => Bool -> a -> ExtensionRaw -extensionEncode critical ext = ExtensionRaw (extOID ext) critical (extEncode ext) +extensionEncode :: forall a . Extension a => Bool -> a -> ExtensionRaw +extensionEncode critical ext + | extHasNestedASN1 (Proxy :: Proxy a) = ExtensionRaw (extOID ext) critical (encodeASN1' DER $ extEncode ext) + | otherwise = ExtensionRaw (extOID ext) critical (extEncodeBs ext) -- | Basic Constraints data ExtBasicConstraints = ExtBasicConstraints Bool (Maybe Integer) @@ -111,6 +130,7 @@ instance Extension ExtBasicConstraints where extOID = const [2,5,29,19] + extHasNestedASN1 = const True extEncode (ExtBasicConstraints b Nothing) = [Start Sequence,Boolean b,End Sequence] extEncode (ExtBasicConstraints b (Just i)) = [Start Sequence,Boolean b,IntVal i,End Sequence] @@ -127,6 +147,7 @@ instance Extension ExtKeyUsage where extOID = const [2,5,29,15] + extHasNestedASN1 = const True extEncode (ExtKeyUsage flags) = [BitString $ flagsToBits flags] extDecode [BitString bits] = Right $ ExtKeyUsage $ bitsToFlags bits extDecode _ = Left "unknown sequence" @@ -158,6 +179,7 @@ instance Extension ExtExtendedKeyUsage where extOID = const [2,5,29,37] + extHasNestedASN1 = const True extEncode (ExtExtendedKeyUsage purposes) = [Start Sequence] ++ map (OID . lookupRev) purposes ++ [End Sequence] where lookupRev (KeyUsagePurpose_Unknown oid) = oid @@ -174,6 +196,7 @@ instance Extension ExtSubjectKeyId where extOID = const [2,5,29,14] + extHasNestedASN1 = const True extEncode (ExtSubjectKeyId o) = [OctetString o] extDecode [OctetString o] = Right $ ExtSubjectKeyId o extDecode _ = Left "unknown sequence" @@ -203,6 +226,7 @@ instance Extension ExtSubjectAltName where extOID = const [2,5,29,17] + extHasNestedASN1 = const True extEncode (ExtSubjectAltName names) = encodeGeneralNames names extDecode l = runParseASN1 (ExtSubjectAltName <$> parseGeneralNames) l @@ -213,6 +237,7 @@ instance Extension ExtAuthorityKeyId where extOID _ = [2,5,29,35] + extHasNestedASN1 = const True extEncode (ExtAuthorityKeyId keyid) = [Start Sequence,Other Context 0 keyid,End Sequence] extDecode [Start Sequence,Other Context 0 keyid,End Sequence] = @@ -244,6 +269,7 @@ instance Extension ExtCrlDistributionPoints where extOID _ = [2,5,29,31] + extHasNestedASN1 = const True extEncode = error "extEncode ExtCrlDistributionPoints unimplemented" extDecode = error "extDecode ExtCrlDistributionPoints unimplemented" --extEncode (ExtCrlDistributionPoints ) @@ -311,3 +337,14 @@ flagsToBits :: Enum a => [a] -> BitArray flagsToBits flags = foldl bitArraySetBit bitArrayEmpty $ map (fromIntegral . fromEnum) flags where bitArrayEmpty = toBitArray (B.pack [0,0]) 7 + +data ExtNetscapeComment = ExtNetscapeComment B.ByteString + deriving (Show,Eq) + +instance Extension ExtNetscapeComment where + extOID _ = [2,16,840,1,113730,1,13] + extHasNestedASN1 = const False + extEncode = error "Extension: Netscape Comment do not contain nested ASN1" + extDecode = error "Extension: Netscape Comment do not contain nested ASN1" + extEncodeBs (ExtNetscapeComment b) = b + extDecodeBs = Right . ExtNetscapeComment diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/x509-1.6.5/Data/X509/ExtensionRaw.hs new/x509-1.7.1/Data/X509/ExtensionRaw.hs --- old/x509-1.6.5/Data/X509/ExtensionRaw.hs 2014-10-09 06:25:42.000000000 +0200 +++ new/x509-1.7.1/Data/X509/ExtensionRaw.hs 2017-07-21 11:58:08.000000000 +0200 @@ -9,6 +9,8 @@ -- module Data.X509.ExtensionRaw ( ExtensionRaw(..) + , tryExtRawASN1 + , extRawASN1 , Extensions(..) ) where @@ -17,14 +19,25 @@ import Data.ASN1.Encoding import Data.ASN1.BinaryEncoding import Data.X509.Internal +import qualified Data.ByteString as B -- | An undecoded extension data ExtensionRaw = ExtensionRaw { extRawOID :: OID -- ^ OID of this extension , extRawCritical :: Bool -- ^ if this extension is critical - , extRawASN1 :: [ASN1] -- ^ the associated ASN1 + , extRawContent :: B.ByteString -- ^ undecoded content } deriving (Show,Eq) +tryExtRawASN1 :: ExtensionRaw -> Either String [ASN1] +tryExtRawASN1 (ExtensionRaw oid _ content) = + case decodeASN1' BER content of + Left err -> Left $ "fromASN1: X509.ExtensionRaw: OID=" ++ show oid ++ ": cannot decode data: " ++ show err + Right r -> Right r + +extRawASN1 :: ExtensionRaw -> [ASN1] +extRawASN1 extRaw = either error id $ tryExtRawASN1 extRaw +{-# DEPRECATED extRawASN1 "use tryExtRawASN1 instead" #-} + -- | a Set of 'ExtensionRaw' newtype Extensions = Extensions (Maybe [ExtensionRaw]) deriving (Show,Eq) @@ -41,19 +54,12 @@ toASN1 extraw = \xs -> encodeExt extraw ++ xs fromASN1 (Start Sequence:OID oid:xs) = case xs of - Boolean b:OctetString obj:End Sequence:xs2 -> extractExt b obj xs2 - OctetString obj:End Sequence:xs2 -> extractExt False obj xs2 + Boolean b:OctetString obj:End Sequence:xs2 -> Right (ExtensionRaw oid b obj, xs2) + OctetString obj:End Sequence:xs2 -> Right (ExtensionRaw oid False obj, xs2) _ -> Left ("fromASN1: X509.ExtensionRaw: unknown format:" ++ show xs) - where - extractExt critical bs remainingStream = - case decodeASN1' BER bs of - Left err -> Left ("fromASN1: X509.ExtensionRaw: OID=" ++ show oid ++ - ": cannot decode data: " ++ show err) - Right r -> Right (ExtensionRaw oid critical r, remainingStream) fromASN1 l = Left ("fromASN1: X509.ExtensionRaw: unknown format:" ++ show l) encodeExt :: ExtensionRaw -> [ASN1] -encodeExt (ExtensionRaw oid critical asn1) = - let bs = encodeASN1' DER asn1 - in asn1Container Sequence ([OID oid] ++ (if critical then [Boolean True] else []) ++ [OctetString bs]) +encodeExt (ExtensionRaw oid critical content) = + asn1Container Sequence ([OID oid] ++ (if critical then [Boolean True] else []) ++ [OctetString content]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/x509-1.6.5/x509.cabal new/x509-1.7.1/x509.cabal --- old/x509-1.6.5/x509.cabal 2016-12-03 08:34:52.000000000 +0100 +++ new/x509-1.7.1/x509.cabal 2017-07-22 08:36:57.000000000 +0200 @@ -1,5 +1,5 @@ Name: x509 -Version: 1.6.5 +version: 1.7.1 Description: X509 reader and writer License: BSD3 License-file: LICENSE @@ -11,9 +11,10 @@ Category: Data stability: experimental Homepage: http://github.com/vincenthz/hs-certificate -Cabal-Version: >=1.8 +Cabal-Version: >= 1.10 Library + Default-Language: Haskell2010 Build-Depends: base >= 3 && < 5 , bytestring , memory @@ -41,6 +42,7 @@ ghc-options: -Wall Test-Suite test-x509 + Default-Language: Haskell2010 type: exitcode-stdio-1.0 hs-source-dirs: Tests Main-is: Tests.hs
participants (1)
-
root@hilbert.suse.de