Data.ASN1.BinaryEncoding.Raw

asn1-encoding-0.9.4: ASN1 data reader and writer in RAW, BER and DER forms

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | experimental
Portability | unknown
Safe Haskell | None
Language | Haskell2010

Data.ASN1.BinaryEncoding.Raw

Contents

- types
- parser
- writer

Description

Raw encoding of binary format (BERDERCER)

Synopsis

- data ASN1Header :: * = ASN1Header ~ASN1Class ~ASN1Tag ~Bool ~ASN1Length
- data ASN1Class :: *
  - = Universal
  - | Application
  - | Context
  - | Private
- type ASN1Tag = Int
- data ASN1Length :: *
  - = LenShort Int
  - | LenLong Int Int
  - | LenIndefinite
- data ASN1Event :: *
  - = Header ASN1Header
  - | Primitive ~ByteString
  - | ConstructionBegin
  - | ConstructionEnd
- parseLBS :: ByteString -> Either ASN1Error [ASN1Event]
- parseBS :: ByteString -> Either ASN1Error [ASN1Event]
- toLazyByteString :: [ASN1Event] -> ByteString
- toByteString :: [ASN1Event] -> ByteString

# types

data ASN1Header :: * #

ASN1 Header with the class, tag, constructed flag and length.

Constructors

ASN1Header ~ASN1Class ~ASN1Tag ~Bool ~ASN1Length |

Instances

Eq ASN1Header |
Methods (==) :: ASN1Header -> ASN1Header -> Bool # (/=) :: ASN1Header -> ASN1Header -> Bool #
Show ASN1Header |
Methods showsPrec :: Int -> ASN1Header -> ShowS # show :: ASN1Header -> String # showList :: [ASN1Header] -> ShowS #

data ASN1Class :: * #

Element class

Constructors

Universal |
Application |
Context |
Private |

Instances

Enum ASN1Class |
Methods succ :: ASN1Class -> ASN1Class # pred :: ASN1Class -> ASN1Class # toEnum :: Int -> ASN1Class # fromEnum :: ASN1Class -> Int # enumFrom :: ASN1Class -> [ASN1Class] # enumFromThen :: ASN1Class -> ASN1Class -> [ASN1Class] # enumFromTo :: ASN1Class -> ASN1Class -> [ASN1Class] # enumFromThenTo :: ASN1Class -> ASN1Class -> ASN1Class -> [ASN1Class] #
Eq ASN1Class |
Methods (==) :: ASN1Class -> ASN1Class -> Bool # (/=) :: ASN1Class -> ASN1Class -> Bool #
Ord ASN1Class |
Methods compare :: ASN1Class -> ASN1Class -> Ordering # (<) :: ASN1Class -> ASN1Class -> Bool # (<=) :: ASN1Class -> ASN1Class -> Bool # (>) :: ASN1Class -> ASN1Class -> Bool # (>=) :: ASN1Class -> ASN1Class -> Bool # max :: ASN1Class -> ASN1Class -> ASN1Class # min :: ASN1Class -> ASN1Class -> ASN1Class #
Show ASN1Class |
Methods showsPrec :: Int -> ASN1Class -> ShowS # show :: ASN1Class -> String # showList :: [ASN1Class] -> ShowS #

type ASN1Tag = Int #

ASN1 Tag

data ASN1Length :: * #

ASN1 Length with all different formats

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 |
Methods (==) :: ASN1Length -> ASN1Length -> Bool # (/=) :: ASN1Length -> ASN1Length -> Bool #
Show ASN1Length |
Methods showsPrec :: Int -> ASN1Length -> ShowS # show :: ASN1Length -> String # showList :: [ASN1Length] -> ShowS #

data ASN1Event :: * #

represent one event from an asn1 data stream

Constructors

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

Instances

Eq ASN1Event |
Methods (==) :: ASN1Event -> ASN1Event -> Bool # (/=) :: ASN1Event -> ASN1Event -> Bool #
Show ASN1Event |
Methods showsPrec :: Int -> ASN1Event -> ShowS # show :: ASN1Event -> String # showList :: [ASN1Event] -> ShowS #

# parser

parseLBS :: ByteString -> Either ASN1Error [ASN1Event] #

Parse one lazy bytestring and returns on success all ASN1 events associated.

parseBS :: ByteString -> Either ASN1Error [ASN1Event] #

Parse one strict bytestring and returns on success all ASN1 events associated.

# writer

toLazyByteString :: [ASN1Event] -> ByteString #

transform a list of ASN1 Events into a lazy bytestring

toByteString :: [ASN1Event] -> ByteString #

transform a list of ASN1 Events into a strict bytestring