]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
pki: Support printing CGA parameters
authorMartin Willi <martin@revosec.ch>
Wed, 28 Jan 2015 12:37:31 +0000 (13:37 +0100)
committerMartin Willi <martin@revosec.ch>
Tue, 24 Feb 2015 16:13:56 +0000 (17:13 +0100)
src/pki/commands/print.c

index 7fec3fe42225eb6455649ec255b7080cbc32c3d9..1ac0b86527b88e8c568a30775f8c15b3dcece674 100644 (file)
@@ -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"},