aboutsummaryrefslogtreecommitdiff
path: root/src/util/gnunet-ecc.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-08-06 14:18:31 +0000
committerChristian Grothoff <christian@grothoff.org>2013-08-06 14:18:31 +0000
commitfe76c075e315c0351e2fe465434ae39087daf014 (patch)
tree436887ccaf331932a3c13a8b9d2a2a710dad4be6 /src/util/gnunet-ecc.c
parent7eb2835d8a494c83aedb720a2ac6f6e5ba23f22f (diff)
downloadgnunet-fe76c075e315c0351e2fe465434ae39087daf014.tar.gz
gnunet-fe76c075e315c0351e2fe465434ae39087daf014.zip
moving to new, fixed-size encoding of public and private ECC keys everywhere, also improving ECC API to better support ECRS/GADS operations
Diffstat (limited to 'src/util/gnunet-ecc.c')
-rw-r--r--src/util/gnunet-ecc.c25
1 files changed, 5 insertions, 20 deletions
diff --git a/src/util/gnunet-ecc.c b/src/util/gnunet-ecc.c
index a00ef0573..0805e3f94 100644
--- a/src/util/gnunet-ecc.c
+++ b/src/util/gnunet-ecc.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2012 Christian Grothoff (and other contributing authors) 3 (C) 2012, 2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -49,15 +49,6 @@ static int print_short_identity;
49 */ 49 */
50static unsigned int make_keys; 50static unsigned int make_keys;
51 51
52/**
53 * The private information of an ECC key pair.
54 * NOTE: this must match the definition in crypto_ksk.c and crypto_ecc.c!
55 */
56struct GNUNET_CRYPTO_EccPrivateKey
57{
58 gcry_sexp_t sexp;
59};
60
61 52
62/** 53/**
63 * Create a flat file with a large number of key pairs for testing. 54 * Create a flat file with a large number of key pairs for testing.
@@ -65,10 +56,8 @@ struct GNUNET_CRYPTO_EccPrivateKey
65static void 56static void
66create_keys (const char *fn) 57create_keys (const char *fn)
67{ 58{
68 static char pad[GNUNET_TESTING_HOSTKEYFILESIZE];
69 FILE *f; 59 FILE *f;
70 struct GNUNET_CRYPTO_EccPrivateKey *pk; 60 struct GNUNET_CRYPTO_EccPrivateKey *pk;
71 struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *enc;
72 61
73 if (NULL == (f = fopen (fn, "w+"))) 62 if (NULL == (f = fopen (fn, "w+")))
74 { 63 {
@@ -90,22 +79,18 @@ create_keys (const char *fn)
90 GNUNET_break (0); 79 GNUNET_break (0);
91 break; 80 break;
92 } 81 }
93 enc = GNUNET_CRYPTO_ecc_encode_key (pk); 82 if (GNUNET_TESTING_HOSTKEYFILESIZE !=
94 GNUNET_assert (ntohs (enc->size) <= GNUNET_TESTING_HOSTKEYFILESIZE); 83 fwrite (pk, 1,
95 if ( (ntohs (enc->size) != fwrite (enc, 1, ntohs (enc->size), f)) || 84 GNUNET_TESTING_HOSTKEYFILESIZE, f))
96 (GNUNET_TESTING_HOSTKEYFILESIZE - ntohs (enc->size)
97 != fwrite (pad, 1, GNUNET_TESTING_HOSTKEYFILESIZE - ntohs (enc->size), f)) )
98 { 85 {
99 fprintf (stderr, 86 fprintf (stderr,
100 _("\nFailed to write to `%s': %s\n"), 87 _("\nFailed to write to `%s': %s\n"),
101 fn, 88 fn,
102 STRERROR (errno)); 89 STRERROR (errno));
103 GNUNET_CRYPTO_ecc_key_free (pk); 90 GNUNET_CRYPTO_ecc_key_free (pk);
104 GNUNET_free (enc);
105 break; 91 break;
106 } 92 }
107 GNUNET_CRYPTO_ecc_key_free (pk); 93 GNUNET_CRYPTO_ecc_key_free (pk);
108 GNUNET_free (enc);
109 } 94 }
110 if (UINT_MAX == make_keys) 95 if (UINT_MAX == make_keys)
111 fprintf (stderr, 96 fprintf (stderr,
@@ -130,7 +115,7 @@ run (void *cls, char *const *args, const char *cfgfile,
130 const struct GNUNET_CONFIGURATION_Handle *cfg) 115 const struct GNUNET_CONFIGURATION_Handle *cfg)
131{ 116{
132 struct GNUNET_CRYPTO_EccPrivateKey *pk; 117 struct GNUNET_CRYPTO_EccPrivateKey *pk;
133 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pub; 118 struct GNUNET_CRYPTO_EccPublicKey pub;
134 struct GNUNET_PeerIdentity pid; 119 struct GNUNET_PeerIdentity pid;
135 120
136 if (NULL == args[0]) 121 if (NULL == args[0])