asn1-data 0.4.4 → 0.4.5
raw patch · 3 files changed
+21/−8 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Data.ASN1.Raw: toBytes :: [ASN1Event] -> ByteString
- Data.ASN1.Stream: getConstructedEndRepr :: Int -> [ASN1Repr] -> ([ASN1Repr], [ASN1Repr])
+ Data.ASN1.Stream: getConstructedEndRepr :: [ASN1Repr] -> ([ASN1Repr], [ASN1Repr])
Files
- Data/ASN1/Raw.hs +7/−0
- Data/ASN1/Stream.hs +13/−7
- asn1-data.cabal +1/−1
Data/ASN1/Raw.hs view
@@ -23,6 +23,7 @@ , iterateByteString , enumReadBytes , enumWriteBytes+ , toBytes -- * serialize asn1 headers , getHeader , putHeader@@ -43,6 +44,7 @@ import Data.Word import Data.Bits import Control.Monad+import Control.Monad.Identity import Control.Applicative ((<|>), (<$>)) data ASN1Class =@@ -272,3 +274,8 @@ [] -> E.throwError ASN1WritingUnexpectedConstructionEnd True : tl -> k (Chunks [putEoc]) >>== loop tl False : tl -> k (Chunks []) >>== loop tl++toBytes :: [ASN1Event] -> L.ByteString+toBytes evs = case runIdentity (run (enumList 8 evs $$ joinI (enumWriteBytes $$ E.consume))) of+ Left err -> error $ show err+ Right l -> L.fromChunks l
Data/ASN1/Stream.hs view
@@ -58,10 +58,16 @@ | otherwise = let (ys, zs) = getConstructedEnd (i-1) xs in (x:ys,zs) getConstructedEnd i (x:xs) = let (ys, zs) = getConstructedEnd i xs in (x:ys,zs) -getConstructedEndRepr :: Int -> [ASN1Repr] -> ([ASN1Repr],[ASN1Repr])-getConstructedEndRepr _ xs@[] = (xs, [])-getConstructedEndRepr i ((x@(Start _, _)):xs) = let (yz, zs) = getConstructedEndRepr (i+1) xs in (x:yz,zs)-getConstructedEndRepr i ((x@(End _, _)):xs)- | i == 0 = ([], xs)- | otherwise = let (ys, zs) = getConstructedEndRepr (i-1) xs in (x:ys,zs)-getConstructedEndRepr i (x:xs) = let (ys, zs) = getConstructedEndRepr i xs in (x:ys,zs)+getConstructedEndRepr :: [ASN1Repr] -> ([ASN1Repr],[ASN1Repr])+getConstructedEndRepr = g+ where+ g [] = ([], [])+ g (x@(Start _,_):xs) = let (ys, zs) = getEnd 1 xs in (x:ys, zs)+ g (x:xs) = ([x],xs)++ getEnd :: Int -> [ASN1Repr] -> ([ASN1Repr],[ASN1Repr])+ getEnd _ [] = ([], [])+ getEnd 0 xs = ([], xs)+ getEnd i ((x@(Start _, _)):xs) = let (ys, zs) = getEnd (i+1) xs in (x:ys,zs)+ getEnd i ((x@(End _, _)):xs) = let (ys, zs) = getEnd (i-1) xs in (x:ys,zs)+ getEnd i (x:xs) = let (ys, zs) = getEnd i xs in (x:ys,zs)
asn1-data.cabal view
@@ -1,5 +1,5 @@ Name: asn1-data-Version: 0.4.4+Version: 0.4.5 Description: ASN1 data reader and writer in raw form with supports for high level forms of ASN1 (BER, CER and DER). .