module Data.ASN1.Encoding
(
ASN1Decoding(..)
, ASN1DecodingRepr(..)
, ASN1Encoding(..)
, decodeASN1'
, decodeASN1Repr'
, encodeASN1'
) where
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as L
import Data.ASN1.Stream
import Data.ASN1.Types
import Data.ASN1.Error
class ASN1Decoding a where
decodeASN1 :: a -> L.ByteString -> Either ASN1Error [ASN1]
class ASN1DecodingRepr a where
decodeASN1Repr :: a -> L.ByteString -> Either ASN1Error [ASN1Repr]
class ASN1Encoding a where
encodeASN1 :: a -> [ASN1] -> L.ByteString
decodeASN1' :: ASN1Decoding a => a -> B.ByteString -> Either ASN1Error [ASN1]
decodeASN1' :: a -> ByteString -> Either ASN1Error [ASN1]
decodeASN1' a
encoding ByteString
bs = a -> ByteString -> Either ASN1Error [ASN1]
forall a.
ASN1Decoding a =>
a -> ByteString -> Either ASN1Error [ASN1]
decodeASN1 a
encoding (ByteString -> Either ASN1Error [ASN1])
-> ByteString -> Either ASN1Error [ASN1]
forall a b. (a -> b) -> a -> b
$ [ByteString] -> ByteString
L.fromChunks [ByteString
bs]
decodeASN1Repr' :: ASN1DecodingRepr a => a -> B.ByteString -> Either ASN1Error [ASN1Repr]
decodeASN1Repr' :: a -> ByteString -> Either ASN1Error [ASN1Repr]
decodeASN1Repr' a
encoding ByteString
bs = a -> ByteString -> Either ASN1Error [ASN1Repr]
forall a.
ASN1DecodingRepr a =>
a -> ByteString -> Either ASN1Error [ASN1Repr]
decodeASN1Repr a
encoding (ByteString -> Either ASN1Error [ASN1Repr])
-> ByteString -> Either ASN1Error [ASN1Repr]
forall a b. (a -> b) -> a -> b
$ [ByteString] -> ByteString
L.fromChunks [ByteString
bs]
encodeASN1' :: ASN1Encoding a => a -> [ASN1] -> B.ByteString
encodeASN1' :: a -> [ASN1] -> ByteString
encodeASN1' a
encoding = [ByteString] -> ByteString
B.concat ([ByteString] -> ByteString)
-> ([ASN1] -> [ByteString]) -> [ASN1] -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
L.toChunks (ByteString -> [ByteString])
-> ([ASN1] -> ByteString) -> [ASN1] -> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> [ASN1] -> ByteString
forall a. ASN1Encoding a => a -> [ASN1] -> ByteString
encodeASN1 a
encoding