Added silc_show_public_key_file.
authorPekka Riikonen <priikone@silcnet.org>
Thu, 9 Nov 2006 16:11:01 +0000 (16:11 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Thu, 9 Nov 2006 16:11:01 +0000 (16:11 +0000)
lib/silcapputil/silcapputil.c
lib/silcapputil/silcapputil.h

index 39fce81cacab76f343281ed4122d1bef8c3f7a8d..2e9fbe685ff6bc3e51a86005aaec33ca77f0d877 100644 (file)
@@ -262,9 +262,8 @@ SilcBool silc_load_key_pair(const char *pub_filename,
 
 /* Dump public key into stdout */
 
-SilcBool silc_show_public_key(const char *pub_filename)
+SilcBool silc_show_public_key(SilcPublicKey public_key)
 {
-  SilcPublicKey public_key;
   SilcSILCPublicKey silc_pubkey;
   SilcPublicKeyIdentifier ident;
   char *fingerprint, *babbleprint;
@@ -272,11 +271,6 @@ SilcBool silc_show_public_key(const char *pub_filename)
   SilcUInt32 pk_len;
   SilcUInt32 key_len = 0;
 
-  if (!silc_pkcs_load_public_key((char *)pub_filename, &public_key)) {
-    fprintf(stderr, "Could not load public key file `%s'\n", pub_filename);
-    return FALSE;
-  }
-
   silc_pubkey = silc_pkcs_get_context(SILC_PKCS_SILC, public_key);
   if (!silc_pubkey) {
     silc_pkcs_public_key_free(public_key);
@@ -293,7 +287,6 @@ SilcBool silc_show_public_key(const char *pub_filename)
   fingerprint = silc_hash_fingerprint(NULL, pk, pk_len);
   babbleprint = silc_hash_babbleprint(NULL, pk, pk_len);
 
-  printf("Public key file    : %s\n", pub_filename);
   printf("Algorithm          : %s\n", silc_pkcs_get_name(public_key));
   if (key_len)
     printf("Key length (bits)  : %d\n", (unsigned int)key_len);
@@ -317,11 +310,29 @@ SilcBool silc_show_public_key(const char *pub_filename)
   silc_free(fingerprint);
   silc_free(babbleprint);
   silc_free(pk);
-  silc_pkcs_public_key_free(public_key);
 
   return TRUE;
 }
 
+/* Dump public key into stdout */
+
+SilcBool silc_show_public_key_file(const char *pub_filename)
+{
+  SilcPublicKey public_key;
+  SilcBool ret;
+
+  if (!silc_pkcs_load_public_key((char *)pub_filename, &public_key)) {
+    fprintf(stderr, "Could not load public key file `%s'\n", pub_filename);
+    return FALSE;
+  }
+
+  printf("Public key file    : %s\n", pub_filename);
+  ret = silc_show_public_key(public_key);
+  silc_pkcs_public_key_free(public_key);
+
+  return ret;
+}
+
 /* Change private key passphrase */
 
 SilcBool silc_change_private_key_passphrase(const char *prv_filename,
index 3b0383586e761816604190476cdd06b65d6d405f..4d3b8b01475da53a19ef2fe4796185838d3a2014 100644 (file)
@@ -117,7 +117,21 @@ SilcBool silc_load_key_pair(const char *pub_filename,
  *
  * SYNOPSIS
  *
- *    SilcBool silc_show_public_key(const char *pub_filename);
+ *    SilcBool silc_show_public_key(SilcPublicKey public_key);
+ *
+ * DESCRIPTION
+ *
+ *    This routine can be used to dump the SILC public key into human
+ *    readable form into stdout.  Returns FALSE on error.
+ *
+ ***/
+SilcBool silc_show_public_key(SilcPublicKey public_key);
+
+/****f* silcapputil/SilcAppUtil/silc_show_public_key_file
+ *
+ * SYNOPSIS
+ *
+ *    SilcBool silc_show_public_key_file(const char *pub_filename);
  *
  * DESCRIPTION
  *
@@ -126,7 +140,7 @@ SilcBool silc_load_key_pair(const char *pub_filename,
  *    into human readable form into stdout.  Returns FALSE on error.
  *
  ***/
-SilcBool silc_show_public_key(const char *pub_filename);
+SilcBool silc_show_public_key_file(const char *pub_filename);
 
 /****f* silcapputil/SilcAppUtil/silc_change_private_key_passphrase
  *