scripts: Add -d option to oid2der to decode DER encoded OIDs
This commit is contained in:
parent
2269444b56
commit
08e2401653
|
@ -23,9 +23,26 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i, nr = 0;
|
int i, nr = 0;
|
||||||
chunk_t oid;
|
chunk_t oid;
|
||||||
|
char *decoded;
|
||||||
|
bool decode = FALSE;
|
||||||
|
|
||||||
|
if (streq(argv[1], "-d"))
|
||||||
|
{
|
||||||
|
decode = TRUE;
|
||||||
|
nr++;
|
||||||
|
}
|
||||||
|
|
||||||
while (argc > ++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]);
|
oid = asn1_oid_from_string(argv[nr]);
|
||||||
if (oid.len)
|
if (oid.len)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue