Skip to content

Main content

DER Bitstring Unused Bit Count Tool

Validate DER BIT STRING padding zeros from the unused-bit count and final payload octet.

Loading tool…

Description

Check BIT STRING unused-tail-bit consistency.

ASN.1 encodings separate identifiers, lengths and contents, with DER applying stricter canonical forms than BER. One leading octet or terminal-bit check covers only part of the complete value.

Check BIT STRING unused-tail-bit consistency.

When to use this tool

Use DER Bitstring Unused Bit Count when inspecting a stated ASN.1 field or canonical-content condition.

How to use the tool and how it works

  1. Enter unused, lastOctet, hasPayload. 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 meaningfulBitsInLast. Use the output convention below.

Check BIT STRING unused-tail-bit consistency. Require unused in [0,7] and lastOctet in [0,255]; with payload require low unused bits zero, otherwise both inputs zero. meaningfulBitsInLast is 8-unused or zero without payload.1

DER constrains primitive encodings, including canonical value representation. Inspecting the supplied value octets does not establish a complete valid ASN.1 element.2

Input fieldMeaning and unitsAccepted input
unusedUnusedRequired. Safe integer; minimum 0; maximum 7.
lastOctetLast OctetRequired. Safe integer; minimum 0; maximum 255.
hasPayloadHas PayloadRequired. Boolean.
Output fieldInterpretationReturned shape
meaningfulBitsInLastMeaningful Bits In LastRequired. Safe integer.
json
{
  "input": {
    "unused": 3,
    "lastOctet": 168,
    "hasPayload": true
  },
  "output": {
    "meaningfulBitsInLast": 5
  }
}

Limitations and assumptions

  • This checks supplied terminal metadata, not total bit length, tag or full DER canonicality.
  • 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 ASN.1 schema and complete BER/DER parser for nested values, canonicality and application meaning.

References

  1. Calculation and input contract: decode/der-bitstring-unused-bit-count — tool.io

  2. ITU-T X.690 (1997): ASN.1 encoding rules — ITU

Similar or alternative tools