Skip to content

Main content

DER Bit String Prefix Writer Tool

Write the DER BIT STRING tag, definite length and unused-bit-count prefix for an explicitly supplied payload length; payload bytes are not serialized.

Loading tool…

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

  1. Enter payloadBytes, unusedBits. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. 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 fieldMeaning and unitsAccepted input
payloadBytesPayload BytesRequired. Safe integer; minimum 0.
unusedBitsUnused BitsRequired. Safe integer; minimum 0; maximum 7.
Output fieldInterpretationReturned shape
prefixHexHexadecimal tag, definite content length and unused-bit count only; no payload.Required. Text; maximum UTF-16 length 8192.
json
{
  "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

  1. Calculation and input contract: encode/der-bit-string-prefix-writer — tool.io

  2. ASN.1 encoding rules: ITU-T X.690 (12/1997) — International Telecommunication Union

Similar or alternative tools