migrated scripts to new fingerprinting API
authorMartin Willi <martin@strongswan.org>
Tue, 25 Aug 2009 09:29:51 +0000 (11:29 +0200)
committerMartin Willi <martin@strongswan.org>
Wed, 26 Aug 2009 09:23:55 +0000 (11:23 +0200)
scripts/key2keyid.c
scripts/keyid2sql.c

index 201670e..15d1323 100644 (file)
@@ -37,10 +37,18 @@ int main(int argc, char *argv[])
                printf("parsed %d bits %N private key.\n",
                           private->get_keysize(private)*8,
                           key_type_names, private->get_type(private));
-               printf("%N is:\t %D\n", id_type_names, ID_PUBKEY_INFO_SHA1,
-                          private->get_id(private, ID_PUBKEY_INFO_SHA1));
-               printf("%N is:\t %D\n", id_type_names, ID_PUBKEY_SHA1,
-                          private->get_id(private, ID_PUBKEY_SHA1));
+               if (private->get_fingerprint(private, KEY_ID_PUBKEY_INFO_SHA1, &chunk))
+               {
+                       printf("subjectPublicKeyInfo keyid: %#B\n", &chunk);
+               }
+               if (private->get_fingerprint(private, KEY_ID_PUBKEY_SHA1, &chunk))
+               {
+                       printf("subjectPublicKey keyid:     %#B\n", &chunk);
+               }
+               if (private->get_fingerprint(private, KEY_ID_PGPV3, &chunk))
+               {
+                       printf("PGP verison 3 keyid:        %#B\n", &chunk);
+               }
                private->destroy(private);
                return 0;
        }
@@ -59,10 +67,18 @@ int main(int argc, char *argv[])
                printf("parsed %d bits %N public key.\n",
                           public->get_keysize(public)*8,
                           key_type_names, public->get_type(public));
-               printf("%N is:\t %D\n", id_type_names, ID_PUBKEY_INFO_SHA1,
-                          public->get_id(public, ID_PUBKEY_INFO_SHA1));
-               printf("%N is:\t %D\n", id_type_names, ID_PUBKEY_SHA1,
-                          public->get_id(public, ID_PUBKEY_SHA1));
+               if (public->get_fingerprint(public, KEY_ID_PUBKEY_INFO_SHA1, &chunk))
+               {
+                       printf("subjectPublicKeyInfo keyid: %#B\n", &chunk);
+               }
+               if (public->get_fingerprint(public, KEY_ID_PUBKEY_SHA1, &chunk))
+               {
+                       printf("subjectPublicKey keyid:     %#B\n", &chunk);
+               }
+               if (public->get_fingerprint(public, KEY_ID_PGPV3, &chunk))
+               {
+                       printf("PGP verison 3 keyid:        %#B\n", &chunk);
+               }
                public->destroy(public);
                return 0;
        }
index 588bd7a..094e1af 100644 (file)
@@ -2,11 +2,9 @@
 #include <stdio.h>
 #include <library.h>
 #include <debug.h>
-#include <utils/identification.h>
 #include <credentials/keys/private_key.h>
 #include <credentials/keys/public_key.h>
 
-
 /**
  * print the keyids of a private or public key in sql format
  */
@@ -14,7 +12,6 @@ int main(int argc, char *argv[])
 {
        public_key_t *public;
        private_key_t *private;
-       identification_t *keyid;
        chunk_t chunk;
        char buf[8096];
        int read, n;
@@ -37,15 +34,15 @@ int main(int argc, char *argv[])
                                                                 BUILD_END);
        if (private)
        {
-               keyid = private->get_id(private, ID_PUBKEY_INFO_SHA1);
-               chunk = keyid->get_encoding(keyid);
-
-               printf("%d, X'", ID_PUBKEY_INFO_SHA1);
-               for (n = 0; n < chunk.len; n++)
+               if (private->get_fingerprint(private, KEY_ID_PUBKEY_SHA1, &chunk))
                {
-                       printf("%.2x", chunk.ptr[n]);
+                       printf("%d, X'", ID_KEY_ID);
+                       for (n = 0; n < chunk.len; n++)
+                       {
+                               printf("%.2x", chunk.ptr[n]);
+                       }
+                       printf("'\n");
                }
-               printf("'\n");
                private->destroy(private);
                return 0;
        }
@@ -61,15 +58,15 @@ int main(int argc, char *argv[])
        }
        if (public)
        {
-               keyid = public->get_id(public, ID_PUBKEY_INFO_SHA1);
-               chunk = keyid->get_encoding(keyid);
-
-               printf("%d, X'", ID_PUBKEY_INFO_SHA1);
-               for (n = 0; n < chunk.len; n++)
+               if (public->get_fingerprint(public, KEY_ID_PUBKEY_SHA1, &chunk))
                {
-                       printf("%.2x", chunk.ptr[n]);
+                       printf("%d, X'", ID_KEY_ID);
+                       for (n = 0; n < chunk.len; n++)
+                       {
+                               printf("%.2x", chunk.ptr[n]);
+                       }
+                       printf("'\n");
                }
-               printf("'\n");
                public->destroy(public);
                return 0;
        }