Fork me on GitHub

OID Converter

The OID converter is a handy little tool to convert ASN.1 OIDs from readable dotted decimal notation to binary hexadecimal Distinguished Encoding Rules (DER) representation and vice versa. If you're into x.509 certificates, this may be useful to you, too.

Download
The code (a single C file) is oid.c (v1.3).
A pre-compiled version for Linux is oid (v1.1).
A pre-compiled version for WIN32 is oid.exe (v1.3; created using lcc-win32).

Synopsis
OID encoder/decoder - v1.3 - Matthias Gaertner 1999/2001 - Freeware
Usage:
 OID [-c|-C] [-o] {-i|1.2.3.4}
   converts dotted form to ASCII HEX DER output.
 OID -x [-o] {-i|hex-digits}
   decodes ASCII HEX DER and gives dotted form.
Examples

The OID for rsaSignatureWithripemd160 is 1.3.36.3.3.1.2 (just as an example).

Bug in v1.0

A bug was pointed out to me recently. The original version would not correctly encode OIDs that contain the component 128. Version 1.1 fixes this. As an example, v1.0 would incorrectly encode

>oid 1.3.128
06 02 2B 00
(incorrect!)

while the corrected version will encode this as

>oid 1.3.128
06 03 2B 81 00

(Thanks to Eric Grenier of Cisco for the hint, 24Mar2006)

Bug in v1.1

Another bug was reported: lack of case-insensitivity when converting from hex to dotted. Only works for capital hex digits (A-F), lowercase digits (a-f) yield bad results.

>oid -x 06 02 02 0a
UNIVERSAL OID.0.2.42
(incorrect!)

while the corrected version will decode this as

UNIVERSAL OID.0.2.10

(Thanks to Hans Hudde of Cryptovision for the hint, 22Jan2014; fixed in v1.2)

v1.3

Added "C" array-style output using "-c" option.

(Thanks to Ilya V. Matveychikov who contributed this improvement via GitHub, 14Oct2014)

Related Stuff
Copyright

This code was written by me, Matthias Gärtner. It is freeware. Do with it whatever you want. Use at your own risk. No warranty of any kind.

Back to main page. Back to software page.


 
This page was last changed on February 18th, 2021. © Matthias Gärtner 2001