Tor
0.4.7.0-alpha-dev
|
Header for crypto_curve25519.c. More...
#include <stdbool.h>
#include "lib/testsupport/testsupport.h"
#include "lib/cc/torint.h"
#include "lib/crypt_ops/crypto_digest.h"
#include "lib/crypt_ops/crypto_openssl_mgt.h"
#include "lib/defs/x25519_sizes.h"
Go to the source code of this file.
Data Structures | |
struct | curve25519_public_key_t |
struct | curve25519_secret_key_t |
struct | curve25519_keypair_t |
Header for crypto_curve25519.c.
Definition in file crypto_curve25519.h.
void curve25519_handshake | ( | uint8_t * | output, |
const curve25519_secret_key_t * | skey, | ||
const curve25519_public_key_t * | pkey | ||
) |
Perform the curve25519 ECDH handshake with skey and pkey, writing CURVE25519_OUTPUT_LEN bytes of output into output.
Definition at line 268 of file crypto_curve25519.c.
Referenced by hs_ntor_service_get_introduce1_keys_multi().
void curve25519_init | ( | void | ) |
Initialize the curve25519 implementations. This is necessary if you're going to use them in a multithreaded setting, and not otherwise.
Definition at line 363 of file crypto_curve25519.c.
int curve25519_keypair_generate | ( | curve25519_keypair_t * | keypair_out, |
int | extra_strong | ||
) |
Construct a new keypair in *keypair_out. If extra_strong is true, this key is possibly going to get used more than once, so use a better-than-usual RNG. Return 0 on success, -1 on failure.
Definition at line 190 of file crypto_curve25519.c.
int curve25519_keypair_read_from_file | ( | curve25519_keypair_t * | keypair_out, |
char ** | tag_out, | ||
const char * | fname | ||
) |
Read a curve25519 keypair from a file named fname created by curve25519_keypair_write_to_file(). Store the keypair in keypair_out, and the associated tag string in tag_out. Return 0 on success, and -1 on failure.
Definition at line 233 of file crypto_curve25519.c.
int curve25519_keypair_write_to_file | ( | const curve25519_keypair_t * | keypair, |
const char * | fname, | ||
const char * | tag | ||
) |
Store the keypair keypair, including its secret and public parts, to the file fname. Use the string tag tag to distinguish this from other Curve25519 keypairs. Return 0 on success, -1 on failure.
See crypto_write_tagged_contents_to_file() for more information on the metaformat used for these keys.
Definition at line 207 of file crypto_curve25519.c.
int curve25519_public_from_base64 | ( | curve25519_public_key_t * | pkey, |
const char * | input | ||
) |
Try to decode a base64-encoded curve25519 public key from input into the object at pkey. Return 0 on success, -1 on failure. Accepts keys with or without a trailing "=".
Definition at line 170 of file crypto_format.c.
void curve25519_public_key_generate | ( | curve25519_public_key_t * | key_out, |
const curve25519_secret_key_t * | seckey | ||
) |
Given a secret key in seckey, create the corresponding public key in key_out.
Definition at line 179 of file crypto_curve25519.c.
Referenced by curve25519_keypair_generate(), and curve25519_keypair_read_from_file().
int curve25519_public_key_is_ok | ( | const curve25519_public_key_t * | key | ) |
Return true iff a curve25519_public_key_t seems valid. (It's not necessary to see if the point is on the curve, since the twist is also secure, but we do need to make sure that it isn't the point at infinity.)
Definition at line 132 of file crypto_curve25519.c.
Referenced by hs_circ_is_rend_sent_in_intro1().
void curve25519_public_to_base64 | ( | char * | output, |
const curve25519_public_key_t * | pkey, | ||
bool | pad | ||
) |
Encode pkey as a base64-encoded string in the buffer output. If pad is false do not include trailing "=" characters, otherwise include them. output must have at least CURVE25519_BASE64_PADDED_LEN+1 bytes available, even if pad is false. Can not fail.
Careful! CURVE25519_BASE64_PADDED_LEN is one byte longer than ED25519_BASE64_LEN.
Definition at line 144 of file crypto_format.c.
Referenced by encode_enc_key(), and encode_onion_key().
int curve25519_rand_seckey_bytes | ( | uint8_t * | out, |
int | extra_strong | ||
) |
Generate CURVE25519_SECKEY_LEN random bytes in out. If extra_strong is true, this key is possibly going to get used more than once, so use a better-than-usual RNG. Return 0 on success, -1 on failure.
This function does not adjust the output of the RNG at all; the will caller will need to clear or set the appropriate bits to make curve25519 work.
Definition at line 147 of file crypto_curve25519.c.
Referenced by curve25519_secret_key_generate().
int curve25519_secret_key_generate | ( | curve25519_secret_key_t * | key_out, |
int | extra_strong | ||
) |
Generate a new keypair and return the secret key. If extra_strong is true, this key is possibly going to get used more than once, so use a better-than-usual RNG. Return 0 on success, -1 on failure.
Definition at line 161 of file crypto_curve25519.c.
Referenced by curve25519_keypair_generate().
void curve25519_set_impl_params | ( | int | use_ed | ) |
Override the decision of whether to use the Ed25519-based basepoint multiply function. Used for testing.
Definition at line 118 of file crypto_curve25519.c.