[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r28796 - gnunet/src/namestore
From: |
gnunet |
Subject: |
[GNUnet-SVN] r28796 - gnunet/src/namestore |
Date: |
Thu, 22 Aug 2013 17:15:40 +0200 |
Author: grothoff
Date: 2013-08-22 17:15:40 +0200 (Thu, 22 Aug 2013)
New Revision: 28796
Modified:
gnunet/src/namestore/namestore_api_common.c
Log:
-implementing zkey <-> pkey conversion functions
Modified: gnunet/src/namestore/namestore_api_common.c
===================================================================
--- gnunet/src/namestore/namestore_api_common.c 2013-08-22 14:14:03 UTC (rev
28795)
+++ gnunet/src/namestore/namestore_api_common.c 2013-08-22 15:15:40 UTC (rev
28796)
@@ -967,8 +967,19 @@
const char *
GNUNET_NAMESTORE_pkey_to_zkey (const struct GNUNET_CRYPTO_EccPublicKey *pkey)
{
- GNUNET_break (0); // not implemented
- return NULL;
+ static char ret[256];
+ char *pkeys;
+ size_t slen;
+
+ pkeys = GNUNET_CRYPTO_ecc_public_key_to_string (pkey);
+ slen = strlen (pkeys);
+ GNUNET_snprintf (ret,
+ sizeof (ret),
+ "%s.%.*s.zkey",
+ &pkeys[slen / 2],
+ (int) (slen / 2),
+ pkeys);
+ return ret;
}
@@ -985,7 +996,41 @@
GNUNET_NAMESTORE_zkey_to_pkey (const char *zkey,
struct GNUNET_CRYPTO_EccPublicKey *pkey)
{
- GNUNET_break (0); // not implemented
+ char *cpy;
+ char *dot;
+ const char *x;
+ const char *y;
+ char *pkeys;
+
+ cpy = GNUNET_strdup (zkey);
+ y = cpy;
+ if (NULL == (dot = strchr (y, (int) '.')))
+ goto error;
+ *dot = '\0';
+ x = dot + 1;
+ if (NULL == (dot = strchr (x, (int) '.')))
+ goto error;
+ *dot = '\0';
+ if (0 != strcasecmp (dot + 1,
+ "zkey"))
+ goto error;
+ GNUNET_asprintf (&pkeys,
+ "%s%s",
+ x, y);
+ GNUNET_free (cpy);
+ if (GNUNET_OK !=
+ GNUNET_CRYPTO_ecc_public_key_from_string (pkeys,
+ strlen (pkeys),
+ pkey))
+ {
+ GNUNET_free (pkeys);
+ return GNUNET_SYSERR;
+ }
+ GNUNET_free (pkeys);
+ return GNUNET_OK;
+ error:
+ GNUNET_break (0);
+ GNUNET_free (cpy);
return GNUNET_SYSERR;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r28796 - gnunet/src/namestore,
gnunet <=