asn1-encoding-0.9.6: 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.Prim

Contents

- ASN1 high level algebraic type
- marshall an ASN1 type from a val struct or a bytestring
- marshall an ASN1 type to a bytestring

Description

Tools to read ASN1 primitive (e.g. boolean, int)

Synopsis

- data ASN1
  - = Boolean Bool
  - | IntVal Integer
  - | BitString BitArray
  - | OctetString ByteString
  - | Null
  - | OID OID
  - | Real Double
  - | Enumerated Integer
  - | ASN1String ASN1CharacterString
  - | ASN1Time ASN1TimeType DateTime (Maybe TimezoneOffset)
  - | Other ASN1Class ASN1Tag ByteString
  - | Start ASN1ConstructionType
  - | End ASN1ConstructionType
- data ASN1ConstructionType
  - = Sequence
  - | Set
  - | Container ASN1Class ASN1Tag
- 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 :: ByteString -> Either ASN1Error ASN1
- getDouble :: ByteString -> Either ASN1Error ASN1
- getBitString :: ByteString -> Either ASN1Error ASN1
- getOctetString :: ByteString -> Either ASN1Error ASN1
- getNull :: ByteString -> Either ASN1Error ASN1
- 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

# ASN1 high level algebraic type

data ASN1 #

Define high level ASN1 object.

Constructors

Boolean Bool |
IntVal Integer |
BitString BitArray |
OctetString ByteString |
Null |
OID OID |
Real Double |
Enumerated Integer |
ASN1String ASN1CharacterString |
ASN1Time ASN1TimeType DateTime (Maybe TimezoneOffset) |
Other ASN1Class ASN1Tag ByteString |
Start ASN1ConstructionType |
End ASN1ConstructionType |

#### Instances

Instances details

Eq ASN1 |
Instance details Defined in Data.ASN1.Types Methods (==) :: ASN1 -> ASN1 -> Bool # (/=) :: ASN1 -> ASN1 -> Bool #
Show ASN1 |
Instance details Defined in Data.ASN1.Types Methods showsPrec :: Int -> ASN1 -> ShowS # show :: ASN1 -> String # showList :: [ASN1] -> ShowS #

data ASN1ConstructionType #

Define the type of container

Constructors

Sequence |
Set |
Container ASN1Class ASN1Tag |

#### Instances

Instances details

Eq ASN1ConstructionType |
Instance details Defined in Data.ASN1.Types Methods (==) :: ASN1ConstructionType -> ASN1ConstructionType -> Bool # (/=) :: ASN1ConstructionType -> ASN1ConstructionType -> Bool #
Show ASN1ConstructionType |
Instance details Defined in Data.ASN1.Types Methods showsPrec :: Int -> ASN1ConstructionType -> ShowS # show :: ASN1ConstructionType -> String # showList :: [ASN1ConstructionType] -> ShowS #

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 #

# marshall an ASN1 type from a val struct or a bytestring

getBoolean :: Bool -> ByteString -> Either ASN1Error ASN1 #

getInteger :: ByteString -> Either ASN1Error ASN1 #

getInteger, parse a value bytestring and get the integer out of the two complement encoded bytes

getDouble :: ByteString -> Either ASN1Error ASN1 #

getBitString :: ByteString -> Either ASN1Error ASN1 #

getOctetString :: ByteString -> Either ASN1Error ASN1 #

getNull :: ByteString -> Either ASN1Error ASN1 #

getOID :: ByteString -> Either ASN1Error ASN1 #

return an OID

getTime :: ASN1TimeType -> ByteString -> Either ASN1Error ASN1 #

# marshall an ASN1 type to a bytestring

putTime :: ASN1TimeType -> DateTime -> Maybe TimezoneOffset -> ByteString #

putInteger :: Integer -> ByteString #

putDouble :: Double -> ByteString #

putBitString :: BitArray -> ByteString #

putString :: ByteString -> ByteString #

putOID :: [Integer] -> ByteString #