[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r28497 - in gnunet/src: fs include util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r28497 - in gnunet/src: fs include util |
Date: |
Sun, 11 Aug 2013 17:36:42 +0200 |
Author: grothoff
Date: 2013-08-11 17:36:42 +0200 (Sun, 11 Aug 2013)
New Revision: 28497
Modified:
gnunet/src/fs/fs_publish_ublock.c
gnunet/src/fs/fs_search.c
gnunet/src/include/gnunet_crypto_lib.h
gnunet/src/util/crypto_ecc.c
gnunet/src/util/test_crypto_ecc.c
Log:
-add extra context argument for key deriviation, so that fs and gads do not
collide
Modified: gnunet/src/fs/fs_publish_ublock.c
===================================================================
--- gnunet/src/fs/fs_publish_ublock.c 2013-08-11 12:58:14 UTC (rev 28496)
+++ gnunet/src/fs/fs_publish_ublock.c 2013-08-11 15:36:42 UTC (rev 28497)
@@ -242,7 +242,7 @@
ub_enc->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_UBLOCK);
/* derive signing-key from 'label' and public key of the namespace */
- nsd = GNUNET_CRYPTO_ecc_key_derive (ns, label);
+ nsd = GNUNET_CRYPTO_ecc_key_derive (ns, label, "fs-ublock");
GNUNET_CRYPTO_ecc_key_get_public (nsd,
&ub_enc->verification_key);
GNUNET_assert (GNUNET_OK ==
Modified: gnunet/src/fs/fs_search.c
===================================================================
--- gnunet/src/fs/fs_search.c 2013-08-11 12:58:14 UTC (rev 28496)
+++ gnunet/src/fs/fs_search.c 2013-08-11 15:36:42 UTC (rev 28497)
@@ -1104,6 +1104,7 @@
memset (&sm->target, 0, sizeof (struct GNUNET_HashCode));
GNUNET_CRYPTO_ecc_public_key_derive (&sc->uri->data.sks.ns,
sc->uri->data.sks.identifier,
+ "fs-ublock",
&dpub);
GNUNET_CRYPTO_hash (&dpub,
sizeof (dpub),
@@ -1290,6 +1291,7 @@
sre->keyword = GNUNET_strdup (keyword);
GNUNET_CRYPTO_ecc_public_key_derive (&anon_pub,
keyword,
+ "fs-ublock",
&sre->dpub);
GNUNET_CRYPTO_hash (&sre->dpub,
sizeof (struct GNUNET_CRYPTO_EccPublicKey),
Modified: gnunet/src/include/gnunet_crypto_lib.h
===================================================================
--- gnunet/src/include/gnunet_crypto_lib.h 2013-08-11 12:58:14 UTC (rev
28496)
+++ gnunet/src/include/gnunet_crypto_lib.h 2013-08-11 15:36:42 UTC (rev
28497)
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet.
- (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2012 Christian Grothoff
(and other contributing authors)
+ (C) 2001-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
@@ -979,11 +979,14 @@
*
* @param priv original private key
* @param label label to use for key deriviation
+ * @param context additional context to use for HKDF of 'h';
+ * typically the name of the subsystem/application
* @return derived private key
*/
struct GNUNET_CRYPTO_EccPrivateKey *
GNUNET_CRYPTO_ecc_key_derive (const struct GNUNET_CRYPTO_EccPrivateKey *priv,
- const char *label);
+ const char *label,
+ const char *context);
/**
@@ -992,11 +995,14 @@
*
* @param pub original public key
* @param label label to use for key deriviation
+ * @param context additional context to use for HKDF of 'h'.
+ * typically the name of the subsystem/application
* @param result where to write the derived public key
*/
void
GNUNET_CRYPTO_ecc_public_key_derive (const struct GNUNET_CRYPTO_EccPublicKey
*pub,
const char *label,
+ const char *context,
struct GNUNET_CRYPTO_EccPublicKey *result);
Modified: gnunet/src/util/crypto_ecc.c
===================================================================
--- gnunet/src/util/crypto_ecc.c 2013-08-11 12:58:14 UTC (rev 28496)
+++ gnunet/src/util/crypto_ecc.c 2013-08-11 15:36:42 UTC (rev 28497)
@@ -926,11 +926,14 @@
*
* @param pub public key for deriviation
* @param label label for deriviation
+ * @param context additional context to use for HKDF of 'h';
+ * typically the name of the subsystem/application
* @return h value
*/
static gcry_mpi_t
derive_h (const struct GNUNET_CRYPTO_EccPublicKey *pub,
- const char *label)
+ const char *label,
+ const char *context)
{
gcry_mpi_t h;
struct GNUNET_HashCode hc;
@@ -939,6 +942,7 @@
"key-derivation", strlen ("key-derivation"),
pub, sizeof (*pub),
label, strlen (label),
+ context, strlen (context),
NULL, 0);
mpi_scan (&h, (unsigned char *) &hc, sizeof (hc));
return h;
@@ -953,11 +957,14 @@
*
* @param priv original private key
* @param label label to use for key deriviation
+ * @param context additional context to use for HKDF of 'h';
+ * typically the name of the subsystem/application
* @return derived private key
*/
struct GNUNET_CRYPTO_EccPrivateKey *
GNUNET_CRYPTO_ecc_key_derive (const struct GNUNET_CRYPTO_EccPrivateKey *priv,
- const char *label)
+ const char *label,
+ const char *context)
{
struct GNUNET_CRYPTO_EccPublicKey pub;
struct GNUNET_CRYPTO_EccPrivateKey *ret;
@@ -970,7 +977,7 @@
GNUNET_assert (0 == gcry_mpi_ec_new (&ctx, NULL, CURVE));
n = gcry_mpi_ec_get_mpi ("n", ctx, 0 /* no copy */);
GNUNET_CRYPTO_ecc_key_get_public (priv, &pub);
- h = derive_h (&pub, label);
+ h = derive_h (&pub, label, context);
mpi_scan (&x, priv->d, sizeof (priv->d));
d = gcry_mpi_new (256);
gcry_mpi_mulm (d, h, x, n);
@@ -989,11 +996,14 @@
*
* @param pub original public key
* @param label label to use for key deriviation
+ * @param context additional context to use for HKDF of 'h';
+ * typically the name of the subsystem/application
* @param result where to write the derived public key
*/
void
GNUNET_CRYPTO_ecc_public_key_derive (const struct GNUNET_CRYPTO_EccPublicKey
*pub,
const char *label,
+ const char *context,
struct GNUNET_CRYPTO_EccPublicKey *result)
{
gcry_ctx_t ctx;
@@ -1017,7 +1027,7 @@
gcry_mpi_release (q_y);
/* calulcate h_mod_n = h % n */
- h = derive_h (pub, label);
+ h = derive_h (pub, label, context);
n = gcry_mpi_ec_get_mpi ("n", ctx, 0 /* no copy */);
h_mod_n = gcry_mpi_new (256);
gcry_mpi_mod (h_mod_n, h, n);
Modified: gnunet/src/util/test_crypto_ecc.c
===================================================================
--- gnunet/src/util/test_crypto_ecc.c 2013-08-11 12:58:14 UTC (rev 28496)
+++ gnunet/src/util/test_crypto_ecc.c 2013-08-11 15:36:42 UTC (rev 28497)
@@ -95,9 +95,9 @@
struct GNUNET_CRYPTO_EccPublicKey pkey;
struct GNUNET_CRYPTO_EccPublicKey dpub;
- dpriv = GNUNET_CRYPTO_ecc_key_derive (key, "test-derive");
+ dpriv = GNUNET_CRYPTO_ecc_key_derive (key, "test-derive", "test-CTX");
GNUNET_CRYPTO_ecc_key_get_public (key, &pkey);
- GNUNET_CRYPTO_ecc_public_key_derive (&pkey, "test-derive", &dpub);
+ GNUNET_CRYPTO_ecc_public_key_derive (&pkey, "test-derive", "test-CTX",
&dpub);
purp.size = htonl (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose));
purp.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TEST);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r28497 - in gnunet/src: fs include util,
gnunet <=