diff options
author | Tobias Brunner <tobias@strongswan.org> | 2017-10-18 16:28:04 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2017-11-02 10:02:26 +0100 |
commit | 08e24016539766fc553f5bf82e9ab75ba41b2b8f (patch) | |
tree | 2478dd19a60256c29db2b9930c5e126c99b569b6 /scripts | |
parent | 2269444b5668cfdb898b21a5624884f85f42b6ff (diff) | |
download | strongswan-08e24016539766fc553f5bf82e9ab75ba41b2b8f.tar.bz2 strongswan-08e24016539766fc553f5bf82e9ab75ba41b2b8f.tar.xz |
scripts: Add -d option to oid2der to decode DER encoded OIDs
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/oid2der.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/scripts/oid2der.c b/scripts/oid2der.c index 793c9804a..c8ab8df0f 100644 --- a/scripts/oid2der.c +++ b/scripts/oid2der.c @@ -23,9 +23,26 @@ int main(int argc, char *argv[]) { int i, nr = 0; chunk_t oid; + char *decoded; + bool decode = FALSE; + + if (streq(argv[1], "-d")) + { + decode = TRUE; + nr++; + } while (argc > ++nr) { + if (decode) + { + oid = chunk_from_hex(chunk_from_str(argv[nr]), NULL); + decoded = asn1_oid_to_string(oid); + printf("%s\n", decoded); + free(decoded); + free(oid.ptr); + continue; + } oid = asn1_oid_from_string(argv[nr]); if (oid.len) { |