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.

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).

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

The OID for rsaSignatureWithripemd160 is (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

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

while the corrected version will decode this as


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


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

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

Related Stuff

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