Added command line tool for OID to DER conversion function
[strongswan.git] / scripts / oid2der.c
1
2 #include <stdio.h>
3 #include <asn1/asn1.h>
4
5 /**
6 * convert string OID to DER encoding
7 */
8 int main(int argc, char *argv[])
9 {
10 int i, nr = 0;
11 chunk_t oid;
12
13 while (argc > ++nr)
14 {
15 oid = asn1_oid_from_string(argv[nr]);
16 if (oid.len)
17 {
18 for (i = 0; i < oid.len; i++)
19 {
20 printf("0x%02x,", oid.ptr[i]);
21 }
22 printf("\n");
23 free(oid.ptr);
24 }
25 else
26 {
27 return 1;
28 }
29 }
30 return 0;
31 }