gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r25992 - in gnunet/src: include util
Date: Sun, 3 Feb 2013 13:59:42 +0100

Author: grothoff
Date: 2013-02-03 13:59:42 +0100 (Sun, 03 Feb 2013)
New Revision: 25992

Modified:
   gnunet/src/include/gnunet_crypto_lib.h
   gnunet/src/util/crypto_ecc.c
Log:
-export ecc generation function

Modified: gnunet/src/include/gnunet_crypto_lib.h
===================================================================
--- gnunet/src/include/gnunet_crypto_lib.h      2013-02-03 12:59:10 UTC (rev 
25991)
+++ gnunet/src/include/gnunet_crypto_lib.h      2013-02-03 12:59:42 UTC (rev 
25992)
@@ -1264,7 +1264,16 @@
  */
 struct GNUNET_CRYPTO_EccKeyGenerationContext;
 
+/**
+ * Create a new private key. Caller must free return value.  Blocking version
+ * (blocks to gather entropy).
+ *
+ * @return fresh private key
+ */
+struct GNUNET_CRYPTO_EccPrivateKey *
+GNUNET_CRYPTO_ecc_key_create (void);
 
+
 /**
  * Create a new private key by reading it from a file.  If the files
  * does not exist, create a new key and write it to the file.  If the
@@ -1303,6 +1312,20 @@
 
 
 /**
+ * Derive key material from a public and a private ECC key.
+ *
+ * @param key private key to use for the ECDH (x)
+ * @param pub public key to use for the ECDY (yG)
+ * @param key_material where to write the key material (xyG)
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
+ */
+int
+GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EccPrivateKey *key,
+                        const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded 
*pub,
+                        struct GNUNET_HashCode *key_material);
+
+
+/**
  * Sign a given block.
  *
  * @param key private key to use for the signing

Modified: gnunet/src/util/crypto_ecc.c
===================================================================
--- gnunet/src/util/crypto_ecc.c        2013-02-03 12:59:10 UTC (rev 25991)
+++ gnunet/src/util/crypto_ecc.c        2013-02-03 12:59:42 UTC (rev 25992)
@@ -366,8 +366,8 @@
  *
  * @return fresh private key
  */
-static struct GNUNET_CRYPTO_EccPrivateKey *
-ecc_key_create ()
+struct GNUNET_CRYPTO_EccPrivateKey *
+GNUNET_CRYPTO_ecc_key_create ()
 {
   struct GNUNET_CRYPTO_EccPrivateKey *ret;
   gcry_sexp_t s_key;
@@ -555,7 +555,7 @@
     }
     LOG (GNUNET_ERROR_TYPE_INFO,
          _("Creating a new private key.  This may take a while.\n"));
-    ret = ecc_key_create ();
+    ret = GNUNET_CRYPTO_ecc_key_create ();
     GNUNET_assert (ret != NULL);
     enc = GNUNET_CRYPTO_ecc_encode_key (ret);
     GNUNET_assert (enc != NULL);
@@ -1052,4 +1052,31 @@
 }
 
 
+/**
+ * Derive key material from a public and a private ECC key.
+ *
+ * @param key private key to use for the ECDH (x)
+ * @param pub public key to use for the ECDY (yG)
+ * @param key_material where to write the key material (xyG)
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
+ */
+int
+GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EccPrivateKey *key,
+                        const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded 
*pub,
+                        struct GNUNET_HashCode *key_material)
+{ 
+  gcry_sexp_t psexp;
+
+  if (! (psexp = decode_public_key (pub)))
+    return GNUNET_SYSERR;
+  
+
+  gcry_sexp_release (psexp);
+  GNUNET_break (0); // not implemented
+  /* FIXME: this totally breaks security ... */
+  memset (key_material, 42, sizeof (struct GNUNET_HashCode));
+  return GNUNET_OK;
+}
+
+
 /* end of crypto_ecc.c */




reply via email to

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