gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r27000 - in gnunet/src: include util


From: gnunet
Subject: [GNUnet-SVN] r27000 - in gnunet/src: include util
Date: Sat, 27 Apr 2013 13:04:29 +0200

Author: dold
Date: 2013-04-27 13:04:29 +0200 (Sat, 27 Apr 2013)
New Revision: 27000

Modified:
   gnunet/src/include/gnunet_crypto_lib.h
   gnunet/src/util/crypto_ecc.c
Log:
implemented GNUNET_CRYPTO_get_host_identity


Modified: gnunet/src/include/gnunet_crypto_lib.h
===================================================================
--- gnunet/src/include/gnunet_crypto_lib.h      2013-04-26 15:43:16 UTC (rev 
26999)
+++ gnunet/src/include/gnunet_crypto_lib.h      2013-04-27 11:04:29 UTC (rev 
27000)
@@ -1327,6 +1327,19 @@
 
 
 /**
+ * Retrieve the identity of the host's peer.
+ *
+ * @param cfg configuration to use
+ * @param dst pointer to where to write the peer identity
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the identity
+ *         could not be retrieved
+ */
+int
+GNUNET_CRYPTO_get_host_identity (const struct GNUNET_CONFIGURATION_Handle *cfg,
+                                 struct GNUNET_PeerIdentity *dst);
+
+
+/**
  * Derive key material from a public and a private ECC key.
  *
  * @param key private key to use for the ECDH (x)

Modified: gnunet/src/util/crypto_ecc.c
===================================================================
--- gnunet/src/util/crypto_ecc.c        2013-04-26 15:43:16 UTC (rev 26999)
+++ gnunet/src/util/crypto_ecc.c        2013-04-27 11:04:29 UTC (rev 27000)
@@ -918,6 +918,45 @@
 
 
 /**
+ * Retrieve the identity of the host's peer.
+ *
+ * @param cfg configuration to use
+ * @param dst pointer to where to write the peer identity
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the identity
+ *         could not be retrieved
+ */
+int
+GNUNET_CRYPTO_get_host_identity (const struct GNUNET_CONFIGURATION_Handle *cfg,
+                                 struct GNUNET_PeerIdentity *dst)
+{
+  struct GNUNET_CRYPTO_EccPrivateKey *my_private_key;
+  struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded my_public_key;
+  char *keyfile;
+  
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_filename (cfg, "PEER", "PRIVATE_KEY",
+                                               &keyfile))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                _("Lacking key configuration settings.\n"));
+    return GNUNET_SYSERR;
+  }
+  if (NULL == (my_private_key = GNUNET_CRYPTO_ecc_key_create_from_file 
(keyfile)))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                _("Could not access hostkey file `%s'.\n"), keyfile);
+    GNUNET_free (keyfile);
+    return GNUNET_SYSERR;
+  }
+  GNUNET_free (keyfile);
+  GNUNET_CRYPTO_ecc_key_get_public (my_private_key, &my_public_key);
+  GNUNET_CRYPTO_ecc_key_free (my_private_key);
+  GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key), 
&dst->hashPubKey);
+  return GNUNET_OK;
+}
+
+
+/**
  * Convert the data specified in the given purpose argument to an
  * S-expression suitable for signature operations.
  *




reply via email to

[Prev in Thread] Current Thread [Next in Thread]