Description
Write a DER BIT STRING tag, definite length and unused-bit-count prefix without payload bytes.
ASN.1 BER encodes values as identifiers, lengths and content; DER constrains representation to a canonical form. Content octets, first-tag octets and length prefixes are only parts of a complete encoded value.
Write a DER BIT STRING tag, definite length and unused-bit-count prefix without payload bytes.
When to use this tool
Use DER Bit String Prefix Writer when inspecting one explicit ASN.1 encoding component.
How to use the tool and how it works
- Enter payloadBytes, unusedBits. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- Read prefixHex. Use the output convention below.
Require nonnegative whole payloadBytes and unusedBits in [0,7], with unusedBits = 0 when payloadBytes = 0. Content length is payloadBytes+1. Return prefixHex containing tag 03, the shortest definite length encoding and the unused-bits count octet.1
ASN.1 encodings distinguish identifier, length and content octets. DER adds canonical constraints; the local output still needs its surrounding encoding.2
| Input field | Meaning and units | Accepted input |
|---|---|---|
| payloadBytes | Payload Bytes | Required. Safe integer; minimum 0. |
| unusedBits | Unused Bits | Required. Safe integer; minimum 0; maximum 7. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| prefixHex | Hexadecimal tag, definite content length and unused-bit count only; no payload. | Required. Text; maximum UTF-16 length 8192. |
{
"input": {
"payloadBytes": 3,
"unusedBits": 4
},
"output": {
"prefixHex": "030404"
}
} Limitations and assumptions
- This is only a BIT STRING prefix; payload bytes are absent. The caller must ensure its length and zero unused tail bits match the supplied counts.
- Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
- Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.
Alternative or Complementary methods
Use an appropriate complete ASN.1 encoder and schema for canonical full values, nested lengths and application semantics.
References
-
Calculation and input contract: encode/der-bit-string-prefix-writer — tool.io
-
ASN.1 encoding rules: ITU-T X.690 (12/1997) — International Telecommunication Union
Similar or alternative tools
- DER Bitstring Padding Count Octet
Calculate payload-octet and unused-tail-bit counts from a supplied BIT STRING bit length.
- DER Boolean Value Octet
Return octet 255 for true and zero for false, using DER's canonical BOOLEAN content-octet convention.