Description
Canonicalize an unsigned magnitude’s positive DER INTEGER content and add a sign-protection octet when needed.
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.
Canonicalize an unsigned magnitude’s positive DER INTEGER content and add a sign-protection octet when needed.
When to use this tool
Use DER Integer Sign Padding Octet when inspecting one explicit ASN.1 encoding component.
How to use the tool and how it works
- Enter unsignedBytes. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- Read bytes, added. Inspect added before interpreting the associated values.
Require a nonempty unsignedBytes array whose values are in [0,255]. Remove leading zero octets, preserving one zero for an all-zero value. Prepend zero if the first retained byte has its high bit set; added records whether that sign-protection octet was inserted.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 |
|---|---|---|
| unsignedBytes | Nonempty unsigned magnitude octets; leading zero octets are removed before sign protection. | Required. Array of safe integer; maximum items 256. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| bytes | Bytes | Required. Array of safe integer; maximum items 256. |
| added | Added | Required. Boolean. |
{
"input": {
"unsignedBytes": [
128
]
},
"output": {
"bytes": [
0,
128
],
"added": true
}
} Limitations and assumptions
- This creates positive INTEGER content octets, not a complete DER tag-length-value. Inputs describe unsigned magnitude; integer item validation follows the declared schema and no negative integer encoding is performed.
- 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.
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-integer-sign-padding-octet — 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.