]> git.ipfire.org Git - people/ms/strongswan.git/blame - scripts/oid2der.c
Merge branch 'utils-split'
[people/ms/strongswan.git] / scripts / oid2der.c
CommitLineData
f3af4969
TB
1/*
2 * Copyright (C) 2010 Martin Willi
3 * Copyright (C) 2010 revosec AG
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
7240e226
MW
15
16#include <stdio.h>
17#include <asn1/asn1.h>
18
19/**
20 * convert string OID to DER encoding
21 */
22int main(int argc, char *argv[])
23{
24 int i, nr = 0;
25 chunk_t oid;
26
27 while (argc > ++nr)
28 {
29 oid = asn1_oid_from_string(argv[nr]);
30 if (oid.len)
31 {
32 for (i = 0; i < oid.len; i++)
33 {
34 printf("0x%02x,", oid.ptr[i]);
35 }
36 printf("\n");
37 free(oid.ptr);
38 }
39 else
40 {
41 return 1;
42 }
43 }
44 return 0;
45}