-- 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-encoding
@version 0.9.6

module Data.ASN1.Error

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

-- | Invalid primitive type
TypePrimitiveInvalid :: String -> ASN1Error

-- | Policy failed including the name of the policy and the reason.
PolicyFailed :: String -> String -> ASN1Error
instance GHC.Classes.Eq Data.ASN1.Error.ASN1Error
instance GHC.Internal.Exception.Type.Exception Data.ASN1.Error.ASN1Error
instance GHC.Internal.Show.Show Data.ASN1.Error.ASN1Error

-- | Deprecated: Use Data.ASN1.Types instead
module Data.ASN1.Object

-- | Define an object that can be converted to and from ASN.1
class ASN1Object a

-- | transform an object into a chunk of ASN1 stream.
toASN1 :: ASN1Object a => a -> ASN1S

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

-- | Raw encoding of binary format (BERDERCER)
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 < 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.Stream
type ASN1Repr = (ASN1, [ASN1Event])
getConstructedEnd :: Int -> [ASN1] -> ([ASN1], [ASN1])
getConstructedEndRepr :: [ASN1Repr] -> ([ASN1Repr], [ASN1Repr])

-- | Tools to read ASN1 primitive (e.g. boolean, int)
module Data.ASN1.Prim

-- | 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 -> DateTime -> Maybe TimezoneOffset -> ASN1
Other :: ASN1Class -> ASN1Tag -> ByteString -> ASN1
Start :: ASN1ConstructionType -> ASN1
End :: ASN1ConstructionType -> ASN1

-- | Define the type of container
data ASN1ConstructionType
Sequence :: ASN1ConstructionType
Set :: ASN1ConstructionType
Container :: ASN1Class -> ASN1Tag -> ASN1ConstructionType
encodeHeader :: Bool -> ASN1Length -> ASN1 -> ASN1Header
encodePrimitiveHeader :: ASN1Length -> ASN1 -> ASN1Header
encodePrimitive :: ASN1 -> (Int, [ASN1Event])
decodePrimitive :: ASN1Header -> ByteString -> ASN1Ret
encodeConstructed :: ASN1 -> [ASN1] -> (Int, [ASN1Event])
encodeList :: [ASN1] -> (Int, [ASN1Event])
encodeOne :: ASN1 -> (Int, [ASN1Event])
mkSmallestLength :: Int -> ASN1Length
getBoolean :: Bool -> ByteString -> Either ASN1Error ASN1

-- | getInteger, parse a value bytestring and get the integer out of the
--   two complement encoded bytes
getInteger :: ByteString -> Either ASN1Error ASN1
getDouble :: ByteString -> Either ASN1Error ASN1
getBitString :: ByteString -> Either ASN1Error ASN1
getOctetString :: ByteString -> Either ASN1Error ASN1
getNull :: ByteString -> Either ASN1Error ASN1

-- | return an OID
getOID :: ByteString -> Either ASN1Error ASN1
getTime :: ASN1TimeType -> ByteString -> Either ASN1Error ASN1
putTime :: ASN1TimeType -> DateTime -> Maybe TimezoneOffset -> ByteString
putInteger :: Integer -> ByteString
putDouble :: Double -> ByteString
putBitString :: BitArray -> ByteString
putString :: ByteString -> ByteString
putOID :: [Integer] -> ByteString

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

-- | 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.ASN1Decoding Data.ASN1.BinaryEncoding.BER
instance Data.ASN1.Encoding.ASN1Decoding Data.ASN1.BinaryEncoding.DER
instance Data.ASN1.Encoding.ASN1DecodingRepr Data.ASN1.BinaryEncoding.BER
instance Data.ASN1.Encoding.ASN1DecodingRepr Data.ASN1.BinaryEncoding.DER
instance Data.ASN1.Encoding.ASN1Encoding Data.ASN1.BinaryEncoding.DER
