gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r29008 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r29008 - gnunet/src/util
Date: Thu, 5 Sep 2013 10:06:15 +0200

Author: grothoff
Date: 2013-09-05 10:06:15 +0200 (Thu, 05 Sep 2013)
New Revision: 29008

Modified:
   gnunet/src/util/crypto_ecc.c
   gnunet/src/util/crypto_hash.c
Log:
-only use x for ECDH

Modified: gnunet/src/util/crypto_ecc.c
===================================================================
--- gnunet/src/util/crypto_ecc.c        2013-09-05 04:29:41 UTC (rev 29007)
+++ gnunet/src/util/crypto_ecc.c        2013-09-05 08:06:15 UTC (rev 29008)
@@ -835,26 +835,21 @@
  * @param priv private key to use for the ECDH (x)
  * @param pub public key to use for the ECDH (yG)
  * @param key_material where to write the key material (xyG)
- * @return GNUNET_SYSERR on error, GNUNET_OK on success
+ * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
  */
 int
 GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EccPrivateKey *priv,
                         const struct GNUNET_CRYPTO_EccPublicKey *pub,
                         struct GNUNET_HashCode *key_material)
 { 
-  size_t slen;
-  unsigned char sdata_buf[2048]; /* big enough to print
-                                   dh-shared-secret as
-                                   S-expression */
   gcry_mpi_point_t result;
   gcry_mpi_point_t q;
   gcry_mpi_t d;
   gcry_ctx_t ctx;
   gcry_sexp_t pub_sexpr;
-  gcry_sexp_t ecdh_sexp;
   gcry_mpi_t result_x;
   gcry_mpi_t result_y;
-  int rc;
+  unsigned char xbuf[256 / 8];
 
   /* first, extract the q = dP value from the public key */
   if (! (pub_sexpr = decode_public_key (pub)))
@@ -885,26 +880,11 @@
   gcry_mpi_point_release (result);
   gcry_ctx_release (ctx);
   /* FIXME: only use 'result_x' as key material */
-  if (0 != (rc = gcry_sexp_build (&ecdh_sexp, NULL, 
-                                 "(dh-shared-secret (x %m)(y %m))",
-                                 result_x,
-                                 result_y)))
-  {
-    LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc);
-    gcry_mpi_release (result_x);
-    gcry_mpi_release (result_y);
-    return GNUNET_SYSERR;
-  }
+
+  mpi_print (xbuf, sizeof (xbuf), result_x);
+  GNUNET_CRYPTO_hash (xbuf, sizeof (xbuf), key_material);
   gcry_mpi_release (result_x);
   gcry_mpi_release (result_y);
-  slen = gcry_sexp_sprint (ecdh_sexp,
-                          GCRYSEXP_FMT_DEFAULT, 
-                          sdata_buf, sizeof (sdata_buf));
-  GNUNET_assert (0 != slen);
-  gcry_sexp_release (ecdh_sexp);
-  /* finally, get a string of the resulting S-expression and hash it
-     to generate the key material */
-  GNUNET_CRYPTO_hash (sdata_buf, slen, key_material);
   return GNUNET_OK;
 }
 

Modified: gnunet/src/util/crypto_hash.c
===================================================================
--- gnunet/src/util/crypto_hash.c       2013-09-05 04:29:41 UTC (rev 29007)
+++ gnunet/src/util/crypto_hash.c       2013-09-05 08:06:15 UTC (rev 29008)
@@ -290,6 +290,8 @@
 
 
 /**
+ * @ingroup hash
+ * 
  * Compute the distance between 2 hashcodes.  The computation must be
  * fast, not involve bits[0] or bits[4] (they're used elsewhere), and be
  * somewhat consistent. And of course, the result should be a positive




reply via email to

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