1-- | 2-- Module : Data.ASN1.Types 3-- License : BSD-style 4-- Maintainer : Vincent Hanquez <vincent@snarc.org> 5-- Stability : experimental 6-- Portability : unknown 7-- 8module Data.ASN1.Types 9 ( ASN1(..) 10 , ASN1S 11 , ASN1Class(..) 12 , ASN1Tag 13 , ASN1ConstructionType(..) 14 , ASN1StringEncoding(..) 15 , ASN1TimeType(..) 16 , ASN1Object(..) 17 , ASN1CharacterString(..) 18 , asn1CharacterString 19 , asn1CharacterToString 20 , module Data.ASN1.OID 21 ) where 22 23import Data.Hourglass 24import Data.ASN1.BitArray 25import Data.ASN1.OID 26import Data.ASN1.Types.Lowlevel 27import Data.ASN1.Types.String 28import Data.ByteString (ByteString) 29 30-- | Define the type of container 31data ASN1ConstructionType = Sequence 32 | Set 33 | Container ASN1Class ASN1Tag 34 deriving (Show,Eq) 35 36-- | Different ASN1 time representation 37data ASN1TimeType = TimeUTC -- ^ ASN1 UTCTime Type: limited between 1950-2050 38 | TimeGeneralized -- ^ ASN1 GeneralizedTime Type 39 deriving (Show,Eq,Ord) 40 41-- | Define high level ASN1 object. 42data ASN1 = 43 Boolean Bool 44 | IntVal Integer 45 | BitString BitArray 46 | OctetString ByteString 47 | Null 48 | OID OID 49 | Real Double 50 | Enumerated Integer 51 | ASN1String ASN1CharacterString 52 | ASN1Time ASN1TimeType DateTime (Maybe TimezoneOffset) 53 | Other ASN1Class ASN1Tag ByteString 54 | Start ASN1ConstructionType 55 | End ASN1ConstructionType 56 deriving (Show, Eq) 57 58-- | represent a chunk of ASN1 Stream. 59-- this is equivalent to ShowS but for an ASN1 Stream. 60type ASN1S = [ASN1] -> [ASN1] 61 62-- | Define an object that can be converted to and from ASN.1 63class ASN1Object a where 64 -- | transform an object into a chunk of ASN1 stream. 65 toASN1 :: a -> ASN1S 66 67 -- | returns either an object along the remaining ASN1 stream, 68 -- or an error. 69 fromASN1 :: [ASN1] -> Either String (a, [ASN1]) 70