Data.ASN1.Raw

asn1-data-0.6.1.2: ASN1 data reader and writer in RAW, BER, DER and CER forms

Portability | unknown
Stability | experimental
Maintainer | Vincent Hanquez <vincent@snarc.org>
Safe Haskell | None

Data.ASN1.Raw

Contents

- ASN1 definitions
- Enumerator events
- serialize asn1 headers

Description

A module containing raw ASN1 serialization/derialization tools

Synopsis

- data ASN1Class
  - = Universal
  - | Application
  - | Context
  - | Private
- type ASN1Tag = Int
- data ASN1Length
  - = LenShort Int
  - | LenLong Int Int
  - | LenIndefinite
- data ASN1Header = ASN1Header !ASN1Class !ASN1Tag !Bool !ASN1Length
- data ASN1Err
  - = ASN1LengthDecodingLongContainsZero
  - | ASN1WritingUnexpectedConstructionEnd
  - | ASN1WritingUnexpectedInputEOF
  - | ASN1PolicyFailed String String
  - | ASN1NotImplemented String
  - | ASN1Multiple [ASN1Err]
  - | ASN1Misc String
  - | ASN1ParsingPartial
  - | ASN1ParsingFail String
- data ASN1Event
  - = Header ASN1Header
  - | Primitive !ByteString
  - | ConstructionBegin
  - | ConstructionEnd
- iterateFile :: FilePath -> Iteratee ASN1Event IO a -> IO (Either SomeException a)
- iterateByteString :: Monad m => ByteString -> Iteratee ASN1Event m a -> m (Either SomeException a)
- enumReadBytes :: Monad m => Enumeratee ByteString ASN1Event m a
- enumWriteBytes :: Monad m => Enumeratee ASN1Event ByteString m a
- toBytes :: [ASN1Event] -> ByteString
- getHeader :: ByteString -> Either ASN1Err ASN1Header
- putHeader :: ASN1Header -> ByteString

# ASN1 definitions

data ASN1Class

Constructors

Universal |
Application |
Context |
Private |

Instances

Enum ASN1Class |
Eq ASN1Class |
Ord ASN1Class |
Show ASN1Class |

type ASN1Tag = Int

data ASN1Length

Constructors

LenShort Int | Short form with only one byte. length has to be < 127.
LenLong Int Int | Long form of N bytes
LenIndefinite | Length is indefinite expect an EOC in the stream to finish the type

Instances

Eq ASN1Length |
Show ASN1Length |

data ASN1Header

Constructors

ASN1Header !ASN1Class !ASN1Tag !Bool !ASN1Length |

Instances

Eq ASN1Header |
Show ASN1Header |

data ASN1Err

Constructors

ASN1LengthDecodingLongContainsZero |
ASN1WritingUnexpectedConstructionEnd |
ASN1WritingUnexpectedInputEOF |
ASN1PolicyFailed String String |
ASN1NotImplemented String |
ASN1Multiple [ASN1Err] |
ASN1Misc String |
ASN1ParsingPartial |
ASN1ParsingFail String |

Instances

Eq ASN1Err |
Show ASN1Err |
Typeable ASN1Err |
Exception ASN1Err |

# Enumerator events

data ASN1Event

Constructors

Header ASN1Header | ASN1 Header
Primitive !ByteString | Primitive
ConstructionBegin | Constructed value start
ConstructionEnd | Constructed value end

Instances

Eq ASN1Event |
Show ASN1Event |

iterateFile :: FilePath -> Iteratee ASN1Event IO a -> IO (Either SomeException a)

iterate over a file using a file enumerator.

iterateByteString :: Monad m => ByteString -> Iteratee ASN1Event m a -> m (Either SomeException a)

iterate over a lazy bytestring using a list enumerator over the bytestring chunks.

enumReadBytes :: Monad m => Enumeratee ByteString ASN1Event m a

enumReadBytes parse bytestring and generate asn1event.

enumWriteBytes :: Monad m => Enumeratee ASN1Event ByteString m a

write Bytes of events enumeratee

toBytes :: [ASN1Event] -> ByteString

# serialize asn1 headers

getHeader :: ByteString -> Either ASN1Err ASN1Header

putHeader :: ASN1Header -> ByteString

putIdentifier encode an ASN1 Identifier into a marshalled value