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


module Data.ASN1.Stream
type ASN1Repr = (ASN1, [ASN1Event])
getConstructedEnd :: Int -> [ASN1] -> ([ASN1], [ASN1])
getConstructedEndRepr :: [ASN1Repr] -> ([ASN1Repr], [ASN1Repr])



-- | <i>Deprecated: Use Data.ASN1.Types instead</i>
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])


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.Show.Show Data.ASN1.Error.ASN1Error
instance GHC.Exception.Exception Data.ASN1.Error.ASN1Error


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


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


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