aboutsummaryrefslogtreecommitdiff
path: root/src/util/tweetnacl-gnunet.h
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-11-26 18:26:54 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-11-26 18:29:56 +0100
commitbc340979c19807c76baedc7da98778178b9bcc4a (patch)
treec7e0e017a441ea5bc13d9e165417c5156e390c9b /src/util/tweetnacl-gnunet.h
parentc36c37830eb909fe73357383136cf8b2405d9633 (diff)
downloadgnunet-bc340979c19807c76baedc7da98778178b9bcc4a.tar.gz
gnunet-bc340979c19807c76baedc7da98778178b9bcc4a.zip
use Curve25519 for ECDH and tweetnacl where we can
This leads to some performance improvements and makes it easier to write software that interoperates with GNUnet / GNU Taler. It also avoids using the rather inconvenient libgcrypt APIs. We still need to keep libgcrypt though, as we need it for RSA, ECDSA and some other primitives. This change is still behind a #define NEW_CRYPTO, as it is a breaking change for both EdDSA (removing the superfluous additional hash) and for ECDHE (using Curve25519 instead of Ed25519).
Diffstat (limited to 'src/util/tweetnacl-gnunet.h')
-rw-r--r--src/util/tweetnacl-gnunet.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/util/tweetnacl-gnunet.h b/src/util/tweetnacl-gnunet.h
new file mode 100644
index 000000000..776e0d355
--- /dev/null
+++ b/src/util/tweetnacl-gnunet.h
@@ -0,0 +1,85 @@
1/*
2 This file has been placed in the public domain.
3
4 Based on TweetNaCl version 20140427
5
6 Originally obtained from:
7 https://tweetnacl.cr.yp.to/20140427/tweetnacl.h
8 */
9
10
11#ifndef TWEETNACL_H
12#define TWEETNACL_H
13#include <stdint.h>
14#define crypto_scalarmult_PRIMITIVE "curve25519"
15#define crypto_scalarmult crypto_scalarmult_curve25519
16#define crypto_scalarmult_base crypto_scalarmult_curve25519_base
17#define crypto_scalarmult_BYTES crypto_scalarmult_curve25519_BYTES
18#define crypto_scalarmult_SCALARBYTES crypto_scalarmult_curve25519_SCALARBYTES
19#define crypto_scalarmult_IMPLEMENTATION \
20 crypto_scalarmult_curve25519_IMPLEMENTATION
21#define crypto_scalarmult_VERSION crypto_scalarmult_curve25519_VERSION
22#define crypto_scalarmult_curve25519_tweet_BYTES 32
23#define crypto_scalarmult_curve25519_tweet_SCALARBYTES 32
24extern int crypto_scalarmult_curve25519_tweet (uint8_t *,
25 const uint8_t *,
26 const uint8_t *);
27extern int crypto_scalarmult_curve25519_tweet_base (uint8_t *,
28 const uint8_t *);
29#define crypto_scalarmult_curve25519_tweet_VERSION "-"
30#define crypto_scalarmult_curve25519 crypto_scalarmult_curve25519_tweet
31#define crypto_scalarmult_curve25519_base \
32 crypto_scalarmult_curve25519_tweet_base
33#define crypto_scalarmult_curve25519_BYTES \
34 crypto_scalarmult_curve25519_tweet_BYTES
35#define crypto_scalarmult_curve25519_SCALARBYTES \
36 crypto_scalarmult_curve25519_tweet_SCALARBYTES
37#define crypto_scalarmult_curve25519_VERSION \
38 crypto_scalarmult_curve25519_tweet_VERSION
39#define crypto_scalarmult_curve25519_IMPLEMENTATION \
40 "crypto_scalarmult/curve25519/tweet"
41#define crypto_sign_PRIMITIVE "ed25519"
42#define crypto_sign crypto_sign_ed25519
43#define crypto_sign_BYTES crypto_sign_ed25519_BYTES
44#define crypto_sign_PUBLICKEYBYTES crypto_sign_ed25519_PUBLICKEYBYTES
45#define crypto_sign_SECRETKEYBYTES crypto_sign_ed25519_SECRETKEYBYTES
46#define crypto_sign_IMPLEMENTATION crypto_sign_ed25519_IMPLEMENTATION
47#define crypto_sign_VERSION crypto_sign_ed25519_VERSION
48#define crypto_sign_ed25519_tweet_BYTES 64
49#define crypto_sign_ed25519_tweet_PUBLICKEYBYTES 32
50#define crypto_sign_ed25519_tweet_SECRETKEYBYTES 64
51extern int crypto_sign_ed25519_tweet (uint8_t *,
52 uint64_t *,
53 const uint8_t *,
54 uint64_t,
55 const uint8_t *);
56extern int crypto_sign_ed25519_tweet_open (uint8_t *,
57 uint64_t *,
58 const uint8_t *,
59 uint64_t,
60 const uint8_t *);
61extern int crypto_sign_ed25519_tweet_keypair (uint8_t *,uint8_t *);
62#define crypto_sign_ed25519_tweet_VERSION "-"
63#define crypto_sign_ed25519 crypto_sign_ed25519_tweet
64#define crypto_sign_ed25519_open crypto_sign_ed25519_tweet_open
65#define crypto_sign_ed25519_keypair crypto_sign_ed25519_tweet_keypair
66#define crypto_sign_ed25519_BYTES crypto_sign_ed25519_tweet_BYTES
67#define crypto_sign_ed25519_PUBLICKEYBYTES \
68 crypto_sign_ed25519_tweet_PUBLICKEYBYTES
69#define crypto_sign_ed25519_SECRETKEYBYTES \
70 crypto_sign_ed25519_tweet_SECRETKEYBYTES
71#define crypto_sign_ed25519_VERSION crypto_sign_ed25519_tweet_VERSION
72#define crypto_sign_ed25519_IMPLEMENTATION "crypto_sign/ed25519/tweet"
73void crypto_sign_pk_from_seed (uint8_t *pk, const uint8_t *seed);
74void crypto_sign_sk_from_seed (uint8_t *sk, const uint8_t *seed);
75int crypto_sign_ed25519_pk_to_curve25519 (uint8_t *x25519_pk,
76 const uint8_t *ed25519_pk);
77int crypto_sign_detached_verify (const uint8_t *sig,
78 const uint8_t *m,
79 uint64_t n,
80 const uint8_t *pk);
81int crypto_sign_detached (uint8_t *sig,
82 const uint8_t *m,
83 uint64_t n,
84 const uint8_t *sk);
85#endif