OR
authorChristian Grothoff <christian@grothoff.org>
Tue, 9 Mar 2010 17:25:38 +0000 (17:25 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 9 Mar 2010 17:25:38 +0000 (17:25 +0000)
src/util/crypto_rsa.c
src/util/disk.c

index c3e0a7833881a12e53efd7365e31726c02038ad5..df4e24e7c57696756fb92241b1e1124aa629bdb3 100644 (file)
@@ -566,6 +566,8 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename)
   unsigned int cnt;
   int ec;
   uint64_t fs;
+  struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub;
+  struct GNUNET_PeerIdentity pid;
 
   if (GNUNET_SYSERR == GNUNET_DISK_directory_create_for_file (filename))
     return NULL;
@@ -622,8 +624,12 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename)
         GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "fcntl",
                                   filename);
       GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd));
+      GNUNET_CRYPTO_rsa_key_get_public (ret, &pub);
+      GNUNET_CRYPTO_hash (&pub, sizeof (pub), &pid.hashPubKey);
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                  _("Stored new private key in `%s'.\n"), filename);
+                  _("I am host `%s'.  Stored new private key in `%s'.\n"), 
+                 GNUNET_i2s (&pid),
+                 filename);
       return ret;
     }
   /* hostkey file exists already, read it! */
@@ -716,6 +722,12 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename)
                                sizeof (struct RsaPrivateKeyBinaryEncoded)))
     GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
   GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd));
+  GNUNET_CRYPTO_rsa_key_get_public (ret, &pub);
+  GNUNET_CRYPTO_hash (&pub, sizeof (pub), &pid.hashPubKey);
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+             _("I am host `%s'.  Read private key from `%s'.\n"), 
+             GNUNET_i2s (&pid),
+             filename);
   return ret;
 }
 
index c1a988464476a64691baead2756777cff32cbc1d..fa737843c7bb88034143d7d5df410b9056760d3e 100644 (file)
@@ -1208,7 +1208,7 @@ GNUNET_DISK_file_open (const char *fn,
       return NULL;
     }
   if (flags & GNUNET_DISK_OPEN_FAILIFEXISTS)
-    oflags |= (O_CREAT & O_EXCL);
+    oflags |= (O_CREAT | O_EXCL);
   if (flags & GNUNET_DISK_OPEN_TRUNCATE)
     oflags |= O_TRUNC;
   if (flags & GNUNET_DISK_OPEN_APPEND)