Copyright | © Herbert Valerio Riedel 2020 |
---|---|
License | GPL-2.0-or-later |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
ASN.1 String Types
This modules features types and associated functions for encodingdecoding common ASN.1 string types from their ASN.1 BER representation according to their standard universal/ ASN.1 tag number.
Since: 0.1.1
Synopsis
- class ASN1String a where
- asn1string'decode :: ByteString -> Maybe a
- asn1string'encode :: a -> ByteString
- asn1string'supportsCodePoint :: Proxy a -> Char -> Bool
- asn1string'toCodePoints :: a -> [Char]
- asn1string'fromCodePoints :: [Char] -> Maybe a
- data ASN1StringChoice
- = ASN1String'OCTET_STRING ShortByteString
- | ASN1String'UniversalString UniversalString
- | ASN1String'UTF8String ShortText
- | ASN1String'BMPString BMPString
- | ASN1String'IA5String IA5String
- | ASN1String'VisibleString VisibleString
- | ASN1String'PrintableString PrintableString
- | ASN1String'NumericString NumericString
- asn1StringChoice'encode :: ASN1StringChoice -> ByteString
- asn1StringChoice'decode :: ByteString -> Maybe ASN1StringChoice
- newtype UTF8String = UTF8String {
- utf8String'toShortText :: ShortText
- data UniversalString
- data BMPString
- bmpString'toUcs2CodePoints :: BMPString -> [Word16]
- bmpString'fromUcs2CodePoints :: [Word16] -> BMPString
- data IA5String
- ia5String'toShortText :: IA5String -> ShortText
- ia5String'fromShortText :: ShortText -> Maybe IA5String
- data VisibleString
- visibleString'toShortText :: VisibleString -> ShortText
- visibleString'fromShortText :: ShortText -> Maybe VisibleString
- data PrintableString
- printableString'toShortText :: PrintableString -> ShortText
- printableString'fromShortText :: ShortText -> Maybe PrintableString
- data NumericString
- numericString'toShortText :: NumericString -> ShortText
- numericString'fromShortText :: ShortText -> Maybe NumericString
Documentation
class ASN1String a where Source #
Typeclass abstracting over common ASN.1 string operations
Since: 0.1.1
asn1string'decode :: ByteString -> Maybe a Source #
Decode ASN.1 string type from its ASN.1 BER encoding
default asn1string'decode :: ASN1 a => ByteString -> Maybe a Source #
asn1string'encode :: a -> ByteString Source #
Encode ASN.1 string type to its ASN.1 BER encoding
default asn1string'encode :: ASN1 a => a -> ByteString Source #
asn1string'supportsCodePoint :: Proxy a -> Char -> Bool Source #
Predicate for determining whether given code-point is allowed by the respective ASN.1 string type
asn1string'toCodePoints :: a -> [Char] Source #
Convert ASN.1 string type to list of code-points
asn1string'fromCodePoints :: [Char] -> Maybe a Source #
Construct ASN.1 string type from list of code-points
This returns Nothing
if a code-point cannot be expressed in the respective ASN.1 string type.
Instances
Convenience Sum-type
data ASN1StringChoice Source #
Convenient Sum-type combining a subset of the standard ASN.1 string-like types
See specific string types in LDAPv3.ASN1String for details.
Instances
Eq ASN1StringChoice Source # | |
Defined in LDAPv3.ASN1String (==) :: ASN1StringChoice -> ASN1StringChoice -> Bool # (/=) :: ASN1StringChoice -> ASN1StringChoice -> Bool # | |
Show ASN1StringChoice Source # | |
Defined in LDAPv3.ASN1String showsPrec :: Int -> ASN1StringChoice -> ShowS # show :: ASN1StringChoice -> String # showList :: [ASN1StringChoice] -> ShowS # | |
Binary ASN1StringChoice Source # | Encodes as ASN.1 BER |
Defined in LDAPv3.ASN1String |
asn1StringChoice'encode :: ASN1StringChoice -> ByteString Source #
Encode ASN.1 string choice to its ASN.1 BER encoding
Since: 0.1.1
asn1StringChoice'decode :: ByteString -> Maybe ASN1StringChoice Source #
Decode ASN.1 string choice from its ASN.1 BER encoding
Since: 0.1.1
UTF8String
newtype UTF8String Source #
ASN.1 UTF8String
UTF8String ::= [UNIVERSAL 12] IMPLICIT OCTET STRING
Since: 0.1.1
UTF8String | |
|
Instances
UniversalString
data UniversalString Source #
ASN.1 UniversalString
UniversalString ::= [UNIVERSAL 28] IMPLICIT OCTET STRING
NB: The surrogate-pair range U+D800 through U+DFFF is tolerated and thus becomes the responsibility of code converting to and from UniversalString
Since: 0.1.1
Instances
BMPString
ASN.1 BMPString
BMPString ::= [UNIVERSAL 30] IMPLICIT OCTET STRING
NB: The surrogate-pair range U+D800 through U+DFFF is tolerated and thus the responsibility of code converting to and
from BMPString
Since: 0.1.1
Instances
Eq BMPString Source # | |
Ord BMPString Source # | |
Defined in LDAPv3.ASN1String | |
Show BMPString Source # | |
Binary BMPString Source # | Encodes as ASN.1 BER |
ASN1String BMPString Source # | |
Defined in LDAPv3.ASN1String asn1string'decode :: ByteString -> Maybe BMPString Source # asn1string'encode :: BMPString -> ByteString Source # asn1string'supportsCodePoint :: Proxy BMPString -> Char -> Bool Source # asn1string'toCodePoints :: BMPString -> [Char] Source # asn1string'fromCodePoints :: [Char] -> Maybe BMPString Source # |
bmpString'toUcs2CodePoints :: BMPString -> [Word16] Source #
IA5String
ASN.1 IA5String
IA5String ::= [UNIVERSAL 22] IMPLICIT OCTET STRING
Since: 0.1.1
Instances
Eq IA5String Source # | |
Ord IA5String Source # | |
Defined in LDAPv3.ASN1String | |
Show IA5String Source # | |
Binary IA5String Source # | Encodes as ASN.1 BER |
ASN1String IA5String Source # | |
Defined in LDAPv3.ASN1String asn1string'decode :: ByteString -> Maybe IA5String Source # asn1string'encode :: IA5String -> ByteString Source # asn1string'supportsCodePoint :: Proxy IA5String -> Char -> Bool Source # asn1string'toCodePoints :: IA5String -> [Char] Source # asn1string'fromCodePoints :: [Char] -> Maybe IA5String Source # |
ia5String'toShortText :: IA5String -> ShortText Source #
ia5String'fromShortText :: ShortText -> Maybe IA5String Source #
VisibleString
data VisibleString Source #
ASN.1 VisibleString
VisibleString ::= [UNIVERSAL 26] IMPLICIT OCTET STRING
Since: 0.1.1
Instances
visibleString'toShortText :: VisibleString -> ShortText Source #
visibleString'fromShortText :: ShortText -> Maybe VisibleString Source #
PrintableString
data PrintableString Source #
ASN.1 PrintableString
PrintableString ::= [UNIVERSAL 19] IMPLICIT OCTET STRING
Since: 0.1.1
Instances
printableString'toShortText :: PrintableString -> ShortText Source #
printableString'fromShortText :: ShortText -> Maybe PrintableString Source #
NumericString
data NumericString Source #
ASN.1 NumericString
NumericString ::= [UNIVERSAL 18] IMPLICIT OCTET STRING
Since: 0.1.1
Instances
numericString'toShortText :: NumericString -> ShortText Source #
numericString'fromShortText :: ShortText -> Maybe NumericString Source #