tor  0.4.1.0-alpha-dev
crypto_curve25519.h
Go to the documentation of this file.
1 /* Copyright (c) 2012-2019, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 
9 #ifndef TOR_CRYPTO_CURVE25519_H
10 #define TOR_CRYPTO_CURVE25519_H
11 
13 #include "lib/cc/torint.h"
16 #include "lib/defs/x25519_sizes.h"
17 
23 typedef struct curve25519_public_key_t {
24  uint8_t public_key[CURVE25519_PUBKEY_LEN];
26 
32 typedef struct curve25519_secret_key_t {
33  uint8_t secret_key[CURVE25519_SECKEY_LEN];
35 
37 typedef struct curve25519_keypair_t {
41 
42 /* These functions require that we actually know how to use curve25519 keys.
43  * The other data structures and functions in this header let us parse them,
44  * store them, and move them around.
45  */
46 
48 
50  int extra_strong);
52  const curve25519_secret_key_t *seckey);
54  int extra_strong);
55 
56 void curve25519_handshake(uint8_t *output,
58  const curve25519_public_key_t *);
59 
61  const char *fname,
62  const char *tag);
63 
65  char **tag_out,
66  const char *fname);
67 
68 int curve25519_rand_seckey_bytes(uint8_t *out, int extra_strong);
69 
70 #ifdef CRYPTO_CURVE25519_PRIVATE
71 STATIC int curve25519_impl(uint8_t *output, const uint8_t *secret,
72  const uint8_t *basepoint);
73 
74 STATIC int curve25519_basepoint_impl(uint8_t *output, const uint8_t *secret);
75 #endif /* defined(CRYPTO_CURVE25519_PRIVATE) */
76 
78  const char *input);
79 int curve25519_public_to_base64(char *output,
80  const curve25519_public_key_t *pkey);
81 
82 void curve25519_set_impl_params(int use_ed);
83 void curve25519_init(void);
84 
85 #endif /* !defined(TOR_CRYPTO_CURVE25519_H) */
int curve25519_public_key_is_ok(const curve25519_public_key_t *)
int curve25519_public_from_base64(curve25519_public_key_t *pkey, const char *input)
Headers for crypto_openssl_mgt.c.
void curve25519_init(void)
struct curve25519_keypair_t curve25519_keypair_t
Integer definitions used throughout Tor.
void curve25519_public_key_generate(curve25519_public_key_t *key_out, const curve25519_secret_key_t *seckey)
struct curve25519_public_key_t curve25519_public_key_t
Definitions for sizes of x25519 keys and elements.
int curve25519_secret_key_generate(curve25519_secret_key_t *key_out, int extra_strong)
int curve25519_rand_seckey_bytes(uint8_t *out, int extra_strong)
struct curve25519_secret_key_t curve25519_secret_key_t
void curve25519_handshake(uint8_t *output, const curve25519_secret_key_t *, const curve25519_public_key_t *)
Headers for crypto_digest.c.
int curve25519_keypair_read_from_file(curve25519_keypair_t *keypair_out, char **tag_out, const char *fname)
STATIC int curve25519_impl(uint8_t *output, const uint8_t *secret, const uint8_t *point)
void curve25519_set_impl_params(int use_ed)
Macros to implement mocking and selective exposure for the test code.
int curve25519_keypair_generate(curve25519_keypair_t *keypair_out, int extra_strong)
int curve25519_keypair_write_to_file(const curve25519_keypair_t *keypair, const char *fname, const char *tag)
STATIC int curve25519_basepoint_impl(uint8_t *output, const uint8_t *secret)
int curve25519_public_to_base64(char *output, const curve25519_public_key_t *pkey)
#define CURVE25519_SECKEY_LEN
Definition: x25519_sizes.h:22
#define CURVE25519_PUBKEY_LEN
Definition: x25519_sizes.h:20