Added command line tool for OID to DER conversion function
authorMartin Willi <martin@revosec.ch>
Tue, 14 Dec 2010 13:49:17 +0000 (14:49 +0100)
committerMartin Willi <martin@revosec.ch>
Wed, 5 Jan 2011 15:46:02 +0000 (16:46 +0100)
scripts/.gitignore
scripts/Makefile.am
scripts/oid2der.c [new file with mode: 0644]

index 54a4cb9..926daba 100644 (file)
@@ -3,6 +3,7 @@ bin2sql
 id2sql
 key2keyid
 keyid2sql
+oid2der
 thread_analysis
 dh_speed
 pubkey_speed
index 827fb7d..0a27520 100644 (file)
@@ -2,7 +2,7 @@ INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libtls
 AM_CFLAGS = \
 -DPLUGINS="\"${scripts_plugins}\""
 
-noinst_PROGRAMS = bin2array bin2sql id2sql key2keyid keyid2sql \
+noinst_PROGRAMS = bin2array bin2sql id2sql key2keyid keyid2sql oid2der \
        thread_analysis dh_speed pubkey_speed crypt_burn
 
 if USE_TLS
@@ -17,6 +17,7 @@ bin2sql_SOURCES = bin2sql.c
 id2sql_SOURCES = id2sql.c
 key2keyid_SOURCES = key2keyid.c
 keyid2sql_SOURCES = keyid2sql.c
+oid2der_SOURCES = oid2der.c
 thread_analysis_SOURCES = thread_analysis.c
 dh_speed_SOURCES = dh_speed.c
 pubkey_speed_SOURCES = pubkey_speed.c
@@ -24,6 +25,7 @@ crypt_burn_SOURCES = crypt_burn.c
 id2sql_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
 key2keyid_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
 keyid2sql_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
+oid2der_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
 dh_speed_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la -lrt
 pubkey_speed_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la -lrt
 crypt_burn_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
diff --git a/scripts/oid2der.c b/scripts/oid2der.c
new file mode 100644 (file)
index 0000000..0da3bbb
--- /dev/null
@@ -0,0 +1,31 @@
+
+#include <stdio.h>
+#include <asn1/asn1.h>
+
+/**
+ * convert string OID to DER encoding
+ */
+int main(int argc, char *argv[])
+{
+       int i, nr = 0;
+       chunk_t oid;
+
+       while (argc > ++nr)
+       {
+               oid = asn1_oid_from_string(argv[nr]);
+               if (oid.len)
+               {
+                       for (i = 0; i < oid.len; i++)
+                       {
+                               printf("0x%02x,", oid.ptr[i]);
+                       }
+                       printf("\n");
+                       free(oid.ptr);
+               }
+               else
+               {
+                       return 1;
+               }
+       }
+       return 0;
+}