From: Martin Willi Date: Wed, 28 Jan 2015 12:37:31 +0000 (+0100) Subject: pki: Support printing CGA parameters X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7649c56ee39c78ccf68f5b959819ec3062905467;p=thirdparty%2Fstrongswan.git pki: Support printing CGA parameters --- diff --git a/src/pki/commands/print.c b/src/pki/commands/print.c index 7fec3fe422..1ac0b86527 100644 --- a/src/pki/commands/print.c +++ b/src/pki/commands/print.c @@ -491,6 +491,26 @@ static void print_ac(ac_t *ac) } } +/** + * Print CGA parameters + */ +static void print_cga(certificate_t *cert) +{ + identification_t *subject; + chunk_t addr; + u_int sec; + + subject = cert->get_subject(cert); + addr = subject->get_encoding(subject); + + if (addr.len == 16) + { + sec = (addr.ptr[8] & 0xE0); + sec >>= 5; + printf("Sec: %u\n", sec); + } +} + /** * Print certificate information */ @@ -542,6 +562,9 @@ static void print_cert(certificate_t *cert) case CERT_X509_AC: print_ac((ac_t*)cert); break; + case CERT_CGA_PARAMS: + print_cga(cert); + break; default: printf("parsing certificate subtype %N not implemented\n", certificate_type_names, cert->get_type(cert)); @@ -587,6 +610,11 @@ static int print() type = CRED_CERTIFICATE; subtype = CERT_X509_AC; } + else if (streq(arg, "cga")) + { + type = CRED_CERTIFICATE; + subtype = CERT_CGA_PARAMS; + } else if (streq(arg, "pub")) { type = CRED_PUBLIC_KEY; @@ -679,7 +707,7 @@ static void __attribute__ ((constructor))reg() command_register((command_t) { print, 'a', "print", "print a credential in a human readable form", - {"[--in file] [--type rsa-priv|ecdsa-priv|bliss-priv|pub|x509|crl|ac]"}, + {"[--in file] [--type rsa-priv|ecdsa-priv|bliss-priv|pub|x509|crl|ac|cga]"}, { {"help", 'h', 0, "show usage information"}, {"in", 'i', 1, "input file, default: stdin"},