diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-10 14:38:55 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-10 14:38:55 +0000 |
commit | 9351b1e9bdf2b067b6db06562c26ba658cff42b8 (patch) | |
tree | 68dc4ab447e7e8b6a20a706858cd36238c1c7c5f /src/util/gnunet-ecc.c | |
parent | 8beabcd96c0cf1e1873c0b5ff96e537f1beb0b34 (diff) | |
download | gnunet-9351b1e9bdf2b067b6db06562c26ba658cff42b8.tar.gz gnunet-9351b1e9bdf2b067b6db06562c26ba658cff42b8.zip |
separating ECC crypto into functions/structs for ECDHE, ECDSA and EDDSA
Diffstat (limited to 'src/util/gnunet-ecc.c')
-rw-r--r-- | src/util/gnunet-ecc.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/util/gnunet-ecc.c b/src/util/gnunet-ecc.c index 23e562cbe..e76321e5e 100644 --- a/src/util/gnunet-ecc.c +++ b/src/util/gnunet-ecc.c | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file util/gnunet-ecc.c | 22 | * @file util/gnunet-ecc.c |
23 | * @brief tool to manipulate ECC key files | 23 | * @brief tool to manipulate EDDSA key files |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
@@ -52,7 +52,7 @@ static void | |||
52 | create_keys (const char *fn) | 52 | create_keys (const char *fn) |
53 | { | 53 | { |
54 | FILE *f; | 54 | FILE *f; |
55 | struct GNUNET_CRYPTO_EccPrivateKey *pk; | 55 | struct GNUNET_CRYPTO_EddsaPrivateKey *pk; |
56 | 56 | ||
57 | if (NULL == (f = fopen (fn, "w+"))) | 57 | if (NULL == (f = fopen (fn, "w+"))) |
58 | { | 58 | { |
@@ -69,7 +69,7 @@ create_keys (const char *fn) | |||
69 | { | 69 | { |
70 | fprintf (stderr, | 70 | fprintf (stderr, |
71 | "."); | 71 | "."); |
72 | if (NULL == (pk = GNUNET_CRYPTO_ecc_key_create ())) | 72 | if (NULL == (pk = GNUNET_CRYPTO_eddsa_key_create ())) |
73 | { | 73 | { |
74 | GNUNET_break (0); | 74 | GNUNET_break (0); |
75 | break; | 75 | break; |
@@ -109,12 +109,14 @@ static void | |||
109 | run (void *cls, char *const *args, const char *cfgfile, | 109 | run (void *cls, char *const *args, const char *cfgfile, |
110 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 110 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
111 | { | 111 | { |
112 | struct GNUNET_CRYPTO_EccPrivateKey *pk; | 112 | struct GNUNET_CRYPTO_EddsaPrivateKey *pk; |
113 | struct GNUNET_CRYPTO_EccPublicSignKey pub; | 113 | struct GNUNET_CRYPTO_EddsaPublicKey pub; |
114 | 114 | ||
115 | if (NULL == args[0]) | 115 | if (NULL == args[0]) |
116 | { | 116 | { |
117 | fprintf (stderr, _("No hostkey file specified on command line\n")); | 117 | FPRINTF (stderr, |
118 | "%s", | ||
119 | _("No hostkey file specified on command line\n")); | ||
118 | return; | 120 | return; |
119 | } | 121 | } |
120 | if (make_keys > 0) | 122 | if (make_keys > 0) |
@@ -122,25 +124,27 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
122 | create_keys (args[0]); | 124 | create_keys (args[0]); |
123 | return; | 125 | return; |
124 | } | 126 | } |
125 | pk = GNUNET_CRYPTO_ecc_key_create_from_file (args[0]); | 127 | pk = GNUNET_CRYPTO_eddsa_key_create_from_file (args[0]); |
126 | if (NULL == pk) | 128 | if (NULL == pk) |
127 | return; | 129 | return; |
128 | if (print_public_key) | 130 | if (print_public_key) |
129 | { | 131 | { |
130 | char *s; | 132 | char *s; |
131 | 133 | ||
132 | GNUNET_CRYPTO_ecc_key_get_public_for_signature (pk, &pub); | 134 | GNUNET_CRYPTO_eddsa_key_get_public (pk, &pub); |
133 | s = GNUNET_CRYPTO_ecc_public_sign_key_to_string (&pub); | 135 | s = GNUNET_CRYPTO_eddsa_public_key_to_string (&pub); |
134 | fprintf (stdout, "%s\n", s); | 136 | FPRINTF (stdout, |
137 | "%s\n", | ||
138 | s); | ||
135 | GNUNET_free (s); | 139 | GNUNET_free (s); |
136 | } | 140 | } |
137 | if (print_peer_identity) | 141 | if (print_peer_identity) |
138 | { | 142 | { |
139 | char *str; | 143 | char *str; |
140 | 144 | ||
141 | GNUNET_CRYPTO_ecc_key_get_public_for_signature (pk, &pub); | 145 | GNUNET_CRYPTO_eddsa_key_get_public (pk, &pub); |
142 | str = GNUNET_CRYPTO_ecc_public_sign_key_to_string (&pub); | 146 | str = GNUNET_CRYPTO_eddsa_public_key_to_string (&pub); |
143 | fprintf (stdout, | 147 | FPRINTF (stdout, |
144 | "%s\n", | 148 | "%s\n", |
145 | str); | 149 | str); |
146 | GNUNET_free (str); | 150 | GNUNET_free (str); |