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


-- | ASN1 data reader and writer in RAW, BER and DER forms
--   
--   ASN1 data reader and writer in raw form with supports for high level
--   forms of ASN1 (BER, and DER).
@package asn1-data
@version 0.7.1


module Data.ASN1.Types

-- | 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

-- | Possible errors during parsing operations
data ASN1Error

-- | Unexpected EOC in the stream.
StreamUnexpectedEOC :: ASN1Error

-- | Invalid primitive with infinite length in a stream.
StreamInfinitePrimitive :: ASN1Error

-- | A construction goes over the size specified in the header.
StreamConstructionWrongSize :: ASN1Error

-- | An unexpected situation has come up parsing an ASN1 event stream.
StreamUnexpectedSituation :: String -> ASN1Error

-- | Parsing an invalid header.
ParsingHeaderFail :: String -> ASN1Error

-- | Parsing is not finished, there is construction unended.
ParsingPartial :: ASN1Error

-- | Decoding of a type that is not implemented. Contribution welcome.
TypeNotImplemented :: String -> ASN1Error

-- | Decoding of a knowed type failed.
TypeDecodingFailed :: String -> ASN1Error

-- | Policy failed including the name of the policy and the reason.
PolicyFailed :: String -> String -> ASN1Error

-- | 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 GHC.Classes.Eq Data.ASN1.Types.ASN1Error
instance GHC.Show.Show Data.ASN1.Types.ASN1Error
instance GHC.Classes.Eq Data.ASN1.Types.ASN1Event
instance GHC.Show.Show Data.ASN1.Types.ASN1Event
instance GHC.Classes.Eq Data.ASN1.Types.ASN1Header
instance GHC.Show.Show Data.ASN1.Types.ASN1Header
instance GHC.Classes.Eq Data.ASN1.Types.ASN1Length
instance GHC.Show.Show Data.ASN1.Types.ASN1Length
instance GHC.Enum.Enum Data.ASN1.Types.ASN1Class
instance GHC.Classes.Ord Data.ASN1.Types.ASN1Class
instance GHC.Classes.Eq Data.ASN1.Types.ASN1Class
instance GHC.Show.Show Data.ASN1.Types.ASN1Class
instance GHC.Exception.Exception Data.ASN1.Types.ASN1Error


-- | Raw encoding of binary format (BER<i>DER</i>CER)
module Data.ASN1.BinaryEncoding.Raw

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

-- | 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

-- | 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

-- | Parse one lazy bytestring and returns on success all ASN1 events
--   associated.
parseLBS :: ByteString -> Either ASN1Error [ASN1Event]

-- | Parse one strict bytestring and returns on success all ASN1 events
--   associated.
parseBS :: ByteString -> Either ASN1Error [ASN1Event]

-- | transform a list of ASN1 Events into a lazy bytestring
toLazyByteString :: [ASN1Event] -> ByteString

-- | transform a list of ASN1 Events into a strict bytestring
toByteString :: [ASN1Event] -> ByteString


module Data.ASN1.BitArray

-- | represent a bitarray / bitmap
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 GHC.Classes.Eq Data.ASN1.BitArray.BitArray
instance GHC.Show.Show Data.ASN1.BitArray.BitArray
instance GHC.Classes.Eq Data.ASN1.BitArray.BitArrayOutOfBound
instance GHC.Show.Show Data.ASN1.BitArray.BitArrayOutOfBound
instance GHC.Exception.Exception Data.ASN1.BitArray.BitArrayOutOfBound


module Data.ASN1.Stream

-- | Define high level ASN1 object.
data ASN1
Boolean :: Bool -> ASN1
IntVal :: Integer -> ASN1
BitString :: BitArray -> ASN1
OctetString :: ByteString -> ASN1
Null :: ASN1
OID :: [Integer] -> ASN1
Real :: Double -> ASN1
Enumerated :: ASN1
UTF8String :: String -> ASN1
NumericString :: ByteString -> ASN1
PrintableString :: String -> ASN1
T61String :: String -> ASN1
VideoTexString :: ByteString -> ASN1
IA5String :: String -> ASN1
UTCTime :: (Int, Int, Int, Int, Int, Int, Bool) -> ASN1
GeneralizedTime :: (Int, Int, Int, Int, Int, Int, Bool) -> ASN1
GraphicString :: ByteString -> ASN1
VisibleString :: ByteString -> ASN1
GeneralString :: ByteString -> ASN1
UniversalString :: String -> ASN1
CharacterString :: ByteString -> ASN1
BMPString :: String -> ASN1
Other :: ASN1Class -> ASN1Tag -> ByteString -> ASN1
Start :: ASN1ConstructionType -> ASN1
End :: ASN1ConstructionType -> ASN1

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

-- | ASN1 Tag
type ASN1Tag = Int
type ASN1Repr = (ASN1, [ASN1Event])

-- | Define the type of container
data ASN1ConstructionType
Sequence :: ASN1ConstructionType
Set :: ASN1ConstructionType
Container :: ASN1Class -> ASN1Tag -> ASN1ConstructionType
getConstructedEnd :: Int -> [ASN1] -> ([ASN1], [ASN1])
getConstructedEndRepr :: [ASN1Repr] -> ([ASN1Repr], [ASN1Repr])
instance GHC.Classes.Eq Data.ASN1.Stream.ASN1
instance GHC.Show.Show Data.ASN1.Stream.ASN1
instance GHC.Classes.Eq Data.ASN1.Stream.ASN1ConstructionType
instance GHC.Show.Show Data.ASN1.Stream.ASN1ConstructionType


module Data.ASN1.Encoding

-- | Describe an ASN1 decoding, that transform a bytestream into an
--   asn1stream
class ASN1Decoding a

-- | decode a lazy bytestring into an ASN1 stream
decodeASN1 :: ASN1Decoding a => a -> ByteString -> Either ASN1Error [ASN1]

-- | transition class.
class ASN1DecodingRepr a

-- | decode a lazy bytestring into an ASN1 stream
decodeASN1Repr :: ASN1DecodingRepr a => a -> ByteString -> Either ASN1Error [ASN1Repr]

-- | Describe an ASN1 encoding, that transform an asn1stream into a
--   bytestream
class ASN1Encoding a

-- | encode a stream into a lazy bytestring
encodeASN1 :: ASN1Encoding a => a -> [ASN1] -> ByteString

-- | decode a strict bytestring into an ASN1 stream
decodeASN1' :: ASN1Decoding a => a -> ByteString -> Either ASN1Error [ASN1]

-- | decode a strict bytestring into an ASN1Repr stream
decodeASN1Repr' :: ASN1DecodingRepr a => a -> ByteString -> Either ASN1Error [ASN1Repr]

-- | encode a stream into a strict bytestring
encodeASN1' :: ASN1Encoding a => a -> [ASN1] -> ByteString


module Data.ASN1.Parse

-- | Parse ASN1 Monad
data ParseASN1 a

-- | run the parse monad over a stream and returns the result and the
--   remaining ASN1 Stream.
runParseASN1State :: ParseASN1 a -> [ASN1] -> Either String (a, [ASN1])

-- | run the parse monad over a stream and returns the result.
runParseASN1 :: ParseASN1 a -> [ASN1] -> Either String a

-- | run a function of the next elements of a container of specified type
onNextContainer :: ASN1ConstructionType -> ParseASN1 a -> ParseASN1 a

-- | just like onNextContainer, except it doens't throw an error if the
--   container doesn't exists.
onNextContainerMaybe :: ASN1ConstructionType -> ParseASN1 a -> ParseASN1 (Maybe a)

-- | get next container of specified type and return all its elements
getNextContainer :: ASN1ConstructionType -> ParseASN1 [ASN1]

-- | just like getNextContainer, except it doesn't throw an error if the
--   container doesn't exists.
getNextContainerMaybe :: ASN1ConstructionType -> ParseASN1 (Maybe [ASN1])

-- | get next element from the stream
getNext :: ParseASN1 ASN1

-- | returns if there's more elements in the stream.
hasNext :: ParseASN1 Bool
instance Control.Monad.Error.Class.MonadError GHC.Base.String Data.ASN1.Parse.ParseASN1
instance GHC.Base.Monad Data.ASN1.Parse.ParseASN1
instance GHC.Base.Applicative Data.ASN1.Parse.ParseASN1
instance GHC.Base.Functor Data.ASN1.Parse.ParseASN1


module Data.ASN1.Object

-- | an object that can be marshalled from and to ASN1
class ASN1Object a

-- | transform an object into an ASN1 stream.
toASN1 :: ASN1Object a => a -> [ASN1]

-- | returns either an object along the remaining ASN1 stream, or an error.
fromASN1 :: ASN1Object a => [ASN1] -> Either String (a, [ASN1])


-- | A module containing ASN1 BER and DER specification encoding/decoding.
module Data.ASN1.BinaryEncoding

-- | Basic Encoding Rules (BER)
data BER
BER :: BER

-- | Distinguished Encoding Rules (DER)
data DER
DER :: DER
instance Data.ASN1.Encoding.ASN1DecodingRepr Data.ASN1.BinaryEncoding.BER
instance Data.ASN1.Encoding.ASN1Decoding Data.ASN1.BinaryEncoding.BER
instance Data.ASN1.Encoding.ASN1DecodingRepr Data.ASN1.BinaryEncoding.DER
instance Data.ASN1.Encoding.ASN1Decoding Data.ASN1.BinaryEncoding.DER
instance Data.ASN1.Encoding.ASN1Encoding Data.ASN1.BinaryEncoding.DER
