beanit / asn1bean

ASN1bean (formerly known as jASN1) is a Java ASN.1 BER and DER encoding/decoding library
https://www.beanit.com/asn1/
Apache License 2.0
110 stars 45 forks source link

BER string types use all UTF-8 encoding but X.690 says otherwise #42

Open terefang opened 2 years ago

terefang commented 2 years ago

lets cite ITU-T X.690-2021 aka ISO/IEC 8825-1:2021 (E):

8.23.5 For restricted character strings apart from UniversalString, UTF8String and BMPString, the octet string shall
contain the octets specified in ISO/IEC 2022 for encodings in an 8-bit environment, using the escape sequence and character
codings registered in accordance with ISO/IEC 2375.

which in java translates to US-ASCII or for more tolerance the ISO-8859-1 charset

8.23.7 For the UniversalString type, the octet string shall contain the octets specified in ISO/IEC 10646, using the 4-
octet canonical form (see 13.2 of ISO/IEC 10646). Signatures shall not be used. Control functions may be used provided they
satisfy the restrictions imposed by 8.23.9.

which in java translates to UTF-32 or rather transformed from UCS-4

8.23.8 For the BMPString type, the octet string shall contain the octets specified in ISO/IEC 10646, using the 2-octet BMP
form (see 13.1 of ISO/IEC 10646). Signatures shall not be used. Control functions may be used provided they satisfy the
restrictions imposed by 8.23.9.

which in java translates to UTF-16 or rather transformed from UCS-2