-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | ASN.1 types
--   
--   ASN.1 standard types
@package asn1-types
@version 0.2.3


-- | Different String types available in ASN1
module Data.ASN1.Types.String

-- | Define all possible ASN1 String encoding.
data ASN1StringEncoding

-- | 128 characters equivalent to the ASCII alphabet
IA5 :: ASN1StringEncoding

-- | UTF8
UTF8 :: ASN1StringEncoding

-- | all registered graphic and character sets (see ISO 2375) plus SPACE
--   and DELETE.
General :: ASN1StringEncoding

-- | all registered G sets and SPACE
Graphic :: ASN1StringEncoding

-- | encoding containing numeric [0-9] and space
Numeric :: ASN1StringEncoding

-- | printable [a-z] [A-Z] [()+,-.?:/=] and space.
Printable :: ASN1StringEncoding

-- | CCITT's T.100 and T.101 character sets
VideoTex :: ASN1StringEncoding

-- | International ASCII printing character sets
Visible :: ASN1StringEncoding

-- | teletext
T61 :: ASN1StringEncoding

-- | UTF32
UTF32 :: ASN1StringEncoding

-- | Character
Character :: ASN1StringEncoding

-- | UCS2
BMP :: ASN1StringEncoding

-- | ASN1 Character String with encoding
data ASN1CharacterString
ASN1CharacterString :: ASN1StringEncoding -> ByteString -> ASN1CharacterString
characterEncoding :: ASN1CharacterString -> ASN1StringEncoding
getCharacterStringRawData :: ASN1CharacterString -> ByteString

-- | encode a string into a character string
asn1CharacterString :: ASN1StringEncoding -> String -> ASN1CharacterString

-- | try to decode an <a>ASN1CharacterString</a> to a String
asn1CharacterToString :: ASN1CharacterString -> Maybe String
instance Show ASN1StringEncoding
instance Eq ASN1StringEncoding
instance Ord ASN1StringEncoding
instance Show ASN1CharacterString
instance Eq ASN1CharacterString
instance Ord ASN1CharacterString
instance IsString ASN1CharacterString


module Data.ASN1.Types.Lowlevel

-- | Element class
data ASN1Class
Universal :: ASN1Class
Application :: ASN1Class
Context :: ASN1Class
Private :: ASN1Class

-- | ASN1 Tag
type ASN1Tag = Int

-- | ASN1 Length with all different formats
data ASN1Length

-- | Short form with only one byte. length has to be &lt; 127.
LenShort :: Int -> ASN1Length

-- | Long form of N bytes
LenLong :: Int -> Int -> ASN1Length

-- | Length is indefinite expect an EOC in the stream to finish the type
LenIndefinite :: ASN1Length

-- | ASN1 Header with the class, tag, constructed flag and length.
data ASN1Header
ASN1Header :: !ASN1Class -> !ASN1Tag -> !Bool -> !ASN1Length -> ASN1Header

-- | represent one event from an asn1 data stream
data ASN1Event

-- | ASN1 Header
Header :: ASN1Header -> ASN1Event

-- | Primitive
Primitive :: !ByteString -> ASN1Event

-- | Constructed value start
ConstructionBegin :: ASN1Event

-- | Constructed value end
ConstructionEnd :: ASN1Event
instance Show ASN1Class
instance Eq ASN1Class
instance Ord ASN1Class
instance Enum ASN1Class
instance Show ASN1Length
instance Eq ASN1Length
instance Show ASN1Header
instance Eq ASN1Header
instance Show ASN1Event
instance Eq ASN1Event


module Data.ASN1.OID

-- | Standard ASN.1 Object ID (OID)
type OID = [Integer]

-- | Class of things that have an Object ID
class OIDable a
getObjectID :: OIDable a => a -> OID

-- | Class of things that can be named by Object ID
class OIDNameable a
fromObjectID :: OIDNameable a => OID -> Maybe a


module Data.ASN1.BitArray

-- | represent a bitarray / bitmap
--   
--   the memory representation start at bit 0
data BitArray
BitArray :: Word64 -> ByteString -> BitArray

-- | throwed in case of out of bounds in the bitarray.
data BitArrayOutOfBound
BitArrayOutOfBound :: Word64 -> BitArrayOutOfBound

-- | returns the length of bits in this bitarray
bitArrayLength :: BitArray -> Word64

-- | get the nth bits
bitArrayGetBit :: BitArray -> Word64 -> Bool

-- | set the nth bit to the value specified
bitArraySetBitValue :: BitArray -> Word64 -> Bool -> BitArray

-- | set the nth bits
bitArraySetBit :: BitArray -> Word64 -> BitArray

-- | clear the nth bits
bitArrayClearBit :: BitArray -> Word64 -> BitArray

-- | get padded bytestring of the bitarray
bitArrayGetData :: BitArray -> ByteString

-- | number of bit to skip at the end (padding)
toBitArray :: ByteString -> Int -> BitArray
instance Typeable BitArrayOutOfBound
instance Show BitArrayOutOfBound
instance Eq BitArrayOutOfBound
instance Show BitArray
instance Eq BitArray
instance Exception BitArrayOutOfBound


module Data.ASN1.Types

-- | Define high level ASN1 object.
data ASN1
Boolean :: Bool -> ASN1
IntVal :: Integer -> ASN1
BitString :: BitArray -> ASN1
OctetString :: ByteString -> ASN1
Null :: ASN1
OID :: OID -> ASN1
Real :: Double -> ASN1
Enumerated :: Integer -> ASN1
ASN1String :: ASN1CharacterString -> ASN1
ASN1Time :: ASN1TimeType -> UTCTime -> (Maybe TimeZone) -> ASN1
Other :: ASN1Class -> ASN1Tag -> ByteString -> ASN1
Start :: ASN1ConstructionType -> ASN1
End :: ASN1ConstructionType -> ASN1

-- | represent a chunk of ASN1 Stream. this is equivalent to ShowS but for
--   an ASN1 Stream.
type ASN1S = [ASN1] -> [ASN1]

-- | Element class
data ASN1Class
Universal :: ASN1Class
Application :: ASN1Class
Context :: ASN1Class
Private :: ASN1Class

-- | ASN1 Tag
type ASN1Tag = Int

-- | Define the type of container
data ASN1ConstructionType
Sequence :: ASN1ConstructionType
Set :: ASN1ConstructionType
Container :: ASN1Class -> ASN1Tag -> ASN1ConstructionType

-- | Define all possible ASN1 String encoding.
data ASN1StringEncoding

-- | 128 characters equivalent to the ASCII alphabet
IA5 :: ASN1StringEncoding

-- | UTF8
UTF8 :: ASN1StringEncoding

-- | all registered graphic and character sets (see ISO 2375) plus SPACE
--   and DELETE.
General :: ASN1StringEncoding

-- | all registered G sets and SPACE
Graphic :: ASN1StringEncoding

-- | encoding containing numeric [0-9] and space
Numeric :: ASN1StringEncoding

-- | printable [a-z] [A-Z] [()+,-.?:/=] and space.
Printable :: ASN1StringEncoding

-- | CCITT's T.100 and T.101 character sets
VideoTex :: ASN1StringEncoding

-- | International ASCII printing character sets
Visible :: ASN1StringEncoding

-- | teletext
T61 :: ASN1StringEncoding

-- | UTF32
UTF32 :: ASN1StringEncoding

-- | Character
Character :: ASN1StringEncoding

-- | UCS2
BMP :: ASN1StringEncoding

-- | Different ASN1 time representation
data ASN1TimeType

-- | ASN1 UTCTime Type: limited between 1950-2050
TimeUTC :: ASN1TimeType

-- | ASN1 GeneralizedTime Type
TimeGeneralized :: ASN1TimeType

-- | Define an object that can be converted to and from ASN.1
class ASN1Object a
toASN1 :: ASN1Object a => a -> ASN1S
fromASN1 :: ASN1Object a => [ASN1] -> Either String (a, [ASN1])

-- | ASN1 Character String with encoding
data ASN1CharacterString
ASN1CharacterString :: ASN1StringEncoding -> ByteString -> ASN1CharacterString
characterEncoding :: ASN1CharacterString -> ASN1StringEncoding
getCharacterStringRawData :: ASN1CharacterString -> ByteString

-- | encode a string into a character string
asn1CharacterString :: ASN1StringEncoding -> String -> ASN1CharacterString

-- | try to decode an <a>ASN1CharacterString</a> to a String
asn1CharacterToString :: ASN1CharacterString -> Maybe String
instance Show ASN1ConstructionType
instance Eq ASN1ConstructionType
instance Show ASN1TimeType
instance Eq ASN1TimeType
instance Ord ASN1TimeType
instance Show ASN1
instance Eq ASN1
