diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
commit | c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch) | |
tree | cac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/util/crypto_ecc.c | |
parent | fbb71d527c7d6babf269a8fefce1db291b9f7068 (diff) | |
download | gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip |
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/util/crypto_ecc.c')
-rw-r--r-- | src/util/crypto_ecc.c | 1394 |
1 files changed, 697 insertions, 697 deletions
diff --git a/src/util/crypto_ecc.c b/src/util/crypto_ecc.c index fed7c9ece..6b11cdada 100644 --- a/src/util/crypto_ecc.c +++ b/src/util/crypto_ecc.c | |||
@@ -39,13 +39,13 @@ | |||
39 | */ | 39 | */ |
40 | #define CURVE "Ed25519" | 40 | #define CURVE "Ed25519" |
41 | 41 | ||
42 | #define LOG(kind, ...) GNUNET_log_from(kind, "util-crypto-ecc", __VA_ARGS__) | 42 | #define LOG(kind, ...) GNUNET_log_from (kind, "util-crypto-ecc", __VA_ARGS__) |
43 | 43 | ||
44 | #define LOG_STRERROR(kind, syscall) \ | 44 | #define LOG_STRERROR(kind, syscall) \ |
45 | GNUNET_log_from_strerror(kind, "util-crypto-ecc", syscall) | 45 | GNUNET_log_from_strerror (kind, "util-crypto-ecc", syscall) |
46 | 46 | ||
47 | #define LOG_STRERROR_FILE(kind, syscall, filename) \ | 47 | #define LOG_STRERROR_FILE(kind, syscall, filename) \ |
48 | GNUNET_log_from_strerror_file(kind, "util-crypto-ecc", syscall, filename) | 48 | GNUNET_log_from_strerror_file (kind, "util-crypto-ecc", syscall, filename) |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * Log an error message at log-level 'level' that indicates | 51 | * Log an error message at log-level 'level' that indicates |
@@ -54,14 +54,14 @@ | |||
54 | */ | 54 | */ |
55 | #define LOG_GCRY(level, cmd, rc) \ | 55 | #define LOG_GCRY(level, cmd, rc) \ |
56 | do \ | 56 | do \ |
57 | { \ | 57 | { \ |
58 | LOG(level, \ | 58 | LOG (level, \ |
59 | _("`%s' failed at %s:%d with error: %s\n"), \ | 59 | _ ("`%s' failed at %s:%d with error: %s\n"), \ |
60 | cmd, \ | 60 | cmd, \ |
61 | __FILE__, \ | 61 | __FILE__, \ |
62 | __LINE__, \ | 62 | __LINE__, \ |
63 | gcry_strerror(rc)); \ | 63 | gcry_strerror (rc)); \ |
64 | } while (0) | 64 | } while (0) |
65 | 65 | ||
66 | 66 | ||
67 | /** | 67 | /** |
@@ -74,52 +74,52 @@ | |||
74 | * @return 0 on success | 74 | * @return 0 on success |
75 | */ | 75 | */ |
76 | static int | 76 | static int |
77 | key_from_sexp(gcry_mpi_t *array, | 77 | key_from_sexp (gcry_mpi_t *array, |
78 | gcry_sexp_t sexp, | 78 | gcry_sexp_t sexp, |
79 | const char *topname, | 79 | const char *topname, |
80 | const char *elems) | 80 | const char *elems) |
81 | { | 81 | { |
82 | gcry_sexp_t list; | 82 | gcry_sexp_t list; |
83 | gcry_sexp_t l2; | 83 | gcry_sexp_t l2; |
84 | unsigned int idx; | 84 | unsigned int idx; |
85 | 85 | ||
86 | list = gcry_sexp_find_token(sexp, topname, 0); | 86 | list = gcry_sexp_find_token (sexp, topname, 0); |
87 | if (!list) | 87 | if (! list) |
88 | return 1; | 88 | return 1; |
89 | l2 = gcry_sexp_cadr(list); | 89 | l2 = gcry_sexp_cadr (list); |
90 | gcry_sexp_release(list); | 90 | gcry_sexp_release (list); |
91 | list = l2; | 91 | list = l2; |
92 | if (!list) | 92 | if (! list) |
93 | return 2; | 93 | return 2; |
94 | 94 | ||
95 | idx = 0; | 95 | idx = 0; |
96 | for (const char *s = elems; *s; s++, idx++) | 96 | for (const char *s = elems; *s; s++, idx++) |
97 | { | ||
98 | l2 = gcry_sexp_find_token (list, s, 1); | ||
99 | if (! l2) | ||
97 | { | 100 | { |
98 | l2 = gcry_sexp_find_token(list, s, 1); | 101 | for (unsigned int i = 0; i < idx; i++) |
99 | if (!l2) | 102 | { |
100 | { | 103 | gcry_free (array[i]); |
101 | for (unsigned int i = 0; i < idx; i++) | 104 | array[i] = NULL; |
102 | { | 105 | } |
103 | gcry_free(array[i]); | 106 | gcry_sexp_release (list); |
104 | array[i] = NULL; | 107 | return 3; /* required parameter not found */ |
105 | } | ||
106 | gcry_sexp_release(list); | ||
107 | return 3; /* required parameter not found */ | ||
108 | } | ||
109 | array[idx] = gcry_sexp_nth_mpi(l2, 1, GCRYMPI_FMT_USG); | ||
110 | gcry_sexp_release(l2); | ||
111 | if (!array[idx]) | ||
112 | { | ||
113 | for (unsigned int i = 0; i < idx; i++) | ||
114 | { | ||
115 | gcry_free(array[i]); | ||
116 | array[i] = NULL; | ||
117 | } | ||
118 | gcry_sexp_release(list); | ||
119 | return 4; /* required parameter is invalid */ | ||
120 | } | ||
121 | } | 108 | } |
122 | gcry_sexp_release(list); | 109 | array[idx] = gcry_sexp_nth_mpi (l2, 1, GCRYMPI_FMT_USG); |
110 | gcry_sexp_release (l2); | ||
111 | if (! array[idx]) | ||
112 | { | ||
113 | for (unsigned int i = 0; i < idx; i++) | ||
114 | { | ||
115 | gcry_free (array[i]); | ||
116 | array[i] = NULL; | ||
117 | } | ||
118 | gcry_sexp_release (list); | ||
119 | return 4; /* required parameter is invalid */ | ||
120 | } | ||
121 | } | ||
122 | gcry_sexp_release (list); | ||
123 | return 0; | 123 | return 0; |
124 | } | 124 | } |
125 | 125 | ||
@@ -132,28 +132,28 @@ key_from_sexp(gcry_mpi_t *array, | |||
132 | * @return NULL on error | 132 | * @return NULL on error |
133 | */ | 133 | */ |
134 | static gcry_sexp_t | 134 | static gcry_sexp_t |
135 | decode_private_ecdsa_key(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv) | 135 | decode_private_ecdsa_key (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv) |
136 | { | 136 | { |
137 | gcry_sexp_t result; | 137 | gcry_sexp_t result; |
138 | int rc; | 138 | int rc; |
139 | 139 | ||
140 | rc = gcry_sexp_build(&result, | 140 | rc = gcry_sexp_build (&result, |
141 | NULL, | 141 | NULL, |
142 | "(private-key(ecc(curve \"" CURVE "\")" | 142 | "(private-key(ecc(curve \"" CURVE "\")" |
143 | "(d %b)))", | 143 | "(d %b)))", |
144 | (int)sizeof(priv->d), | 144 | (int) sizeof(priv->d), |
145 | priv->d); | 145 | priv->d); |
146 | if (0 != rc) | 146 | if (0 != rc) |
147 | { | 147 | { |
148 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); | 148 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); |
149 | GNUNET_assert(0); | 149 | GNUNET_assert (0); |
150 | } | 150 | } |
151 | #if EXTRA_CHECKS | 151 | #if EXTRA_CHECKS |
152 | if (0 != (rc = gcry_pk_testkey(result))) | 152 | if (0 != (rc = gcry_pk_testkey (result))) |
153 | { | 153 | { |
154 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_pk_testkey", rc); | 154 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_pk_testkey", rc); |
155 | GNUNET_assert(0); | 155 | GNUNET_assert (0); |
156 | } | 156 | } |
157 | #endif | 157 | #endif |
158 | return result; | 158 | return result; |
159 | } | 159 | } |
@@ -167,28 +167,28 @@ decode_private_ecdsa_key(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv) | |||
167 | * @return NULL on error | 167 | * @return NULL on error |
168 | */ | 168 | */ |
169 | static gcry_sexp_t | 169 | static gcry_sexp_t |
170 | decode_private_eddsa_key(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv) | 170 | decode_private_eddsa_key (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv) |
171 | { | 171 | { |
172 | gcry_sexp_t result; | 172 | gcry_sexp_t result; |
173 | int rc; | 173 | int rc; |
174 | 174 | ||
175 | rc = gcry_sexp_build(&result, | 175 | rc = gcry_sexp_build (&result, |
176 | NULL, | 176 | NULL, |
177 | "(private-key(ecc(curve \"" CURVE "\")" | 177 | "(private-key(ecc(curve \"" CURVE "\")" |
178 | "(flags eddsa)(d %b)))", | 178 | "(flags eddsa)(d %b)))", |
179 | (int)sizeof(priv->d), | 179 | (int) sizeof(priv->d), |
180 | priv->d); | 180 | priv->d); |
181 | if (0 != rc) | 181 | if (0 != rc) |
182 | { | 182 | { |
183 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); | 183 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); |
184 | GNUNET_assert(0); | 184 | GNUNET_assert (0); |
185 | } | 185 | } |
186 | #if EXTRA_CHECKS | 186 | #if EXTRA_CHECKS |
187 | if (0 != (rc = gcry_pk_testkey(result))) | 187 | if (0 != (rc = gcry_pk_testkey (result))) |
188 | { | 188 | { |
189 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_pk_testkey", rc); | 189 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_pk_testkey", rc); |
190 | GNUNET_assert(0); | 190 | GNUNET_assert (0); |
191 | } | 191 | } |
192 | #endif | 192 | #endif |
193 | return result; | 193 | return result; |
194 | } | 194 | } |
@@ -202,28 +202,28 @@ decode_private_eddsa_key(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv) | |||
202 | * @return NULL on error | 202 | * @return NULL on error |
203 | */ | 203 | */ |
204 | static gcry_sexp_t | 204 | static gcry_sexp_t |
205 | decode_private_ecdhe_key(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv) | 205 | decode_private_ecdhe_key (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv) |
206 | { | 206 | { |
207 | gcry_sexp_t result; | 207 | gcry_sexp_t result; |
208 | int rc; | 208 | int rc; |
209 | 209 | ||
210 | rc = gcry_sexp_build(&result, | 210 | rc = gcry_sexp_build (&result, |
211 | NULL, | 211 | NULL, |
212 | "(private-key(ecc(curve \"" CURVE "\")" | 212 | "(private-key(ecc(curve \"" CURVE "\")" |
213 | "(d %b)))", | 213 | "(d %b)))", |
214 | (int)sizeof(priv->d), | 214 | (int) sizeof(priv->d), |
215 | priv->d); | 215 | priv->d); |
216 | if (0 != rc) | 216 | if (0 != rc) |
217 | { | 217 | { |
218 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); | 218 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); |
219 | GNUNET_assert(0); | 219 | GNUNET_assert (0); |
220 | } | 220 | } |
221 | #if EXTRA_CHECKS | 221 | #if EXTRA_CHECKS |
222 | if (0 != (rc = gcry_pk_testkey(result))) | 222 | if (0 != (rc = gcry_pk_testkey (result))) |
223 | { | 223 | { |
224 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_pk_testkey", rc); | 224 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_pk_testkey", rc); |
225 | GNUNET_assert(0); | 225 | GNUNET_assert (0); |
226 | } | 226 | } |
227 | #endif | 227 | #endif |
228 | return result; | 228 | return result; |
229 | } | 229 | } |
@@ -236,7 +236,7 @@ decode_private_ecdhe_key(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv) | |||
236 | * @param pub where to write the public key | 236 | * @param pub where to write the public key |
237 | */ | 237 | */ |
238 | void | 238 | void |
239 | GNUNET_CRYPTO_ecdsa_key_get_public( | 239 | GNUNET_CRYPTO_ecdsa_key_get_public ( |
240 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 240 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
241 | struct GNUNET_CRYPTO_EcdsaPublicKey *pub) | 241 | struct GNUNET_CRYPTO_EcdsaPublicKey *pub) |
242 | { | 242 | { |
@@ -244,19 +244,19 @@ GNUNET_CRYPTO_ecdsa_key_get_public( | |||
244 | gcry_ctx_t ctx; | 244 | gcry_ctx_t ctx; |
245 | gcry_mpi_t q; | 245 | gcry_mpi_t q; |
246 | 246 | ||
247 | BENCHMARK_START(ecdsa_key_get_public); | 247 | BENCHMARK_START (ecdsa_key_get_public); |
248 | 248 | ||
249 | sexp = decode_private_ecdsa_key(priv); | 249 | sexp = decode_private_ecdsa_key (priv); |
250 | GNUNET_assert(NULL != sexp); | 250 | GNUNET_assert (NULL != sexp); |
251 | GNUNET_assert(0 == gcry_mpi_ec_new(&ctx, sexp, NULL)); | 251 | GNUNET_assert (0 == gcry_mpi_ec_new (&ctx, sexp, NULL)); |
252 | gcry_sexp_release(sexp); | 252 | gcry_sexp_release (sexp); |
253 | q = gcry_mpi_ec_get_mpi("q@eddsa", ctx, 0); | 253 | q = gcry_mpi_ec_get_mpi ("q@eddsa", ctx, 0); |
254 | GNUNET_assert(NULL != q); | 254 | GNUNET_assert (NULL != q); |
255 | GNUNET_CRYPTO_mpi_print_unsigned(pub->q_y, sizeof(pub->q_y), q); | 255 | GNUNET_CRYPTO_mpi_print_unsigned (pub->q_y, sizeof(pub->q_y), q); |
256 | gcry_mpi_release(q); | 256 | gcry_mpi_release (q); |
257 | gcry_ctx_release(ctx); | 257 | gcry_ctx_release (ctx); |
258 | 258 | ||
259 | BENCHMARK_END(ecdsa_key_get_public); | 259 | BENCHMARK_END (ecdsa_key_get_public); |
260 | } | 260 | } |
261 | 261 | ||
262 | 262 | ||
@@ -267,7 +267,7 @@ GNUNET_CRYPTO_ecdsa_key_get_public( | |||
267 | * @param pub where to write the public key | 267 | * @param pub where to write the public key |
268 | */ | 268 | */ |
269 | void | 269 | void |
270 | GNUNET_CRYPTO_eddsa_key_get_public( | 270 | GNUNET_CRYPTO_eddsa_key_get_public ( |
271 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | 271 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, |
272 | struct GNUNET_CRYPTO_EddsaPublicKey *pub) | 272 | struct GNUNET_CRYPTO_EddsaPublicKey *pub) |
273 | { | 273 | { |
@@ -275,19 +275,19 @@ GNUNET_CRYPTO_eddsa_key_get_public( | |||
275 | gcry_ctx_t ctx; | 275 | gcry_ctx_t ctx; |
276 | gcry_mpi_t q; | 276 | gcry_mpi_t q; |
277 | 277 | ||
278 | BENCHMARK_START(eddsa_key_get_public); | 278 | BENCHMARK_START (eddsa_key_get_public); |
279 | 279 | ||
280 | sexp = decode_private_eddsa_key(priv); | 280 | sexp = decode_private_eddsa_key (priv); |
281 | GNUNET_assert(NULL != sexp); | 281 | GNUNET_assert (NULL != sexp); |
282 | GNUNET_assert(0 == gcry_mpi_ec_new(&ctx, sexp, NULL)); | 282 | GNUNET_assert (0 == gcry_mpi_ec_new (&ctx, sexp, NULL)); |
283 | gcry_sexp_release(sexp); | 283 | gcry_sexp_release (sexp); |
284 | q = gcry_mpi_ec_get_mpi("q@eddsa", ctx, 0); | 284 | q = gcry_mpi_ec_get_mpi ("q@eddsa", ctx, 0); |
285 | GNUNET_assert(q); | 285 | GNUNET_assert (q); |
286 | GNUNET_CRYPTO_mpi_print_unsigned(pub->q_y, sizeof(pub->q_y), q); | 286 | GNUNET_CRYPTO_mpi_print_unsigned (pub->q_y, sizeof(pub->q_y), q); |
287 | gcry_mpi_release(q); | 287 | gcry_mpi_release (q); |
288 | gcry_ctx_release(ctx); | 288 | gcry_ctx_release (ctx); |
289 | 289 | ||
290 | BENCHMARK_END(eddsa_key_get_public); | 290 | BENCHMARK_END (eddsa_key_get_public); |
291 | } | 291 | } |
292 | 292 | ||
293 | 293 | ||
@@ -298,7 +298,7 @@ GNUNET_CRYPTO_eddsa_key_get_public( | |||
298 | * @param pub where to write the public key | 298 | * @param pub where to write the public key |
299 | */ | 299 | */ |
300 | void | 300 | void |
301 | GNUNET_CRYPTO_ecdhe_key_get_public( | 301 | GNUNET_CRYPTO_ecdhe_key_get_public ( |
302 | const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | 302 | const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, |
303 | struct GNUNET_CRYPTO_EcdhePublicKey *pub) | 303 | struct GNUNET_CRYPTO_EcdhePublicKey *pub) |
304 | { | 304 | { |
@@ -306,19 +306,19 @@ GNUNET_CRYPTO_ecdhe_key_get_public( | |||
306 | gcry_ctx_t ctx; | 306 | gcry_ctx_t ctx; |
307 | gcry_mpi_t q; | 307 | gcry_mpi_t q; |
308 | 308 | ||
309 | BENCHMARK_START(ecdhe_key_get_public); | 309 | BENCHMARK_START (ecdhe_key_get_public); |
310 | 310 | ||
311 | sexp = decode_private_ecdhe_key(priv); | 311 | sexp = decode_private_ecdhe_key (priv); |
312 | GNUNET_assert(NULL != sexp); | 312 | GNUNET_assert (NULL != sexp); |
313 | GNUNET_assert(0 == gcry_mpi_ec_new(&ctx, sexp, NULL)); | 313 | GNUNET_assert (0 == gcry_mpi_ec_new (&ctx, sexp, NULL)); |
314 | gcry_sexp_release(sexp); | 314 | gcry_sexp_release (sexp); |
315 | q = gcry_mpi_ec_get_mpi("q@eddsa", ctx, 0); | 315 | q = gcry_mpi_ec_get_mpi ("q@eddsa", ctx, 0); |
316 | GNUNET_assert(q); | 316 | GNUNET_assert (q); |
317 | GNUNET_CRYPTO_mpi_print_unsigned(pub->q_y, sizeof(pub->q_y), q); | 317 | GNUNET_CRYPTO_mpi_print_unsigned (pub->q_y, sizeof(pub->q_y), q); |
318 | gcry_mpi_release(q); | 318 | gcry_mpi_release (q); |
319 | gcry_ctx_release(ctx); | 319 | gcry_ctx_release (ctx); |
320 | 320 | ||
321 | BENCHMARK_END(ecdhe_key_get_public); | 321 | BENCHMARK_END (ecdhe_key_get_public); |
322 | } | 322 | } |
323 | 323 | ||
324 | 324 | ||
@@ -329,7 +329,7 @@ GNUNET_CRYPTO_ecdhe_key_get_public( | |||
329 | * @return string representing @a pub | 329 | * @return string representing @a pub |
330 | */ | 330 | */ |
331 | char * | 331 | char * |
332 | GNUNET_CRYPTO_ecdsa_public_key_to_string( | 332 | GNUNET_CRYPTO_ecdsa_public_key_to_string ( |
333 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub) | 333 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub) |
334 | { | 334 | { |
335 | char *pubkeybuf; | 335 | char *pubkeybuf; |
@@ -339,17 +339,17 @@ GNUNET_CRYPTO_ecdsa_public_key_to_string( | |||
339 | if (keylen % 5 > 0) | 339 | if (keylen % 5 > 0) |
340 | keylen += 5 - keylen % 5; | 340 | keylen += 5 - keylen % 5; |
341 | keylen /= 5; | 341 | keylen /= 5; |
342 | pubkeybuf = GNUNET_malloc(keylen + 1); | 342 | pubkeybuf = GNUNET_malloc (keylen + 1); |
343 | end = | 343 | end = |
344 | GNUNET_STRINGS_data_to_string((unsigned char *)pub, | 344 | GNUNET_STRINGS_data_to_string ((unsigned char *) pub, |
345 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey), | 345 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey), |
346 | pubkeybuf, | 346 | pubkeybuf, |
347 | keylen); | 347 | keylen); |
348 | if (NULL == end) | 348 | if (NULL == end) |
349 | { | 349 | { |
350 | GNUNET_free(pubkeybuf); | 350 | GNUNET_free (pubkeybuf); |
351 | return NULL; | 351 | return NULL; |
352 | } | 352 | } |
353 | *end = '\0'; | 353 | *end = '\0'; |
354 | return pubkeybuf; | 354 | return pubkeybuf; |
355 | } | 355 | } |
@@ -362,7 +362,7 @@ GNUNET_CRYPTO_ecdsa_public_key_to_string( | |||
362 | * @return string representing @a pub | 362 | * @return string representing @a pub |
363 | */ | 363 | */ |
364 | char * | 364 | char * |
365 | GNUNET_CRYPTO_eddsa_public_key_to_string( | 365 | GNUNET_CRYPTO_eddsa_public_key_to_string ( |
366 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub) | 366 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub) |
367 | { | 367 | { |
368 | char *pubkeybuf; | 368 | char *pubkeybuf; |
@@ -372,17 +372,17 @@ GNUNET_CRYPTO_eddsa_public_key_to_string( | |||
372 | if (keylen % 5 > 0) | 372 | if (keylen % 5 > 0) |
373 | keylen += 5 - keylen % 5; | 373 | keylen += 5 - keylen % 5; |
374 | keylen /= 5; | 374 | keylen /= 5; |
375 | pubkeybuf = GNUNET_malloc(keylen + 1); | 375 | pubkeybuf = GNUNET_malloc (keylen + 1); |
376 | end = | 376 | end = |
377 | GNUNET_STRINGS_data_to_string((unsigned char *)pub, | 377 | GNUNET_STRINGS_data_to_string ((unsigned char *) pub, |
378 | sizeof(struct GNUNET_CRYPTO_EddsaPublicKey), | 378 | sizeof(struct GNUNET_CRYPTO_EddsaPublicKey), |
379 | pubkeybuf, | 379 | pubkeybuf, |
380 | keylen); | 380 | keylen); |
381 | if (NULL == end) | 381 | if (NULL == end) |
382 | { | 382 | { |
383 | GNUNET_free(pubkeybuf); | 383 | GNUNET_free (pubkeybuf); |
384 | return NULL; | 384 | return NULL; |
385 | } | 385 | } |
386 | *end = '\0'; | 386 | *end = '\0'; |
387 | return pubkeybuf; | 387 | return pubkeybuf; |
388 | } | 388 | } |
@@ -395,7 +395,7 @@ GNUNET_CRYPTO_eddsa_public_key_to_string( | |||
395 | * @return string representing @a pub | 395 | * @return string representing @a pub |
396 | */ | 396 | */ |
397 | char * | 397 | char * |
398 | GNUNET_CRYPTO_eddsa_private_key_to_string( | 398 | GNUNET_CRYPTO_eddsa_private_key_to_string ( |
399 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv) | 399 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv) |
400 | { | 400 | { |
401 | char *privkeybuf; | 401 | char *privkeybuf; |
@@ -405,17 +405,17 @@ GNUNET_CRYPTO_eddsa_private_key_to_string( | |||
405 | if (keylen % 5 > 0) | 405 | if (keylen % 5 > 0) |
406 | keylen += 5 - keylen % 5; | 406 | keylen += 5 - keylen % 5; |
407 | keylen /= 5; | 407 | keylen /= 5; |
408 | privkeybuf = GNUNET_malloc(keylen + 1); | 408 | privkeybuf = GNUNET_malloc (keylen + 1); |
409 | end = GNUNET_STRINGS_data_to_string((unsigned char *)priv, | 409 | end = GNUNET_STRINGS_data_to_string ((unsigned char *) priv, |
410 | sizeof( | 410 | sizeof( |
411 | struct GNUNET_CRYPTO_EddsaPrivateKey), | 411 | struct GNUNET_CRYPTO_EddsaPrivateKey), |
412 | privkeybuf, | 412 | privkeybuf, |
413 | keylen); | 413 | keylen); |
414 | if (NULL == end) | 414 | if (NULL == end) |
415 | { | 415 | { |
416 | GNUNET_free(privkeybuf); | 416 | GNUNET_free (privkeybuf); |
417 | return NULL; | 417 | return NULL; |
418 | } | 418 | } |
419 | *end = '\0'; | 419 | *end = '\0'; |
420 | return privkeybuf; | 420 | return privkeybuf; |
421 | } | 421 | } |
@@ -428,7 +428,7 @@ GNUNET_CRYPTO_eddsa_private_key_to_string( | |||
428 | * @return string representing @a priv | 428 | * @return string representing @a priv |
429 | */ | 429 | */ |
430 | char * | 430 | char * |
431 | GNUNET_CRYPTO_ecdsa_private_key_to_string( | 431 | GNUNET_CRYPTO_ecdsa_private_key_to_string ( |
432 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv) | 432 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv) |
433 | { | 433 | { |
434 | char *privkeybuf; | 434 | char *privkeybuf; |
@@ -438,17 +438,17 @@ GNUNET_CRYPTO_ecdsa_private_key_to_string( | |||
438 | if (keylen % 5 > 0) | 438 | if (keylen % 5 > 0) |
439 | keylen += 5 - keylen % 5; | 439 | keylen += 5 - keylen % 5; |
440 | keylen /= 5; | 440 | keylen /= 5; |
441 | privkeybuf = GNUNET_malloc(keylen + 1); | 441 | privkeybuf = GNUNET_malloc (keylen + 1); |
442 | end = GNUNET_STRINGS_data_to_string((unsigned char *)priv, | 442 | end = GNUNET_STRINGS_data_to_string ((unsigned char *) priv, |
443 | sizeof( | 443 | sizeof( |
444 | struct GNUNET_CRYPTO_EcdsaPrivateKey), | 444 | struct GNUNET_CRYPTO_EcdsaPrivateKey), |
445 | privkeybuf, | 445 | privkeybuf, |
446 | keylen); | 446 | keylen); |
447 | if (NULL == end) | 447 | if (NULL == end) |
448 | { | 448 | { |
449 | GNUNET_free(privkeybuf); | 449 | GNUNET_free (privkeybuf); |
450 | return NULL; | 450 | return NULL; |
451 | } | 451 | } |
452 | *end = '\0'; | 452 | *end = '\0'; |
453 | return privkeybuf; | 453 | return privkeybuf; |
454 | } | 454 | } |
@@ -463,7 +463,7 @@ GNUNET_CRYPTO_ecdsa_private_key_to_string( | |||
463 | * @return #GNUNET_OK on success | 463 | * @return #GNUNET_OK on success |
464 | */ | 464 | */ |
465 | int | 465 | int |
466 | GNUNET_CRYPTO_ecdsa_public_key_from_string( | 466 | GNUNET_CRYPTO_ecdsa_public_key_from_string ( |
467 | const char *enc, | 467 | const char *enc, |
468 | size_t enclen, | 468 | size_t enclen, |
469 | struct GNUNET_CRYPTO_EcdsaPublicKey *pub) | 469 | struct GNUNET_CRYPTO_EcdsaPublicKey *pub) |
@@ -477,11 +477,11 @@ GNUNET_CRYPTO_ecdsa_public_key_from_string( | |||
477 | return GNUNET_SYSERR; | 477 | return GNUNET_SYSERR; |
478 | 478 | ||
479 | if (GNUNET_OK != | 479 | if (GNUNET_OK != |
480 | GNUNET_STRINGS_string_to_data(enc, | 480 | GNUNET_STRINGS_string_to_data (enc, |
481 | enclen, | 481 | enclen, |
482 | pub, | 482 | pub, |
483 | sizeof( | 483 | sizeof( |
484 | struct GNUNET_CRYPTO_EcdsaPublicKey))) | 484 | struct GNUNET_CRYPTO_EcdsaPublicKey))) |
485 | return GNUNET_SYSERR; | 485 | return GNUNET_SYSERR; |
486 | return GNUNET_OK; | 486 | return GNUNET_OK; |
487 | } | 487 | } |
@@ -496,7 +496,7 @@ GNUNET_CRYPTO_ecdsa_public_key_from_string( | |||
496 | * @return #GNUNET_OK on success | 496 | * @return #GNUNET_OK on success |
497 | */ | 497 | */ |
498 | int | 498 | int |
499 | GNUNET_CRYPTO_eddsa_public_key_from_string( | 499 | GNUNET_CRYPTO_eddsa_public_key_from_string ( |
500 | const char *enc, | 500 | const char *enc, |
501 | size_t enclen, | 501 | size_t enclen, |
502 | struct GNUNET_CRYPTO_EddsaPublicKey *pub) | 502 | struct GNUNET_CRYPTO_EddsaPublicKey *pub) |
@@ -510,11 +510,11 @@ GNUNET_CRYPTO_eddsa_public_key_from_string( | |||
510 | return GNUNET_SYSERR; | 510 | return GNUNET_SYSERR; |
511 | 511 | ||
512 | if (GNUNET_OK != | 512 | if (GNUNET_OK != |
513 | GNUNET_STRINGS_string_to_data(enc, | 513 | GNUNET_STRINGS_string_to_data (enc, |
514 | enclen, | 514 | enclen, |
515 | pub, | 515 | pub, |
516 | sizeof( | 516 | sizeof( |
517 | struct GNUNET_CRYPTO_EddsaPublicKey))) | 517 | struct GNUNET_CRYPTO_EddsaPublicKey))) |
518 | return GNUNET_SYSERR; | 518 | return GNUNET_SYSERR; |
519 | return GNUNET_OK; | 519 | return GNUNET_OK; |
520 | } | 520 | } |
@@ -529,7 +529,7 @@ GNUNET_CRYPTO_eddsa_public_key_from_string( | |||
529 | * @return #GNUNET_OK on success | 529 | * @return #GNUNET_OK on success |
530 | */ | 530 | */ |
531 | int | 531 | int |
532 | GNUNET_CRYPTO_eddsa_private_key_from_string( | 532 | GNUNET_CRYPTO_eddsa_private_key_from_string ( |
533 | const char *enc, | 533 | const char *enc, |
534 | size_t enclen, | 534 | size_t enclen, |
535 | struct GNUNET_CRYPTO_EddsaPrivateKey *priv) | 535 | struct GNUNET_CRYPTO_EddsaPrivateKey *priv) |
@@ -543,18 +543,18 @@ GNUNET_CRYPTO_eddsa_private_key_from_string( | |||
543 | return GNUNET_SYSERR; | 543 | return GNUNET_SYSERR; |
544 | 544 | ||
545 | if (GNUNET_OK != | 545 | if (GNUNET_OK != |
546 | GNUNET_STRINGS_string_to_data(enc, | 546 | GNUNET_STRINGS_string_to_data (enc, |
547 | enclen, | 547 | enclen, |
548 | priv, | 548 | priv, |
549 | sizeof( | 549 | sizeof( |
550 | struct GNUNET_CRYPTO_EddsaPrivateKey))) | 550 | struct GNUNET_CRYPTO_EddsaPrivateKey))) |
551 | return GNUNET_SYSERR; | 551 | return GNUNET_SYSERR; |
552 | #if CRYPTO_BUG | 552 | #if CRYPTO_BUG |
553 | if (GNUNET_OK != check_eddsa_key(priv)) | 553 | if (GNUNET_OK != check_eddsa_key (priv)) |
554 | { | 554 | { |
555 | GNUNET_break(0); | 555 | GNUNET_break (0); |
556 | return GNUNET_OK; | 556 | return GNUNET_OK; |
557 | } | 557 | } |
558 | #endif | 558 | #endif |
559 | return GNUNET_OK; | 559 | return GNUNET_OK; |
560 | } | 560 | } |
@@ -567,9 +567,9 @@ GNUNET_CRYPTO_eddsa_private_key_from_string( | |||
567 | * @param pk location of the key | 567 | * @param pk location of the key |
568 | */ | 568 | */ |
569 | void | 569 | void |
570 | GNUNET_CRYPTO_ecdhe_key_clear(struct GNUNET_CRYPTO_EcdhePrivateKey *pk) | 570 | GNUNET_CRYPTO_ecdhe_key_clear (struct GNUNET_CRYPTO_EcdhePrivateKey *pk) |
571 | { | 571 | { |
572 | memset(pk, 0, sizeof(struct GNUNET_CRYPTO_EcdhePrivateKey)); | 572 | memset (pk, 0, sizeof(struct GNUNET_CRYPTO_EcdhePrivateKey)); |
573 | } | 573 | } |
574 | 574 | ||
575 | 575 | ||
@@ -580,9 +580,9 @@ GNUNET_CRYPTO_ecdhe_key_clear(struct GNUNET_CRYPTO_EcdhePrivateKey *pk) | |||
580 | * @param pk location of the key | 580 | * @param pk location of the key |
581 | */ | 581 | */ |
582 | void | 582 | void |
583 | GNUNET_CRYPTO_ecdsa_key_clear(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk) | 583 | GNUNET_CRYPTO_ecdsa_key_clear (struct GNUNET_CRYPTO_EcdsaPrivateKey *pk) |
584 | { | 584 | { |
585 | memset(pk, 0, sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey)); | 585 | memset (pk, 0, sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey)); |
586 | } | 586 | } |
587 | 587 | ||
588 | 588 | ||
@@ -593,9 +593,9 @@ GNUNET_CRYPTO_ecdsa_key_clear(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk) | |||
593 | * @param pk location of the key | 593 | * @param pk location of the key |
594 | */ | 594 | */ |
595 | void | 595 | void |
596 | GNUNET_CRYPTO_eddsa_key_clear(struct GNUNET_CRYPTO_EddsaPrivateKey *pk) | 596 | GNUNET_CRYPTO_eddsa_key_clear (struct GNUNET_CRYPTO_EddsaPrivateKey *pk) |
597 | { | 597 | { |
598 | memset(pk, 0, sizeof(struct GNUNET_CRYPTO_EddsaPrivateKey)); | 598 | memset (pk, 0, sizeof(struct GNUNET_CRYPTO_EddsaPrivateKey)); |
599 | } | 599 | } |
600 | 600 | ||
601 | 601 | ||
@@ -605,16 +605,16 @@ GNUNET_CRYPTO_eddsa_key_clear(struct GNUNET_CRYPTO_EddsaPrivateKey *pk) | |||
605 | * @return fresh private key | 605 | * @return fresh private key |
606 | */ | 606 | */ |
607 | struct GNUNET_CRYPTO_EcdhePrivateKey * | 607 | struct GNUNET_CRYPTO_EcdhePrivateKey * |
608 | GNUNET_CRYPTO_ecdhe_key_create() | 608 | GNUNET_CRYPTO_ecdhe_key_create () |
609 | { | 609 | { |
610 | struct GNUNET_CRYPTO_EcdhePrivateKey *priv; | 610 | struct GNUNET_CRYPTO_EcdhePrivateKey *priv; |
611 | 611 | ||
612 | priv = GNUNET_new(struct GNUNET_CRYPTO_EcdhePrivateKey); | 612 | priv = GNUNET_new (struct GNUNET_CRYPTO_EcdhePrivateKey); |
613 | if (GNUNET_OK != GNUNET_CRYPTO_ecdhe_key_create2(priv)) | 613 | if (GNUNET_OK != GNUNET_CRYPTO_ecdhe_key_create2 (priv)) |
614 | { | 614 | { |
615 | GNUNET_free(priv); | 615 | GNUNET_free (priv); |
616 | return NULL; | 616 | return NULL; |
617 | } | 617 | } |
618 | return priv; | 618 | return priv; |
619 | } | 619 | } |
620 | 620 | ||
@@ -627,54 +627,54 @@ GNUNET_CRYPTO_ecdhe_key_create() | |||
627 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | 627 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
628 | */ | 628 | */ |
629 | int | 629 | int |
630 | GNUNET_CRYPTO_ecdhe_key_create2(struct GNUNET_CRYPTO_EcdhePrivateKey *pk) | 630 | GNUNET_CRYPTO_ecdhe_key_create2 (struct GNUNET_CRYPTO_EcdhePrivateKey *pk) |
631 | { | 631 | { |
632 | gcry_sexp_t priv_sexp; | 632 | gcry_sexp_t priv_sexp; |
633 | gcry_sexp_t s_keyparam; | 633 | gcry_sexp_t s_keyparam; |
634 | gcry_mpi_t d; | 634 | gcry_mpi_t d; |
635 | int rc; | 635 | int rc; |
636 | 636 | ||
637 | BENCHMARK_START(ecdhe_key_create); | 637 | BENCHMARK_START (ecdhe_key_create); |
638 | 638 | ||
639 | /* NOTE: For libgcrypt >= 1.7, we do not need the 'eddsa' flag here, | 639 | /* NOTE: For libgcrypt >= 1.7, we do not need the 'eddsa' flag here, |
640 | but should also be harmless. For libgcrypt < 1.7, using 'eddsa' | 640 | but should also be harmless. For libgcrypt < 1.7, using 'eddsa' |
641 | disables an expensive key testing routine. We do not want to run | 641 | disables an expensive key testing routine. We do not want to run |
642 | the expensive check for ECDHE, as we generate TONS of keys to | 642 | the expensive check for ECDHE, as we generate TONS of keys to |
643 | use for a very short time. */ | 643 | use for a very short time. */ |
644 | if (0 != (rc = gcry_sexp_build(&s_keyparam, | 644 | if (0 != (rc = gcry_sexp_build (&s_keyparam, |
645 | NULL, | 645 | NULL, |
646 | "(genkey(ecc(curve \"" CURVE "\")" | 646 | "(genkey(ecc(curve \"" CURVE "\")" |
647 | "(flags eddsa no-keytest)))"))) | 647 | "(flags eddsa no-keytest)))"))) |
648 | { | 648 | { |
649 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); | 649 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); |
650 | return GNUNET_SYSERR; | 650 | return GNUNET_SYSERR; |
651 | } | 651 | } |
652 | if (0 != (rc = gcry_pk_genkey(&priv_sexp, s_keyparam))) | 652 | if (0 != (rc = gcry_pk_genkey (&priv_sexp, s_keyparam))) |
653 | { | 653 | { |
654 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_pk_genkey", rc); | 654 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_pk_genkey", rc); |
655 | gcry_sexp_release(s_keyparam); | 655 | gcry_sexp_release (s_keyparam); |
656 | return GNUNET_SYSERR; | 656 | return GNUNET_SYSERR; |
657 | } | 657 | } |
658 | gcry_sexp_release(s_keyparam); | 658 | gcry_sexp_release (s_keyparam); |
659 | #if EXTRA_CHECKS | 659 | #if EXTRA_CHECKS |
660 | if (0 != (rc = gcry_pk_testkey(priv_sexp))) | 660 | if (0 != (rc = gcry_pk_testkey (priv_sexp))) |
661 | { | 661 | { |
662 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_pk_testkey", rc); | 662 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_pk_testkey", rc); |
663 | gcry_sexp_release(priv_sexp); | 663 | gcry_sexp_release (priv_sexp); |
664 | return GNUNET_SYSERR; | 664 | return GNUNET_SYSERR; |
665 | } | 665 | } |
666 | #endif | 666 | #endif |
667 | if (0 != (rc = key_from_sexp(&d, priv_sexp, "private-key", "d"))) | 667 | if (0 != (rc = key_from_sexp (&d, priv_sexp, "private-key", "d"))) |
668 | { | 668 | { |
669 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "key_from_sexp", rc); | 669 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "key_from_sexp", rc); |
670 | gcry_sexp_release(priv_sexp); | 670 | gcry_sexp_release (priv_sexp); |
671 | return GNUNET_SYSERR; | 671 | return GNUNET_SYSERR; |
672 | } | 672 | } |
673 | gcry_sexp_release(priv_sexp); | 673 | gcry_sexp_release (priv_sexp); |
674 | GNUNET_CRYPTO_mpi_print_unsigned(pk->d, sizeof(pk->d), d); | 674 | GNUNET_CRYPTO_mpi_print_unsigned (pk->d, sizeof(pk->d), d); |
675 | gcry_mpi_release(d); | 675 | gcry_mpi_release (d); |
676 | 676 | ||
677 | BENCHMARK_END(ecdhe_key_create); | 677 | BENCHMARK_END (ecdhe_key_create); |
678 | 678 | ||
679 | return GNUNET_OK; | 679 | return GNUNET_OK; |
680 | } | 680 | } |
@@ -686,7 +686,7 @@ GNUNET_CRYPTO_ecdhe_key_create2(struct GNUNET_CRYPTO_EcdhePrivateKey *pk) | |||
686 | * @return fresh private key | 686 | * @return fresh private key |
687 | */ | 687 | */ |
688 | struct GNUNET_CRYPTO_EcdsaPrivateKey * | 688 | struct GNUNET_CRYPTO_EcdsaPrivateKey * |
689 | GNUNET_CRYPTO_ecdsa_key_create() | 689 | GNUNET_CRYPTO_ecdsa_key_create () |
690 | { | 690 | { |
691 | struct GNUNET_CRYPTO_EcdsaPrivateKey *priv; | 691 | struct GNUNET_CRYPTO_EcdsaPrivateKey *priv; |
692 | gcry_sexp_t priv_sexp; | 692 | gcry_sexp_t priv_sexp; |
@@ -694,43 +694,43 @@ GNUNET_CRYPTO_ecdsa_key_create() | |||
694 | gcry_mpi_t d; | 694 | gcry_mpi_t d; |
695 | int rc; | 695 | int rc; |
696 | 696 | ||
697 | BENCHMARK_START(ecdsa_key_create); | 697 | BENCHMARK_START (ecdsa_key_create); |
698 | 698 | ||
699 | if (0 != (rc = gcry_sexp_build(&s_keyparam, | 699 | if (0 != (rc = gcry_sexp_build (&s_keyparam, |
700 | NULL, | 700 | NULL, |
701 | "(genkey(ecc(curve \"" CURVE "\")" | 701 | "(genkey(ecc(curve \"" CURVE "\")" |
702 | "(flags)))"))) | 702 | "(flags)))"))) |
703 | { | 703 | { |
704 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); | 704 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); |
705 | return NULL; | 705 | return NULL; |
706 | } | 706 | } |
707 | if (0 != (rc = gcry_pk_genkey(&priv_sexp, s_keyparam))) | 707 | if (0 != (rc = gcry_pk_genkey (&priv_sexp, s_keyparam))) |
708 | { | 708 | { |
709 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_pk_genkey", rc); | 709 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_pk_genkey", rc); |
710 | gcry_sexp_release(s_keyparam); | 710 | gcry_sexp_release (s_keyparam); |
711 | return NULL; | 711 | return NULL; |
712 | } | 712 | } |
713 | gcry_sexp_release(s_keyparam); | 713 | gcry_sexp_release (s_keyparam); |
714 | #if EXTRA_CHECKS | 714 | #if EXTRA_CHECKS |
715 | if (0 != (rc = gcry_pk_testkey(priv_sexp))) | 715 | if (0 != (rc = gcry_pk_testkey (priv_sexp))) |
716 | { | 716 | { |
717 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_pk_testkey", rc); | 717 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_pk_testkey", rc); |
718 | gcry_sexp_release(priv_sexp); | 718 | gcry_sexp_release (priv_sexp); |
719 | return NULL; | 719 | return NULL; |
720 | } | 720 | } |
721 | #endif | 721 | #endif |
722 | if (0 != (rc = key_from_sexp(&d, priv_sexp, "private-key", "d"))) | 722 | if (0 != (rc = key_from_sexp (&d, priv_sexp, "private-key", "d"))) |
723 | { | 723 | { |
724 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "key_from_sexp", rc); | 724 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "key_from_sexp", rc); |
725 | gcry_sexp_release(priv_sexp); | 725 | gcry_sexp_release (priv_sexp); |
726 | return NULL; | 726 | return NULL; |
727 | } | 727 | } |
728 | gcry_sexp_release(priv_sexp); | 728 | gcry_sexp_release (priv_sexp); |
729 | priv = GNUNET_new(struct GNUNET_CRYPTO_EcdsaPrivateKey); | 729 | priv = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPrivateKey); |
730 | GNUNET_CRYPTO_mpi_print_unsigned(priv->d, sizeof(priv->d), d); | 730 | GNUNET_CRYPTO_mpi_print_unsigned (priv->d, sizeof(priv->d), d); |
731 | gcry_mpi_release(d); | 731 | gcry_mpi_release (d); |
732 | 732 | ||
733 | BENCHMARK_END(ecdsa_key_create); | 733 | BENCHMARK_END (ecdsa_key_create); |
734 | 734 | ||
735 | return priv; | 735 | return priv; |
736 | } | 736 | } |
@@ -741,7 +741,7 @@ GNUNET_CRYPTO_ecdsa_key_create() | |||
741 | * @return fresh private key | 741 | * @return fresh private key |
742 | */ | 742 | */ |
743 | struct GNUNET_CRYPTO_EddsaPrivateKey * | 743 | struct GNUNET_CRYPTO_EddsaPrivateKey * |
744 | GNUNET_CRYPTO_eddsa_key_create() | 744 | GNUNET_CRYPTO_eddsa_key_create () |
745 | { | 745 | { |
746 | struct GNUNET_CRYPTO_EddsaPrivateKey *priv; | 746 | struct GNUNET_CRYPTO_EddsaPrivateKey *priv; |
747 | gcry_sexp_t priv_sexp; | 747 | gcry_sexp_t priv_sexp; |
@@ -749,55 +749,55 @@ GNUNET_CRYPTO_eddsa_key_create() | |||
749 | gcry_mpi_t d; | 749 | gcry_mpi_t d; |
750 | int rc; | 750 | int rc; |
751 | 751 | ||
752 | BENCHMARK_START(eddsa_key_create); | 752 | BENCHMARK_START (eddsa_key_create); |
753 | 753 | ||
754 | #if CRYPTO_BUG | 754 | #if CRYPTO_BUG |
755 | again: | 755 | again: |
756 | #endif | 756 | #endif |
757 | if (0 != (rc = gcry_sexp_build(&s_keyparam, | 757 | if (0 != (rc = gcry_sexp_build (&s_keyparam, |
758 | NULL, | 758 | NULL, |
759 | "(genkey(ecc(curve \"" CURVE "\")" | 759 | "(genkey(ecc(curve \"" CURVE "\")" |
760 | "(flags eddsa)))"))) | 760 | "(flags eddsa)))"))) |
761 | { | 761 | { |
762 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); | 762 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); |
763 | return NULL; | 763 | return NULL; |
764 | } | 764 | } |
765 | if (0 != (rc = gcry_pk_genkey(&priv_sexp, s_keyparam))) | 765 | if (0 != (rc = gcry_pk_genkey (&priv_sexp, s_keyparam))) |
766 | { | 766 | { |
767 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_pk_genkey", rc); | 767 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_pk_genkey", rc); |
768 | gcry_sexp_release(s_keyparam); | 768 | gcry_sexp_release (s_keyparam); |
769 | return NULL; | 769 | return NULL; |
770 | } | 770 | } |
771 | gcry_sexp_release(s_keyparam); | 771 | gcry_sexp_release (s_keyparam); |
772 | #if EXTRA_CHECKS | 772 | #if EXTRA_CHECKS |
773 | if (0 != (rc = gcry_pk_testkey(priv_sexp))) | 773 | if (0 != (rc = gcry_pk_testkey (priv_sexp))) |
774 | { | 774 | { |
775 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_pk_testkey", rc); | 775 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_pk_testkey", rc); |
776 | gcry_sexp_release(priv_sexp); | 776 | gcry_sexp_release (priv_sexp); |
777 | return NULL; | 777 | return NULL; |
778 | } | 778 | } |
779 | #endif | 779 | #endif |
780 | if (0 != (rc = key_from_sexp(&d, priv_sexp, "private-key", "d"))) | 780 | if (0 != (rc = key_from_sexp (&d, priv_sexp, "private-key", "d"))) |
781 | { | 781 | { |
782 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "key_from_sexp", rc); | 782 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "key_from_sexp", rc); |
783 | gcry_sexp_release(priv_sexp); | 783 | gcry_sexp_release (priv_sexp); |
784 | return NULL; | 784 | return NULL; |
785 | } | 785 | } |
786 | gcry_sexp_release(priv_sexp); | 786 | gcry_sexp_release (priv_sexp); |
787 | priv = GNUNET_new(struct GNUNET_CRYPTO_EddsaPrivateKey); | 787 | priv = GNUNET_new (struct GNUNET_CRYPTO_EddsaPrivateKey); |
788 | GNUNET_CRYPTO_mpi_print_unsigned(priv->d, sizeof(priv->d), d); | 788 | GNUNET_CRYPTO_mpi_print_unsigned (priv->d, sizeof(priv->d), d); |
789 | gcry_mpi_release(d); | 789 | gcry_mpi_release (d); |
790 | 790 | ||
791 | #if CRYPTO_BUG | 791 | #if CRYPTO_BUG |
792 | if (GNUNET_OK != check_eddsa_key(priv)) | 792 | if (GNUNET_OK != check_eddsa_key (priv)) |
793 | { | 793 | { |
794 | GNUNET_break(0); | 794 | GNUNET_break (0); |
795 | GNUNET_free(priv); | 795 | GNUNET_free (priv); |
796 | goto again; | 796 | goto again; |
797 | } | 797 | } |
798 | #endif | 798 | #endif |
799 | 799 | ||
800 | BENCHMARK_END(eddsa_key_create); | 800 | BENCHMARK_END (eddsa_key_create); |
801 | 801 | ||
802 | return priv; | 802 | return priv; |
803 | } | 803 | } |
@@ -809,7 +809,7 @@ again: | |||
809 | * @return "anonymous" private key | 809 | * @return "anonymous" private key |
810 | */ | 810 | */ |
811 | const struct GNUNET_CRYPTO_EcdsaPrivateKey * | 811 | const struct GNUNET_CRYPTO_EcdsaPrivateKey * |
812 | GNUNET_CRYPTO_ecdsa_key_get_anonymous() | 812 | GNUNET_CRYPTO_ecdsa_key_get_anonymous () |
813 | { | 813 | { |
814 | /** | 814 | /** |
815 | * 'anonymous' pseudonym (global static, d=1, public key = G | 815 | * 'anonymous' pseudonym (global static, d=1, public key = G |
@@ -820,9 +820,9 @@ GNUNET_CRYPTO_ecdsa_key_get_anonymous() | |||
820 | 820 | ||
821 | if (once) | 821 | if (once) |
822 | return &anonymous; | 822 | return &anonymous; |
823 | GNUNET_CRYPTO_mpi_print_unsigned(anonymous.d, | 823 | GNUNET_CRYPTO_mpi_print_unsigned (anonymous.d, |
824 | sizeof(anonymous.d), | 824 | sizeof(anonymous.d), |
825 | GCRYMPI_CONST_ONE); | 825 | GCRYMPI_CONST_ONE); |
826 | once = 1; | 826 | once = 1; |
827 | return &anonymous; | 827 | return &anonymous; |
828 | } | 828 | } |
@@ -836,7 +836,7 @@ GNUNET_CRYPTO_ecdsa_key_get_anonymous() | |||
836 | * @return converted s-expression | 836 | * @return converted s-expression |
837 | */ | 837 | */ |
838 | static gcry_sexp_t | 838 | static gcry_sexp_t |
839 | data_to_eddsa_value(const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose) | 839 | data_to_eddsa_value (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose) |
840 | { | 840 | { |
841 | gcry_sexp_t data; | 841 | gcry_sexp_t data; |
842 | int rc; | 842 | int rc; |
@@ -845,29 +845,29 @@ data_to_eddsa_value(const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose) | |||
845 | #if 1 | 845 | #if 1 |
846 | struct GNUNET_HashCode hc; | 846 | struct GNUNET_HashCode hc; |
847 | 847 | ||
848 | GNUNET_CRYPTO_hash(purpose, ntohl(purpose->size), &hc); | 848 | GNUNET_CRYPTO_hash (purpose, ntohl (purpose->size), &hc); |
849 | if (0 != (rc = gcry_sexp_build(&data, | 849 | if (0 != (rc = gcry_sexp_build (&data, |
850 | NULL, | 850 | NULL, |
851 | "(data(flags eddsa)(hash-algo %s)(value %b))", | 851 | "(data(flags eddsa)(hash-algo %s)(value %b))", |
852 | "sha512", | 852 | "sha512", |
853 | (int)sizeof(hc), | 853 | (int) sizeof(hc), |
854 | &hc))) | 854 | &hc))) |
855 | { | 855 | { |
856 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); | 856 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); |
857 | return NULL; | 857 | return NULL; |
858 | } | 858 | } |
859 | #else | 859 | #else |
860 | GNUNET_CRYPTO_hash(purpose, ntohl(purpose->size), &hc); | 860 | GNUNET_CRYPTO_hash (purpose, ntohl (purpose->size), &hc); |
861 | if (0 != (rc = gcry_sexp_build(&data, | 861 | if (0 != (rc = gcry_sexp_build (&data, |
862 | NULL, | 862 | NULL, |
863 | "(data(flags eddsa)(hash-algo %s)(value %b))", | 863 | "(data(flags eddsa)(hash-algo %s)(value %b))", |
864 | "sha512", | 864 | "sha512", |
865 | ntohl(purpose->size), | 865 | ntohl (purpose->size), |
866 | purpose))) | 866 | purpose))) |
867 | { | 867 | { |
868 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); | 868 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); |
869 | return NULL; | 869 | return NULL; |
870 | } | 870 | } |
871 | #endif | 871 | #endif |
872 | return data; | 872 | return data; |
873 | } | 873 | } |
@@ -881,7 +881,7 @@ data_to_eddsa_value(const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose) | |||
881 | * @return converted s-expression | 881 | * @return converted s-expression |
882 | */ | 882 | */ |
883 | static gcry_sexp_t | 883 | static gcry_sexp_t |
884 | data_to_ecdsa_value(const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose) | 884 | data_to_ecdsa_value (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose) |
885 | { | 885 | { |
886 | gcry_sexp_t data; | 886 | gcry_sexp_t data; |
887 | int rc; | 887 | int rc; |
@@ -890,28 +890,28 @@ data_to_ecdsa_value(const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose) | |||
890 | #if 1 | 890 | #if 1 |
891 | struct GNUNET_HashCode hc; | 891 | struct GNUNET_HashCode hc; |
892 | 892 | ||
893 | GNUNET_CRYPTO_hash(purpose, ntohl(purpose->size), &hc); | 893 | GNUNET_CRYPTO_hash (purpose, ntohl (purpose->size), &hc); |
894 | if (0 != (rc = gcry_sexp_build(&data, | 894 | if (0 != (rc = gcry_sexp_build (&data, |
895 | NULL, | 895 | NULL, |
896 | "(data(flags rfc6979)(hash %s %b))", | 896 | "(data(flags rfc6979)(hash %s %b))", |
897 | "sha512", | 897 | "sha512", |
898 | (int)sizeof(hc), | 898 | (int) sizeof(hc), |
899 | &hc))) | 899 | &hc))) |
900 | { | 900 | { |
901 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); | 901 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); |
902 | return NULL; | 902 | return NULL; |
903 | } | 903 | } |
904 | #else | 904 | #else |
905 | if (0 != (rc = gcry_sexp_build(&data, | 905 | if (0 != (rc = gcry_sexp_build (&data, |
906 | NULL, | 906 | NULL, |
907 | "(data(flags rfc6979)(hash %s %b))", | 907 | "(data(flags rfc6979)(hash %s %b))", |
908 | "sha512", | 908 | "sha512", |
909 | ntohl(purpose->size), | 909 | ntohl (purpose->size), |
910 | purpose))) | 910 | purpose))) |
911 | { | 911 | { |
912 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); | 912 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); |
913 | return NULL; | 913 | return NULL; |
914 | } | 914 | } |
915 | #endif | 915 | #endif |
916 | return data; | 916 | return data; |
917 | } | 917 | } |
@@ -926,7 +926,7 @@ data_to_ecdsa_value(const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose) | |||
926 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 926 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
927 | */ | 927 | */ |
928 | int | 928 | int |
929 | GNUNET_CRYPTO_ecdsa_sign( | 929 | GNUNET_CRYPTO_ecdsa_sign ( |
930 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 930 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
931 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, | 931 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, |
932 | struct GNUNET_CRYPTO_EcdsaSignature *sig) | 932 | struct GNUNET_CRYPTO_EcdsaSignature *sig) |
@@ -937,39 +937,39 @@ GNUNET_CRYPTO_ecdsa_sign( | |||
937 | int rc; | 937 | int rc; |
938 | gcry_mpi_t rs[2]; | 938 | gcry_mpi_t rs[2]; |
939 | 939 | ||
940 | BENCHMARK_START(ecdsa_sign); | 940 | BENCHMARK_START (ecdsa_sign); |
941 | 941 | ||
942 | priv_sexp = decode_private_ecdsa_key(priv); | 942 | priv_sexp = decode_private_ecdsa_key (priv); |
943 | data = data_to_ecdsa_value(purpose); | 943 | data = data_to_ecdsa_value (purpose); |
944 | if (0 != (rc = gcry_pk_sign(&sig_sexp, data, priv_sexp))) | 944 | if (0 != (rc = gcry_pk_sign (&sig_sexp, data, priv_sexp))) |
945 | { | 945 | { |
946 | LOG(GNUNET_ERROR_TYPE_WARNING, | 946 | LOG (GNUNET_ERROR_TYPE_WARNING, |
947 | _("ECC signing failed at %s:%d: %s\n"), | 947 | _ ("ECC signing failed at %s:%d: %s\n"), |
948 | __FILE__, | 948 | __FILE__, |
949 | __LINE__, | 949 | __LINE__, |
950 | gcry_strerror(rc)); | 950 | gcry_strerror (rc)); |
951 | gcry_sexp_release(data); | 951 | gcry_sexp_release (data); |
952 | gcry_sexp_release(priv_sexp); | 952 | gcry_sexp_release (priv_sexp); |
953 | return GNUNET_SYSERR; | 953 | return GNUNET_SYSERR; |
954 | } | 954 | } |
955 | gcry_sexp_release(priv_sexp); | 955 | gcry_sexp_release (priv_sexp); |
956 | gcry_sexp_release(data); | 956 | gcry_sexp_release (data); |
957 | 957 | ||
958 | /* extract 'r' and 's' values from sexpression 'sig_sexp' and store in | 958 | /* extract 'r' and 's' values from sexpression 'sig_sexp' and store in |
959 | 'signature' */ | 959 | 'signature' */ |
960 | if (0 != (rc = key_from_sexp(rs, sig_sexp, "sig-val", "rs"))) | 960 | if (0 != (rc = key_from_sexp (rs, sig_sexp, "sig-val", "rs"))) |
961 | { | 961 | { |
962 | GNUNET_break(0); | 962 | GNUNET_break (0); |
963 | gcry_sexp_release(sig_sexp); | 963 | gcry_sexp_release (sig_sexp); |
964 | return GNUNET_SYSERR; | 964 | return GNUNET_SYSERR; |
965 | } | 965 | } |
966 | gcry_sexp_release(sig_sexp); | 966 | gcry_sexp_release (sig_sexp); |
967 | GNUNET_CRYPTO_mpi_print_unsigned(sig->r, sizeof(sig->r), rs[0]); | 967 | GNUNET_CRYPTO_mpi_print_unsigned (sig->r, sizeof(sig->r), rs[0]); |
968 | GNUNET_CRYPTO_mpi_print_unsigned(sig->s, sizeof(sig->s), rs[1]); | 968 | GNUNET_CRYPTO_mpi_print_unsigned (sig->s, sizeof(sig->s), rs[1]); |
969 | gcry_mpi_release(rs[0]); | 969 | gcry_mpi_release (rs[0]); |
970 | gcry_mpi_release(rs[1]); | 970 | gcry_mpi_release (rs[1]); |
971 | 971 | ||
972 | BENCHMARK_END(ecdsa_sign); | 972 | BENCHMARK_END (ecdsa_sign); |
973 | 973 | ||
974 | return GNUNET_OK; | 974 | return GNUNET_OK; |
975 | } | 975 | } |
@@ -984,7 +984,7 @@ GNUNET_CRYPTO_ecdsa_sign( | |||
984 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 984 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
985 | */ | 985 | */ |
986 | int | 986 | int |
987 | GNUNET_CRYPTO_eddsa_sign( | 987 | GNUNET_CRYPTO_eddsa_sign ( |
988 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | 988 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, |
989 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, | 989 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, |
990 | struct GNUNET_CRYPTO_EddsaSignature *sig) | 990 | struct GNUNET_CRYPTO_EddsaSignature *sig) |
@@ -995,39 +995,39 @@ GNUNET_CRYPTO_eddsa_sign( | |||
995 | int rc; | 995 | int rc; |
996 | gcry_mpi_t rs[2]; | 996 | gcry_mpi_t rs[2]; |
997 | 997 | ||
998 | BENCHMARK_START(eddsa_sign); | 998 | BENCHMARK_START (eddsa_sign); |
999 | 999 | ||
1000 | priv_sexp = decode_private_eddsa_key(priv); | 1000 | priv_sexp = decode_private_eddsa_key (priv); |
1001 | data = data_to_eddsa_value(purpose); | 1001 | data = data_to_eddsa_value (purpose); |
1002 | if (0 != (rc = gcry_pk_sign(&sig_sexp, data, priv_sexp))) | 1002 | if (0 != (rc = gcry_pk_sign (&sig_sexp, data, priv_sexp))) |
1003 | { | 1003 | { |
1004 | LOG(GNUNET_ERROR_TYPE_WARNING, | 1004 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1005 | _("EdDSA signing failed at %s:%d: %s\n"), | 1005 | _ ("EdDSA signing failed at %s:%d: %s\n"), |
1006 | __FILE__, | 1006 | __FILE__, |
1007 | __LINE__, | 1007 | __LINE__, |
1008 | gcry_strerror(rc)); | 1008 | gcry_strerror (rc)); |
1009 | gcry_sexp_release(data); | 1009 | gcry_sexp_release (data); |
1010 | gcry_sexp_release(priv_sexp); | 1010 | gcry_sexp_release (priv_sexp); |
1011 | return GNUNET_SYSERR; | 1011 | return GNUNET_SYSERR; |
1012 | } | 1012 | } |
1013 | gcry_sexp_release(priv_sexp); | 1013 | gcry_sexp_release (priv_sexp); |
1014 | gcry_sexp_release(data); | 1014 | gcry_sexp_release (data); |
1015 | 1015 | ||
1016 | /* extract 'r' and 's' values from sexpression 'sig_sexp' and store in | 1016 | /* extract 'r' and 's' values from sexpression 'sig_sexp' and store in |
1017 | 'signature' */ | 1017 | 'signature' */ |
1018 | if (0 != (rc = key_from_sexp(rs, sig_sexp, "sig-val", "rs"))) | 1018 | if (0 != (rc = key_from_sexp (rs, sig_sexp, "sig-val", "rs"))) |
1019 | { | 1019 | { |
1020 | GNUNET_break(0); | 1020 | GNUNET_break (0); |
1021 | gcry_sexp_release(sig_sexp); | 1021 | gcry_sexp_release (sig_sexp); |
1022 | return GNUNET_SYSERR; | 1022 | return GNUNET_SYSERR; |
1023 | } | 1023 | } |
1024 | gcry_sexp_release(sig_sexp); | 1024 | gcry_sexp_release (sig_sexp); |
1025 | GNUNET_CRYPTO_mpi_print_unsigned(sig->r, sizeof(sig->r), rs[0]); | 1025 | GNUNET_CRYPTO_mpi_print_unsigned (sig->r, sizeof(sig->r), rs[0]); |
1026 | GNUNET_CRYPTO_mpi_print_unsigned(sig->s, sizeof(sig->s), rs[1]); | 1026 | GNUNET_CRYPTO_mpi_print_unsigned (sig->s, sizeof(sig->s), rs[1]); |
1027 | gcry_mpi_release(rs[0]); | 1027 | gcry_mpi_release (rs[0]); |
1028 | gcry_mpi_release(rs[1]); | 1028 | gcry_mpi_release (rs[1]); |
1029 | 1029 | ||
1030 | BENCHMARK_END(eddsa_sign); | 1030 | BENCHMARK_END (eddsa_sign); |
1031 | 1031 | ||
1032 | return GNUNET_OK; | 1032 | return GNUNET_OK; |
1033 | } | 1033 | } |
@@ -1043,7 +1043,7 @@ GNUNET_CRYPTO_eddsa_sign( | |||
1043 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid | 1043 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid |
1044 | */ | 1044 | */ |
1045 | int | 1045 | int |
1046 | GNUNET_CRYPTO_ecdsa_verify( | 1046 | GNUNET_CRYPTO_ecdsa_verify ( |
1047 | uint32_t purpose, | 1047 | uint32_t purpose, |
1048 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, | 1048 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, |
1049 | const struct GNUNET_CRYPTO_EcdsaSignature *sig, | 1049 | const struct GNUNET_CRYPTO_EcdsaSignature *sig, |
@@ -1054,49 +1054,49 @@ GNUNET_CRYPTO_ecdsa_verify( | |||
1054 | gcry_sexp_t pub_sexpr; | 1054 | gcry_sexp_t pub_sexpr; |
1055 | int rc; | 1055 | int rc; |
1056 | 1056 | ||
1057 | BENCHMARK_START(ecdsa_verify); | 1057 | BENCHMARK_START (ecdsa_verify); |
1058 | 1058 | ||
1059 | if (purpose != ntohl(validate->purpose)) | 1059 | if (purpose != ntohl (validate->purpose)) |
1060 | return GNUNET_SYSERR; /* purpose mismatch */ | 1060 | return GNUNET_SYSERR; /* purpose mismatch */ |
1061 | 1061 | ||
1062 | /* build s-expression for signature */ | 1062 | /* build s-expression for signature */ |
1063 | if (0 != (rc = gcry_sexp_build(&sig_sexpr, | 1063 | if (0 != (rc = gcry_sexp_build (&sig_sexpr, |
1064 | NULL, | 1064 | NULL, |
1065 | "(sig-val(ecdsa(r %b)(s %b)))", | 1065 | "(sig-val(ecdsa(r %b)(s %b)))", |
1066 | (int)sizeof(sig->r), | 1066 | (int) sizeof(sig->r), |
1067 | sig->r, | 1067 | sig->r, |
1068 | (int)sizeof(sig->s), | 1068 | (int) sizeof(sig->s), |
1069 | sig->s))) | 1069 | sig->s))) |
1070 | { | 1070 | { |
1071 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); | 1071 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); |
1072 | return GNUNET_SYSERR; | 1072 | return GNUNET_SYSERR; |
1073 | } | 1073 | } |
1074 | data = data_to_ecdsa_value(validate); | 1074 | data = data_to_ecdsa_value (validate); |
1075 | if (0 != (rc = gcry_sexp_build(&pub_sexpr, | 1075 | if (0 != (rc = gcry_sexp_build (&pub_sexpr, |
1076 | NULL, | 1076 | NULL, |
1077 | "(public-key(ecc(curve " CURVE ")(q %b)))", | 1077 | "(public-key(ecc(curve " CURVE ")(q %b)))", |
1078 | (int)sizeof(pub->q_y), | 1078 | (int) sizeof(pub->q_y), |
1079 | pub->q_y))) | 1079 | pub->q_y))) |
1080 | { | 1080 | { |
1081 | gcry_sexp_release(data); | 1081 | gcry_sexp_release (data); |
1082 | gcry_sexp_release(sig_sexpr); | 1082 | gcry_sexp_release (sig_sexpr); |
1083 | return GNUNET_SYSERR; | 1083 | return GNUNET_SYSERR; |
1084 | } | 1084 | } |
1085 | rc = gcry_pk_verify(sig_sexpr, data, pub_sexpr); | 1085 | rc = gcry_pk_verify (sig_sexpr, data, pub_sexpr); |
1086 | gcry_sexp_release(pub_sexpr); | 1086 | gcry_sexp_release (pub_sexpr); |
1087 | gcry_sexp_release(data); | 1087 | gcry_sexp_release (data); |
1088 | gcry_sexp_release(sig_sexpr); | 1088 | gcry_sexp_release (sig_sexpr); |
1089 | if (0 != rc) | 1089 | if (0 != rc) |
1090 | { | 1090 | { |
1091 | LOG(GNUNET_ERROR_TYPE_INFO, | 1091 | LOG (GNUNET_ERROR_TYPE_INFO, |
1092 | _("ECDSA signature verification failed at %s:%d: %s\n"), | 1092 | _ ("ECDSA signature verification failed at %s:%d: %s\n"), |
1093 | __FILE__, | 1093 | __FILE__, |
1094 | __LINE__, | 1094 | __LINE__, |
1095 | gcry_strerror(rc)); | 1095 | gcry_strerror (rc)); |
1096 | BENCHMARK_END(ecdsa_verify); | 1096 | BENCHMARK_END (ecdsa_verify); |
1097 | return GNUNET_SYSERR; | 1097 | return GNUNET_SYSERR; |
1098 | } | 1098 | } |
1099 | BENCHMARK_END(ecdsa_verify); | 1099 | BENCHMARK_END (ecdsa_verify); |
1100 | return GNUNET_OK; | 1100 | return GNUNET_OK; |
1101 | } | 1101 | } |
1102 | 1102 | ||
@@ -1111,7 +1111,7 @@ GNUNET_CRYPTO_ecdsa_verify( | |||
1111 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid | 1111 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid |
1112 | */ | 1112 | */ |
1113 | int | 1113 | int |
1114 | GNUNET_CRYPTO_eddsa_verify( | 1114 | GNUNET_CRYPTO_eddsa_verify ( |
1115 | uint32_t purpose, | 1115 | uint32_t purpose, |
1116 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, | 1116 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, |
1117 | const struct GNUNET_CRYPTO_EddsaSignature *sig, | 1117 | const struct GNUNET_CRYPTO_EddsaSignature *sig, |
@@ -1122,51 +1122,51 @@ GNUNET_CRYPTO_eddsa_verify( | |||
1122 | gcry_sexp_t pub_sexpr; | 1122 | gcry_sexp_t pub_sexpr; |
1123 | int rc; | 1123 | int rc; |
1124 | 1124 | ||
1125 | BENCHMARK_START(eddsa_verify); | 1125 | BENCHMARK_START (eddsa_verify); |
1126 | 1126 | ||
1127 | if (purpose != ntohl(validate->purpose)) | 1127 | if (purpose != ntohl (validate->purpose)) |
1128 | return GNUNET_SYSERR; /* purpose mismatch */ | 1128 | return GNUNET_SYSERR; /* purpose mismatch */ |
1129 | 1129 | ||
1130 | /* build s-expression for signature */ | 1130 | /* build s-expression for signature */ |
1131 | if (0 != (rc = gcry_sexp_build(&sig_sexpr, | 1131 | if (0 != (rc = gcry_sexp_build (&sig_sexpr, |
1132 | NULL, | 1132 | NULL, |
1133 | "(sig-val(eddsa(r %b)(s %b)))", | 1133 | "(sig-val(eddsa(r %b)(s %b)))", |
1134 | (int)sizeof(sig->r), | 1134 | (int) sizeof(sig->r), |
1135 | sig->r, | 1135 | sig->r, |
1136 | (int)sizeof(sig->s), | 1136 | (int) sizeof(sig->s), |
1137 | sig->s))) | 1137 | sig->s))) |
1138 | { | 1138 | { |
1139 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); | 1139 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); |
1140 | return GNUNET_SYSERR; | 1140 | return GNUNET_SYSERR; |
1141 | } | 1141 | } |
1142 | data = data_to_eddsa_value(validate); | 1142 | data = data_to_eddsa_value (validate); |
1143 | if (0 != (rc = gcry_sexp_build(&pub_sexpr, | 1143 | if (0 != (rc = gcry_sexp_build (&pub_sexpr, |
1144 | NULL, | 1144 | NULL, |
1145 | "(public-key(ecc(curve " CURVE | 1145 | "(public-key(ecc(curve " CURVE |
1146 | ")(flags eddsa)(q %b)))", | 1146 | ")(flags eddsa)(q %b)))", |
1147 | (int)sizeof(pub->q_y), | 1147 | (int) sizeof(pub->q_y), |
1148 | pub->q_y))) | 1148 | pub->q_y))) |
1149 | { | 1149 | { |
1150 | gcry_sexp_release(data); | 1150 | gcry_sexp_release (data); |
1151 | gcry_sexp_release(sig_sexpr); | 1151 | gcry_sexp_release (sig_sexpr); |
1152 | return GNUNET_SYSERR; | 1152 | return GNUNET_SYSERR; |
1153 | } | 1153 | } |
1154 | rc = gcry_pk_verify(sig_sexpr, data, pub_sexpr); | 1154 | rc = gcry_pk_verify (sig_sexpr, data, pub_sexpr); |
1155 | gcry_sexp_release(pub_sexpr); | 1155 | gcry_sexp_release (pub_sexpr); |
1156 | gcry_sexp_release(data); | 1156 | gcry_sexp_release (data); |
1157 | gcry_sexp_release(sig_sexpr); | 1157 | gcry_sexp_release (sig_sexpr); |
1158 | if (0 != rc) | 1158 | if (0 != rc) |
1159 | { | 1159 | { |
1160 | LOG(GNUNET_ERROR_TYPE_INFO, | 1160 | LOG (GNUNET_ERROR_TYPE_INFO, |
1161 | _("EdDSA signature verification of type %u failed at %s:%d: %s\n"), | 1161 | _ ("EdDSA signature verification of type %u failed at %s:%d: %s\n"), |
1162 | (unsigned int)purpose, | 1162 | (unsigned int) purpose, |
1163 | __FILE__, | 1163 | __FILE__, |
1164 | __LINE__, | 1164 | __LINE__, |
1165 | gcry_strerror(rc)); | 1165 | gcry_strerror (rc)); |
1166 | BENCHMARK_END(eddsa_verify); | 1166 | BENCHMARK_END (eddsa_verify); |
1167 | return GNUNET_SYSERR; | 1167 | return GNUNET_SYSERR; |
1168 | } | 1168 | } |
1169 | BENCHMARK_END(eddsa_verify); | 1169 | BENCHMARK_END (eddsa_verify); |
1170 | return GNUNET_OK; | 1170 | return GNUNET_OK; |
1171 | } | 1171 | } |
1172 | 1172 | ||
@@ -1180,9 +1180,9 @@ GNUNET_CRYPTO_eddsa_verify( | |||
1180 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 1180 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
1181 | */ | 1181 | */ |
1182 | int | 1182 | int |
1183 | GNUNET_CRYPTO_ecc_ecdh(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | 1183 | GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, |
1184 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, | 1184 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, |
1185 | struct GNUNET_HashCode *key_material) | 1185 | struct GNUNET_HashCode *key_material) |
1186 | { | 1186 | { |
1187 | gcry_mpi_point_t result; | 1187 | gcry_mpi_point_t result; |
1188 | gcry_mpi_point_t q; | 1188 | gcry_mpi_point_t q; |
@@ -1193,51 +1193,51 @@ GNUNET_CRYPTO_ecc_ecdh(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1193 | unsigned char xbuf[256 / 8]; | 1193 | unsigned char xbuf[256 / 8]; |
1194 | size_t rsize; | 1194 | size_t rsize; |
1195 | 1195 | ||
1196 | BENCHMARK_START(ecc_ecdh); | 1196 | BENCHMARK_START (ecc_ecdh); |
1197 | 1197 | ||
1198 | /* first, extract the q = dP value from the public key */ | 1198 | /* first, extract the q = dP value from the public key */ |
1199 | if (0 != gcry_sexp_build(&pub_sexpr, | 1199 | if (0 != gcry_sexp_build (&pub_sexpr, |
1200 | NULL, | 1200 | NULL, |
1201 | "(public-key(ecc(curve " CURVE ")(q %b)))", | 1201 | "(public-key(ecc(curve " CURVE ")(q %b)))", |
1202 | (int)sizeof(pub->q_y), | 1202 | (int) sizeof(pub->q_y), |
1203 | pub->q_y)) | 1203 | pub->q_y)) |
1204 | return GNUNET_SYSERR; | 1204 | return GNUNET_SYSERR; |
1205 | GNUNET_assert(0 == gcry_mpi_ec_new(&ctx, pub_sexpr, NULL)); | 1205 | GNUNET_assert (0 == gcry_mpi_ec_new (&ctx, pub_sexpr, NULL)); |
1206 | gcry_sexp_release(pub_sexpr); | 1206 | gcry_sexp_release (pub_sexpr); |
1207 | q = gcry_mpi_ec_get_point("q", ctx, 0); | 1207 | q = gcry_mpi_ec_get_point ("q", ctx, 0); |
1208 | 1208 | ||
1209 | /* second, extract the d value from our private key */ | 1209 | /* second, extract the d value from our private key */ |
1210 | GNUNET_CRYPTO_mpi_scan_unsigned(&d, priv->d, sizeof(priv->d)); | 1210 | GNUNET_CRYPTO_mpi_scan_unsigned (&d, priv->d, sizeof(priv->d)); |
1211 | 1211 | ||
1212 | /* then call the 'multiply' function, to compute the product */ | 1212 | /* then call the 'multiply' function, to compute the product */ |
1213 | result = gcry_mpi_point_new(0); | 1213 | result = gcry_mpi_point_new (0); |
1214 | gcry_mpi_ec_mul(result, d, q, ctx); | 1214 | gcry_mpi_ec_mul (result, d, q, ctx); |
1215 | gcry_mpi_point_release(q); | 1215 | gcry_mpi_point_release (q); |
1216 | gcry_mpi_release(d); | 1216 | gcry_mpi_release (d); |
1217 | 1217 | ||
1218 | /* finally, convert point to string for hashing */ | 1218 | /* finally, convert point to string for hashing */ |
1219 | result_x = gcry_mpi_new(256); | 1219 | result_x = gcry_mpi_new (256); |
1220 | if (gcry_mpi_ec_get_affine(result_x, NULL, result, ctx)) | 1220 | if (gcry_mpi_ec_get_affine (result_x, NULL, result, ctx)) |
1221 | { | 1221 | { |
1222 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "get_affine failed", 0); | 1222 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "get_affine failed", 0); |
1223 | gcry_mpi_point_release(result); | 1223 | gcry_mpi_point_release (result); |
1224 | gcry_ctx_release(ctx); | 1224 | gcry_ctx_release (ctx); |
1225 | return GNUNET_SYSERR; | 1225 | return GNUNET_SYSERR; |
1226 | } | 1226 | } |
1227 | gcry_mpi_point_release(result); | 1227 | gcry_mpi_point_release (result); |
1228 | gcry_ctx_release(ctx); | 1228 | gcry_ctx_release (ctx); |
1229 | 1229 | ||
1230 | rsize = sizeof(xbuf); | 1230 | rsize = sizeof(xbuf); |
1231 | GNUNET_assert(!gcry_mpi_get_flag(result_x, GCRYMPI_FLAG_OPAQUE)); | 1231 | GNUNET_assert (! gcry_mpi_get_flag (result_x, GCRYMPI_FLAG_OPAQUE)); |
1232 | /* result_x can be negative here, so we do not use 'GNUNET_CRYPTO_mpi_print_unsigned' | 1232 | /* result_x can be negative here, so we do not use 'GNUNET_CRYPTO_mpi_print_unsigned' |
1233 | as that does not include the sign bit; x should be a 255-bit | 1233 | as that does not include the sign bit; x should be a 255-bit |
1234 | value, so with the sign it should fit snugly into the 256-bit | 1234 | value, so with the sign it should fit snugly into the 256-bit |
1235 | xbuf */ | 1235 | xbuf */ |
1236 | GNUNET_assert( | 1236 | GNUNET_assert ( |
1237 | 0 == gcry_mpi_print(GCRYMPI_FMT_STD, xbuf, rsize, &rsize, result_x)); | 1237 | 0 == gcry_mpi_print (GCRYMPI_FMT_STD, xbuf, rsize, &rsize, result_x)); |
1238 | GNUNET_CRYPTO_hash(xbuf, rsize, key_material); | 1238 | GNUNET_CRYPTO_hash (xbuf, rsize, key_material); |
1239 | gcry_mpi_release(result_x); | 1239 | gcry_mpi_release (result_x); |
1240 | BENCHMARK_END(ecc_ecdh); | 1240 | BENCHMARK_END (ecc_ecdh); |
1241 | return GNUNET_OK; | 1241 | return GNUNET_OK; |
1242 | } | 1242 | } |
1243 | 1243 | ||
@@ -1253,27 +1253,27 @@ GNUNET_CRYPTO_ecc_ecdh(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1253 | * @return h value | 1253 | * @return h value |
1254 | */ | 1254 | */ |
1255 | static gcry_mpi_t | 1255 | static gcry_mpi_t |
1256 | derive_h(const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, | 1256 | derive_h (const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, |
1257 | const char *label, | 1257 | const char *label, |
1258 | const char *context) | 1258 | const char *context) |
1259 | { | 1259 | { |
1260 | gcry_mpi_t h; | 1260 | gcry_mpi_t h; |
1261 | struct GNUNET_HashCode hc; | 1261 | struct GNUNET_HashCode hc; |
1262 | static const char *const salt = "key-derivation"; | 1262 | static const char *const salt = "key-derivation"; |
1263 | 1263 | ||
1264 | GNUNET_CRYPTO_kdf(&hc, | 1264 | GNUNET_CRYPTO_kdf (&hc, |
1265 | sizeof(hc), | 1265 | sizeof(hc), |
1266 | salt, | 1266 | salt, |
1267 | strlen(salt), | 1267 | strlen (salt), |
1268 | pub, | 1268 | pub, |
1269 | sizeof(*pub), | 1269 | sizeof(*pub), |
1270 | label, | 1270 | label, |
1271 | strlen(label), | 1271 | strlen (label), |
1272 | context, | 1272 | context, |
1273 | strlen(context), | 1273 | strlen (context), |
1274 | NULL, | 1274 | NULL, |
1275 | 0); | 1275 | 0); |
1276 | GNUNET_CRYPTO_mpi_scan_unsigned(&h, (unsigned char *)&hc, sizeof(hc)); | 1276 | GNUNET_CRYPTO_mpi_scan_unsigned (&h, (unsigned char *) &hc, sizeof(hc)); |
1277 | return h; | 1277 | return h; |
1278 | } | 1278 | } |
1279 | 1279 | ||
@@ -1291,7 +1291,7 @@ derive_h(const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, | |||
1291 | * @return derived private key | 1291 | * @return derived private key |
1292 | */ | 1292 | */ |
1293 | struct GNUNET_CRYPTO_EcdsaPrivateKey * | 1293 | struct GNUNET_CRYPTO_EcdsaPrivateKey * |
1294 | GNUNET_CRYPTO_ecdsa_private_key_derive( | 1294 | GNUNET_CRYPTO_ecdsa_private_key_derive ( |
1295 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 1295 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
1296 | const char *label, | 1296 | const char *label, |
1297 | const char *context) | 1297 | const char *context) |
@@ -1304,22 +1304,22 @@ GNUNET_CRYPTO_ecdsa_private_key_derive( | |||
1304 | gcry_mpi_t n; | 1304 | gcry_mpi_t n; |
1305 | gcry_ctx_t ctx; | 1305 | gcry_ctx_t ctx; |
1306 | 1306 | ||
1307 | GNUNET_assert(0 == gcry_mpi_ec_new(&ctx, NULL, CURVE)); | 1307 | GNUNET_assert (0 == gcry_mpi_ec_new (&ctx, NULL, CURVE)); |
1308 | 1308 | ||
1309 | n = gcry_mpi_ec_get_mpi("n", ctx, 1); | 1309 | n = gcry_mpi_ec_get_mpi ("n", ctx, 1); |
1310 | GNUNET_CRYPTO_ecdsa_key_get_public(priv, &pub); | 1310 | GNUNET_CRYPTO_ecdsa_key_get_public (priv, &pub); |
1311 | 1311 | ||
1312 | h = derive_h(&pub, label, context); | 1312 | h = derive_h (&pub, label, context); |
1313 | GNUNET_CRYPTO_mpi_scan_unsigned(&x, priv->d, sizeof(priv->d)); | 1313 | GNUNET_CRYPTO_mpi_scan_unsigned (&x, priv->d, sizeof(priv->d)); |
1314 | d = gcry_mpi_new(256); | 1314 | d = gcry_mpi_new (256); |
1315 | gcry_mpi_mulm(d, h, x, n); | 1315 | gcry_mpi_mulm (d, h, x, n); |
1316 | gcry_mpi_release(h); | 1316 | gcry_mpi_release (h); |
1317 | gcry_mpi_release(x); | 1317 | gcry_mpi_release (x); |
1318 | gcry_mpi_release(n); | 1318 | gcry_mpi_release (n); |
1319 | gcry_ctx_release(ctx); | 1319 | gcry_ctx_release (ctx); |
1320 | ret = GNUNET_new(struct GNUNET_CRYPTO_EcdsaPrivateKey); | 1320 | ret = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPrivateKey); |
1321 | GNUNET_CRYPTO_mpi_print_unsigned(ret->d, sizeof(ret->d), d); | 1321 | GNUNET_CRYPTO_mpi_print_unsigned (ret->d, sizeof(ret->d), d); |
1322 | gcry_mpi_release(d); | 1322 | gcry_mpi_release (d); |
1323 | return ret; | 1323 | return ret; |
1324 | } | 1324 | } |
1325 | 1325 | ||
@@ -1335,7 +1335,7 @@ GNUNET_CRYPTO_ecdsa_private_key_derive( | |||
1335 | * @param result where to write the derived public key | 1335 | * @param result where to write the derived public key |
1336 | */ | 1336 | */ |
1337 | void | 1337 | void |
1338 | GNUNET_CRYPTO_ecdsa_public_key_derive( | 1338 | GNUNET_CRYPTO_ecdsa_public_key_derive ( |
1339 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, | 1339 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, |
1340 | const char *label, | 1340 | const char *label, |
1341 | const char *context, | 1341 | const char *context, |
@@ -1349,39 +1349,39 @@ GNUNET_CRYPTO_ecdsa_public_key_derive( | |||
1349 | gcry_mpi_point_t q; | 1349 | gcry_mpi_point_t q; |
1350 | gcry_mpi_point_t v; | 1350 | gcry_mpi_point_t v; |
1351 | 1351 | ||
1352 | GNUNET_assert(0 == gcry_mpi_ec_new(&ctx, NULL, CURVE)); | 1352 | GNUNET_assert (0 == gcry_mpi_ec_new (&ctx, NULL, CURVE)); |
1353 | 1353 | ||
1354 | /* obtain point 'q' from original public key. The provided 'q' is | 1354 | /* obtain point 'q' from original public key. The provided 'q' is |
1355 | compressed thus we first store it in the context and then get it | 1355 | compressed thus we first store it in the context and then get it |
1356 | back as a (decompresssed) point. */ | 1356 | back as a (decompresssed) point. */ |
1357 | q_y = gcry_mpi_set_opaque_copy(NULL, pub->q_y, 8 * sizeof(pub->q_y)); | 1357 | q_y = gcry_mpi_set_opaque_copy (NULL, pub->q_y, 8 * sizeof(pub->q_y)); |
1358 | GNUNET_assert(NULL != q_y); | 1358 | GNUNET_assert (NULL != q_y); |
1359 | GNUNET_assert(0 == gcry_mpi_ec_set_mpi("q", q_y, ctx)); | 1359 | GNUNET_assert (0 == gcry_mpi_ec_set_mpi ("q", q_y, ctx)); |
1360 | gcry_mpi_release(q_y); | 1360 | gcry_mpi_release (q_y); |
1361 | q = gcry_mpi_ec_get_point("q", ctx, 0); | 1361 | q = gcry_mpi_ec_get_point ("q", ctx, 0); |
1362 | GNUNET_assert(q); | 1362 | GNUNET_assert (q); |
1363 | 1363 | ||
1364 | /* calculate h_mod_n = h % n */ | 1364 | /* calculate h_mod_n = h % n */ |
1365 | h = derive_h(pub, label, context); | 1365 | h = derive_h (pub, label, context); |
1366 | n = gcry_mpi_ec_get_mpi("n", ctx, 1); | 1366 | n = gcry_mpi_ec_get_mpi ("n", ctx, 1); |
1367 | h_mod_n = gcry_mpi_new(256); | 1367 | h_mod_n = gcry_mpi_new (256); |
1368 | gcry_mpi_mod(h_mod_n, h, n); | 1368 | gcry_mpi_mod (h_mod_n, h, n); |
1369 | /* calculate v = h_mod_n * q */ | 1369 | /* calculate v = h_mod_n * q */ |
1370 | v = gcry_mpi_point_new(0); | 1370 | v = gcry_mpi_point_new (0); |
1371 | gcry_mpi_ec_mul(v, h_mod_n, q, ctx); | 1371 | gcry_mpi_ec_mul (v, h_mod_n, q, ctx); |
1372 | gcry_mpi_release(h_mod_n); | 1372 | gcry_mpi_release (h_mod_n); |
1373 | gcry_mpi_release(h); | 1373 | gcry_mpi_release (h); |
1374 | gcry_mpi_release(n); | 1374 | gcry_mpi_release (n); |
1375 | gcry_mpi_point_release(q); | 1375 | gcry_mpi_point_release (q); |
1376 | 1376 | ||
1377 | /* convert point 'v' to public key that we return */ | 1377 | /* convert point 'v' to public key that we return */ |
1378 | GNUNET_assert(0 == gcry_mpi_ec_set_point("q", v, ctx)); | 1378 | GNUNET_assert (0 == gcry_mpi_ec_set_point ("q", v, ctx)); |
1379 | gcry_mpi_point_release(v); | 1379 | gcry_mpi_point_release (v); |
1380 | q_y = gcry_mpi_ec_get_mpi("q@eddsa", ctx, 0); | 1380 | q_y = gcry_mpi_ec_get_mpi ("q@eddsa", ctx, 0); |
1381 | GNUNET_assert(q_y); | 1381 | GNUNET_assert (q_y); |
1382 | GNUNET_CRYPTO_mpi_print_unsigned(result->q_y, sizeof(result->q_y), q_y); | 1382 | GNUNET_CRYPTO_mpi_print_unsigned (result->q_y, sizeof(result->q_y), q_y); |
1383 | gcry_mpi_release(q_y); | 1383 | gcry_mpi_release (q_y); |
1384 | gcry_ctx_release(ctx); | 1384 | gcry_ctx_release (ctx); |
1385 | } | 1385 | } |
1386 | 1386 | ||
1387 | 1387 | ||
@@ -1392,17 +1392,17 @@ GNUNET_CRYPTO_ecdsa_public_key_derive( | |||
1392 | * @param length number of bytes in @a buffer | 1392 | * @param length number of bytes in @a buffer |
1393 | */ | 1393 | */ |
1394 | static void | 1394 | static void |
1395 | reverse_buffer(unsigned char *buffer, size_t length) | 1395 | reverse_buffer (unsigned char *buffer, size_t length) |
1396 | { | 1396 | { |
1397 | unsigned char tmp; | 1397 | unsigned char tmp; |
1398 | size_t i; | 1398 | size_t i; |
1399 | 1399 | ||
1400 | for (i = 0; i < length / 2; i++) | 1400 | for (i = 0; i < length / 2; i++) |
1401 | { | 1401 | { |
1402 | tmp = buffer[i]; | 1402 | tmp = buffer[i]; |
1403 | buffer[i] = buffer[length - 1 - i]; | 1403 | buffer[i] = buffer[length - 1 - i]; |
1404 | buffer[length - 1 - i] = tmp; | 1404 | buffer[length - 1 - i] = tmp; |
1405 | } | 1405 | } |
1406 | } | 1406 | } |
1407 | 1407 | ||
1408 | 1408 | ||
@@ -1414,7 +1414,7 @@ reverse_buffer(unsigned char *buffer, size_t length) | |||
1414 | * @return value used for the calculation in EdDSA | 1414 | * @return value used for the calculation in EdDSA |
1415 | */ | 1415 | */ |
1416 | static gcry_mpi_t | 1416 | static gcry_mpi_t |
1417 | eddsa_d_to_a(gcry_mpi_t d) | 1417 | eddsa_d_to_a (gcry_mpi_t d) |
1418 | { | 1418 | { |
1419 | unsigned char rawmpi[32]; /* 256-bit value */ | 1419 | unsigned char rawmpi[32]; /* 256-bit value */ |
1420 | size_t rawmpilen; | 1420 | size_t rawmpilen; |
@@ -1427,25 +1427,25 @@ eddsa_d_to_a(gcry_mpi_t d) | |||
1427 | 1427 | ||
1428 | /* Note that we clear DIGEST so we can use it as input to left pad | 1428 | /* Note that we clear DIGEST so we can use it as input to left pad |
1429 | the key with zeroes for hashing. */ | 1429 | the key with zeroes for hashing. */ |
1430 | memset(digest, 0, sizeof digest); | 1430 | memset (digest, 0, sizeof digest); |
1431 | memset(hvec, 0, sizeof hvec); | 1431 | memset (hvec, 0, sizeof hvec); |
1432 | rawmpilen = sizeof(rawmpi); | 1432 | rawmpilen = sizeof(rawmpi); |
1433 | GNUNET_assert( | 1433 | GNUNET_assert ( |
1434 | 0 == gcry_mpi_print(GCRYMPI_FMT_USG, rawmpi, rawmpilen, &rawmpilen, d)); | 1434 | 0 == gcry_mpi_print (GCRYMPI_FMT_USG, rawmpi, rawmpilen, &rawmpilen, d)); |
1435 | hvec[0].data = digest; | 1435 | hvec[0].data = digest; |
1436 | hvec[0].off = 0; | 1436 | hvec[0].off = 0; |
1437 | hvec[0].len = b > rawmpilen ? (b - rawmpilen) : 0; | 1437 | hvec[0].len = b > rawmpilen ? (b - rawmpilen) : 0; |
1438 | hvec[1].data = rawmpi; | 1438 | hvec[1].data = rawmpi; |
1439 | hvec[1].off = 0; | 1439 | hvec[1].off = 0; |
1440 | hvec[1].len = rawmpilen; | 1440 | hvec[1].len = rawmpilen; |
1441 | GNUNET_assert( | 1441 | GNUNET_assert ( |
1442 | 0 == gcry_md_hash_buffers(GCRY_MD_SHA512, 0 /* flags */, digest, hvec, 2)); | 1442 | 0 == gcry_md_hash_buffers (GCRY_MD_SHA512, 0 /* flags */, digest, hvec, 2)); |
1443 | /* Compute the A value. */ | 1443 | /* Compute the A value. */ |
1444 | reverse_buffer(digest, 32); /* Only the first half of the hash. */ | 1444 | reverse_buffer (digest, 32); /* Only the first half of the hash. */ |
1445 | digest[0] = (digest[0] & 0x7f) | 0x40; | 1445 | digest[0] = (digest[0] & 0x7f) | 0x40; |
1446 | digest[31] &= 0xf8; | 1446 | digest[31] &= 0xf8; |
1447 | 1447 | ||
1448 | GNUNET_CRYPTO_mpi_scan_unsigned(&a, digest, 32); | 1448 | GNUNET_CRYPTO_mpi_scan_unsigned (&a, digest, 32); |
1449 | return a; | 1449 | return a; |
1450 | } | 1450 | } |
1451 | 1451 | ||
@@ -1459,32 +1459,32 @@ eddsa_d_to_a(gcry_mpi_t d) | |||
1459 | * @return #GNUNET_OK on success | 1459 | * @return #GNUNET_OK on success |
1460 | */ | 1460 | */ |
1461 | static int | 1461 | static int |
1462 | point_to_hash(gcry_mpi_point_t result, | 1462 | point_to_hash (gcry_mpi_point_t result, |
1463 | gcry_ctx_t ctx, | 1463 | gcry_ctx_t ctx, |
1464 | struct GNUNET_HashCode *key_material) | 1464 | struct GNUNET_HashCode *key_material) |
1465 | { | 1465 | { |
1466 | gcry_mpi_t result_x; | 1466 | gcry_mpi_t result_x; |
1467 | unsigned char xbuf[256 / 8]; | 1467 | unsigned char xbuf[256 / 8]; |
1468 | size_t rsize; | 1468 | size_t rsize; |
1469 | 1469 | ||
1470 | /* finally, convert point to string for hashing */ | 1470 | /* finally, convert point to string for hashing */ |
1471 | result_x = gcry_mpi_new(256); | 1471 | result_x = gcry_mpi_new (256); |
1472 | if (gcry_mpi_ec_get_affine(result_x, NULL, result, ctx)) | 1472 | if (gcry_mpi_ec_get_affine (result_x, NULL, result, ctx)) |
1473 | { | 1473 | { |
1474 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "get_affine failed", 0); | 1474 | LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "get_affine failed", 0); |
1475 | return GNUNET_SYSERR; | 1475 | return GNUNET_SYSERR; |
1476 | } | 1476 | } |
1477 | 1477 | ||
1478 | rsize = sizeof(xbuf); | 1478 | rsize = sizeof(xbuf); |
1479 | GNUNET_assert(!gcry_mpi_get_flag(result_x, GCRYMPI_FLAG_OPAQUE)); | 1479 | GNUNET_assert (! gcry_mpi_get_flag (result_x, GCRYMPI_FLAG_OPAQUE)); |
1480 | /* result_x can be negative here, so we do not use 'GNUNET_CRYPTO_mpi_print_unsigned' | 1480 | /* result_x can be negative here, so we do not use 'GNUNET_CRYPTO_mpi_print_unsigned' |
1481 | as that does not include the sign bit; x should be a 255-bit | 1481 | as that does not include the sign bit; x should be a 255-bit |
1482 | value, so with the sign it should fit snugly into the 256-bit | 1482 | value, so with the sign it should fit snugly into the 256-bit |
1483 | xbuf */ | 1483 | xbuf */ |
1484 | GNUNET_assert( | 1484 | GNUNET_assert ( |
1485 | 0 == gcry_mpi_print(GCRYMPI_FMT_STD, xbuf, rsize, &rsize, result_x)); | 1485 | 0 == gcry_mpi_print (GCRYMPI_FMT_STD, xbuf, rsize, &rsize, result_x)); |
1486 | GNUNET_CRYPTO_hash(xbuf, rsize, key_material); | 1486 | GNUNET_CRYPTO_hash (xbuf, rsize, key_material); |
1487 | gcry_mpi_release(result_x); | 1487 | gcry_mpi_release (result_x); |
1488 | return GNUNET_OK; | 1488 | return GNUNET_OK; |
1489 | } | 1489 | } |
1490 | 1490 | ||
@@ -1500,9 +1500,9 @@ point_to_hash(gcry_mpi_point_t result, | |||
1500 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 1500 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
1501 | */ | 1501 | */ |
1502 | int | 1502 | int |
1503 | GNUNET_CRYPTO_eddsa_ecdh(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | 1503 | GNUNET_CRYPTO_eddsa_ecdh (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, |
1504 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, | 1504 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, |
1505 | struct GNUNET_HashCode *key_material) | 1505 | struct GNUNET_HashCode *key_material) |
1506 | { | 1506 | { |
1507 | gcry_mpi_point_t result; | 1507 | gcry_mpi_point_t result; |
1508 | gcry_mpi_point_t q; | 1508 | gcry_mpi_point_t q; |
@@ -1512,36 +1512,36 @@ GNUNET_CRYPTO_eddsa_ecdh(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | |||
1512 | gcry_sexp_t pub_sexpr; | 1512 | gcry_sexp_t pub_sexpr; |
1513 | int ret; | 1513 | int ret; |
1514 | 1514 | ||
1515 | BENCHMARK_START(eddsa_ecdh); | 1515 | BENCHMARK_START (eddsa_ecdh); |
1516 | 1516 | ||
1517 | /* first, extract the q = dP value from the public key */ | 1517 | /* first, extract the q = dP value from the public key */ |
1518 | if (0 != gcry_sexp_build(&pub_sexpr, | 1518 | if (0 != gcry_sexp_build (&pub_sexpr, |
1519 | NULL, | 1519 | NULL, |
1520 | "(public-key(ecc(curve " CURVE ")(q %b)))", | 1520 | "(public-key(ecc(curve " CURVE ")(q %b)))", |
1521 | (int)sizeof(pub->q_y), | 1521 | (int) sizeof(pub->q_y), |
1522 | pub->q_y)) | 1522 | pub->q_y)) |
1523 | return GNUNET_SYSERR; | 1523 | return GNUNET_SYSERR; |
1524 | GNUNET_assert(0 == gcry_mpi_ec_new(&ctx, pub_sexpr, NULL)); | 1524 | GNUNET_assert (0 == gcry_mpi_ec_new (&ctx, pub_sexpr, NULL)); |
1525 | gcry_sexp_release(pub_sexpr); | 1525 | gcry_sexp_release (pub_sexpr); |
1526 | q = gcry_mpi_ec_get_point("q", ctx, 0); | 1526 | q = gcry_mpi_ec_get_point ("q", ctx, 0); |
1527 | 1527 | ||
1528 | /* second, extract the d value from our private key */ | 1528 | /* second, extract the d value from our private key */ |
1529 | GNUNET_CRYPTO_mpi_scan_unsigned(&d, priv->d, sizeof(priv->d)); | 1529 | GNUNET_CRYPTO_mpi_scan_unsigned (&d, priv->d, sizeof(priv->d)); |
1530 | 1530 | ||
1531 | /* NOW, because this is EdDSA, HASH 'd' first! */ | 1531 | /* NOW, because this is EdDSA, HASH 'd' first! */ |
1532 | a = eddsa_d_to_a(d); | 1532 | a = eddsa_d_to_a (d); |
1533 | gcry_mpi_release(d); | 1533 | gcry_mpi_release (d); |
1534 | 1534 | ||
1535 | /* then call the 'multiply' function, to compute the product */ | 1535 | /* then call the 'multiply' function, to compute the product */ |
1536 | result = gcry_mpi_point_new(0); | 1536 | result = gcry_mpi_point_new (0); |
1537 | gcry_mpi_ec_mul(result, a, q, ctx); | 1537 | gcry_mpi_ec_mul (result, a, q, ctx); |
1538 | gcry_mpi_point_release(q); | 1538 | gcry_mpi_point_release (q); |
1539 | gcry_mpi_release(a); | 1539 | gcry_mpi_release (a); |
1540 | 1540 | ||
1541 | ret = point_to_hash(result, ctx, key_material); | 1541 | ret = point_to_hash (result, ctx, key_material); |
1542 | gcry_mpi_point_release(result); | 1542 | gcry_mpi_point_release (result); |
1543 | gcry_ctx_release(ctx); | 1543 | gcry_ctx_release (ctx); |
1544 | BENCHMARK_END(eddsa_ecdh); | 1544 | BENCHMARK_END (eddsa_ecdh); |
1545 | return ret; | 1545 | return ret; |
1546 | } | 1546 | } |
1547 | 1547 | ||
@@ -1557,9 +1557,9 @@ GNUNET_CRYPTO_eddsa_ecdh(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | |||
1557 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 1557 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
1558 | */ | 1558 | */ |
1559 | int | 1559 | int |
1560 | GNUNET_CRYPTO_ecdsa_ecdh(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 1560 | GNUNET_CRYPTO_ecdsa_ecdh (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
1561 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, | 1561 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, |
1562 | struct GNUNET_HashCode *key_material) | 1562 | struct GNUNET_HashCode *key_material) |
1563 | { | 1563 | { |
1564 | gcry_mpi_point_t result; | 1564 | gcry_mpi_point_t result; |
1565 | gcry_mpi_point_t q; | 1565 | gcry_mpi_point_t q; |
@@ -1568,33 +1568,33 @@ GNUNET_CRYPTO_ecdsa_ecdh(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | |||
1568 | gcry_sexp_t pub_sexpr; | 1568 | gcry_sexp_t pub_sexpr; |
1569 | int ret; | 1569 | int ret; |
1570 | 1570 | ||
1571 | BENCHMARK_START(ecdsa_ecdh); | 1571 | BENCHMARK_START (ecdsa_ecdh); |
1572 | 1572 | ||
1573 | /* first, extract the q = dP value from the public key */ | 1573 | /* first, extract the q = dP value from the public key */ |
1574 | if (0 != gcry_sexp_build(&pub_sexpr, | 1574 | if (0 != gcry_sexp_build (&pub_sexpr, |
1575 | NULL, | 1575 | NULL, |
1576 | "(public-key(ecc(curve " CURVE ")(q %b)))", | 1576 | "(public-key(ecc(curve " CURVE ")(q %b)))", |
1577 | (int)sizeof(pub->q_y), | 1577 | (int) sizeof(pub->q_y), |
1578 | pub->q_y)) | 1578 | pub->q_y)) |
1579 | return GNUNET_SYSERR; | 1579 | return GNUNET_SYSERR; |
1580 | GNUNET_assert(0 == gcry_mpi_ec_new(&ctx, pub_sexpr, NULL)); | 1580 | GNUNET_assert (0 == gcry_mpi_ec_new (&ctx, pub_sexpr, NULL)); |
1581 | gcry_sexp_release(pub_sexpr); | 1581 | gcry_sexp_release (pub_sexpr); |
1582 | q = gcry_mpi_ec_get_point("q", ctx, 0); | 1582 | q = gcry_mpi_ec_get_point ("q", ctx, 0); |
1583 | 1583 | ||
1584 | /* second, extract the d value from our private key */ | 1584 | /* second, extract the d value from our private key */ |
1585 | GNUNET_CRYPTO_mpi_scan_unsigned(&d, priv->d, sizeof(priv->d)); | 1585 | GNUNET_CRYPTO_mpi_scan_unsigned (&d, priv->d, sizeof(priv->d)); |
1586 | 1586 | ||
1587 | /* then call the 'multiply' function, to compute the product */ | 1587 | /* then call the 'multiply' function, to compute the product */ |
1588 | result = gcry_mpi_point_new(0); | 1588 | result = gcry_mpi_point_new (0); |
1589 | gcry_mpi_ec_mul(result, d, q, ctx); | 1589 | gcry_mpi_ec_mul (result, d, q, ctx); |
1590 | gcry_mpi_point_release(q); | 1590 | gcry_mpi_point_release (q); |
1591 | gcry_mpi_release(d); | 1591 | gcry_mpi_release (d); |
1592 | 1592 | ||
1593 | /* finally, convert point to string for hashing */ | 1593 | /* finally, convert point to string for hashing */ |
1594 | ret = point_to_hash(result, ctx, key_material); | 1594 | ret = point_to_hash (result, ctx, key_material); |
1595 | gcry_mpi_point_release(result); | 1595 | gcry_mpi_point_release (result); |
1596 | gcry_ctx_release(ctx); | 1596 | gcry_ctx_release (ctx); |
1597 | BENCHMARK_END(ecdsa_ecdh); | 1597 | BENCHMARK_END (ecdsa_ecdh); |
1598 | return ret; | 1598 | return ret; |
1599 | } | 1599 | } |
1600 | 1600 | ||
@@ -1610,9 +1610,9 @@ GNUNET_CRYPTO_ecdsa_ecdh(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | |||
1610 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 1610 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
1611 | */ | 1611 | */ |
1612 | int | 1612 | int |
1613 | GNUNET_CRYPTO_ecdh_eddsa(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | 1613 | GNUNET_CRYPTO_ecdh_eddsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, |
1614 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub, | 1614 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub, |
1615 | struct GNUNET_HashCode *key_material) | 1615 | struct GNUNET_HashCode *key_material) |
1616 | { | 1616 | { |
1617 | gcry_mpi_point_t result; | 1617 | gcry_mpi_point_t result; |
1618 | gcry_mpi_point_t q; | 1618 | gcry_mpi_point_t q; |
@@ -1621,33 +1621,33 @@ GNUNET_CRYPTO_ecdh_eddsa(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1621 | gcry_sexp_t pub_sexpr; | 1621 | gcry_sexp_t pub_sexpr; |
1622 | int ret; | 1622 | int ret; |
1623 | 1623 | ||
1624 | BENCHMARK_START(ecdh_eddsa); | 1624 | BENCHMARK_START (ecdh_eddsa); |
1625 | 1625 | ||
1626 | /* first, extract the q = dP value from the public key */ | 1626 | /* first, extract the q = dP value from the public key */ |
1627 | if (0 != gcry_sexp_build(&pub_sexpr, | 1627 | if (0 != gcry_sexp_build (&pub_sexpr, |
1628 | NULL, | 1628 | NULL, |
1629 | "(public-key(ecc(curve " CURVE ")(q %b)))", | 1629 | "(public-key(ecc(curve " CURVE ")(q %b)))", |
1630 | (int)sizeof(pub->q_y), | 1630 | (int) sizeof(pub->q_y), |
1631 | pub->q_y)) | 1631 | pub->q_y)) |
1632 | return GNUNET_SYSERR; | 1632 | return GNUNET_SYSERR; |
1633 | GNUNET_assert(0 == gcry_mpi_ec_new(&ctx, pub_sexpr, NULL)); | 1633 | GNUNET_assert (0 == gcry_mpi_ec_new (&ctx, pub_sexpr, NULL)); |
1634 | gcry_sexp_release(pub_sexpr); | 1634 | gcry_sexp_release (pub_sexpr); |
1635 | q = gcry_mpi_ec_get_point("q", ctx, 0); | 1635 | q = gcry_mpi_ec_get_point ("q", ctx, 0); |
1636 | 1636 | ||
1637 | /* second, extract the d value from our private key */ | 1637 | /* second, extract the d value from our private key */ |
1638 | GNUNET_CRYPTO_mpi_scan_unsigned(&d, priv->d, sizeof(priv->d)); | 1638 | GNUNET_CRYPTO_mpi_scan_unsigned (&d, priv->d, sizeof(priv->d)); |
1639 | 1639 | ||
1640 | /* then call the 'multiply' function, to compute the product */ | 1640 | /* then call the 'multiply' function, to compute the product */ |
1641 | result = gcry_mpi_point_new(0); | 1641 | result = gcry_mpi_point_new (0); |
1642 | gcry_mpi_ec_mul(result, d, q, ctx); | 1642 | gcry_mpi_ec_mul (result, d, q, ctx); |
1643 | gcry_mpi_point_release(q); | 1643 | gcry_mpi_point_release (q); |
1644 | gcry_mpi_release(d); | 1644 | gcry_mpi_release (d); |
1645 | 1645 | ||
1646 | /* finally, convert point to string for hashing */ | 1646 | /* finally, convert point to string for hashing */ |
1647 | ret = point_to_hash(result, ctx, key_material); | 1647 | ret = point_to_hash (result, ctx, key_material); |
1648 | gcry_mpi_point_release(result); | 1648 | gcry_mpi_point_release (result); |
1649 | gcry_ctx_release(ctx); | 1649 | gcry_ctx_release (ctx); |
1650 | BENCHMARK_END(ecdh_eddsa); | 1650 | BENCHMARK_END (ecdh_eddsa); |
1651 | return ret; | 1651 | return ret; |
1652 | } | 1652 | } |
1653 | 1653 | ||
@@ -1662,14 +1662,14 @@ GNUNET_CRYPTO_ecdh_eddsa(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1662 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 1662 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
1663 | */ | 1663 | */ |
1664 | int | 1664 | int |
1665 | GNUNET_CRYPTO_ecdh_ecdsa(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | 1665 | GNUNET_CRYPTO_ecdh_ecdsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, |
1666 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, | 1666 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, |
1667 | struct GNUNET_HashCode *key_material) | 1667 | struct GNUNET_HashCode *key_material) |
1668 | { | 1668 | { |
1669 | return GNUNET_CRYPTO_ecdh_eddsa(priv, | 1669 | return GNUNET_CRYPTO_ecdh_eddsa (priv, |
1670 | (const struct GNUNET_CRYPTO_EddsaPublicKey *) | 1670 | (const struct GNUNET_CRYPTO_EddsaPublicKey *) |
1671 | pub, | 1671 | pub, |
1672 | key_material); | 1672 | key_material); |
1673 | } | 1673 | } |
1674 | 1674 | ||
1675 | /* end of crypto_ecc.c */ | 1675 | /* end of crypto_ecc.c */ |