Class DerUtils
java.lang.Object
de.xima.fc.model.encoding.DerUtils
- Since:
- 8.5.4
- Author:
- Norman Lorenz
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringdecodeDerStringValue(byte[] derBytes) Decodes a DER-encoded (Distinguished Encoding Rules per ITU-T X.690) ASN.1 string value into a plain JavaString.
-
Method Details
-
decodeDerStringValue
Decodes a DER-encoded (Distinguished Encoding Rules per ITU-T X.690) ASN.1 string value into a plain JavaString.This method expects the input byte array to contain a complete TLV (Tag-Length-Value) structure as used in ASN.1 DER encoding:
- Tag (1 byte): ASN.1 type identifier (e.g., 0x16 for IA5String)
- Length (1+ bytes): Short form (0x00–0x7F) or long form (0x80–0xFF)
- Value (n bytes): The actual string content
Charset selection:
Common use case: Decoding RFC 2253 hex-encoded DN attributes. When Java's
X500Principaloutputs a DN with email attributes (e.g.,1.2.840.113549.1.9.1=#1623...), the hex part after#represents the DER-encoded value. This method decodes such values.- Parameters:
derBytes- the complete DER-encoded TLV byte array (must not be null or empty)- Returns:
- the decoded string value
- Throws:
IllegalArgumentException- if:derBytesis null or shorter than 2 bytes- the length field is malformed or inconsistent with the actual payload
- the DER structure violates basic format rules
- Since:
- 8.5.4
- See Also:
-