mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
Separate "generate-DH-key" from "get-DH-key" without breaking old interface
svn:r1431
This commit is contained in:
parent
f05937355e
commit
56b3d67149
@ -1158,12 +1158,20 @@ int crypto_dh_get_bytes(crypto_dh_env_t *dh)
|
||||
assert(dh);
|
||||
return DH_size(dh->dh);
|
||||
}
|
||||
int crypto_dh_generate_public(crypto_dh_env_t *dh)
|
||||
{
|
||||
if (!DH_generate_key(dh->dh))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
int crypto_dh_get_public(crypto_dh_env_t *dh, char *pubkey, int pubkey_len)
|
||||
{
|
||||
int bytes;
|
||||
assert(dh);
|
||||
if (!dh->dh->pub_key) {
|
||||
if (!DH_generate_key(dh->dh))
|
||||
return -1;
|
||||
}
|
||||
|
||||
assert(dh->dh->pub_key);
|
||||
bytes = BN_num_bytes(dh->dh->pub_key);
|
||||
|
@ -86,6 +86,7 @@ typedef struct crypto_dh_env_st {
|
||||
#define CRYPTO_DH_SIZE (1024 / 8)
|
||||
crypto_dh_env_t *crypto_dh_new();
|
||||
int crypto_dh_get_bytes(crypto_dh_env_t *dh);
|
||||
int crypto_dh_generate_public(crypto_dh_env_t *dh);
|
||||
int crypto_dh_get_public(crypto_dh_env_t *dh, char *pubkey_out,
|
||||
int pubkey_out_len);
|
||||
int crypto_dh_compute_secret(crypto_dh_env_t *dh,
|
||||
|
Loading…
Reference in New Issue
Block a user