diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-12-04 15:57:16 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-01-02 14:11:13 -0500 |
commit | 6c883bc6384b3260d791e407b42ffcabb8276beb (patch) | |
tree | 17c9476e652e464019c08a21b5f919e719203f9a /src/common/crypto_curve25519.h | |
parent | 25c05cb747eece7d720a3f79c172e83a0e79a3a1 (diff) | |
download | tor-6c883bc6384b3260d791e407b42ffcabb8276beb.tar.gz tor-6c883bc6384b3260d791e407b42ffcabb8276beb.zip |
Move curve25519 keypair type to src/common; give it functions
This patch moves curve25519_keypair_t from src/or/onion_ntor.h to
src/common/crypto_curve25519.h, and adds new functions to generate,
load, and store keypairs.
Diffstat (limited to 'src/common/crypto_curve25519.h')
-rw-r--r-- | src/common/crypto_curve25519.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/common/crypto_curve25519.h b/src/common/crypto_curve25519.h index 3e093be7bf..c43017e355 100644 --- a/src/common/crypto_curve25519.h +++ b/src/common/crypto_curve25519.h @@ -23,21 +23,39 @@ typedef struct curve25519_secret_key_t { uint8_t secret_key[CURVE25519_SECKEY_LEN]; } curve25519_secret_key_t; +/** A paired public and private key for curve25519. **/ +typedef struct curve25519_keypair_t { + curve25519_public_key_t pubkey; + curve25519_secret_key_t seckey; +} curve25519_keypair_t; + +#ifdef CURVE25519_ENABLED int curve25519_public_key_is_ok(const curve25519_public_key_t *); void curve25519_secret_key_generate(curve25519_secret_key_t *key_out, int extra_strong); void curve25519_public_key_generate(curve25519_public_key_t *key_out, const curve25519_secret_key_t *seckey); +void curve25519_keypair_generate(curve25519_keypair_t *keypair_out, + int extra_strong); void curve25519_handshake(uint8_t *output, const curve25519_secret_key_t *, const curve25519_public_key_t *); +int curve25519_keypair_write_to_file(const curve25519_keypair_t *keypair, + const char *fname, + const char *tag); + +int curve25519_keypair_read_from_file(curve25519_keypair_t *keypair_out, + char **tag_out, + const char *fname); + #ifdef CRYPTO_CURVE25519_PRIVATE int curve25519_impl(uint8_t *output, const uint8_t *secret, const uint8_t *basepoint); #endif +#endif #endif |