[or-cvs] Separate "generate-DH-key" from "get-DH-key" without breaki...
Nick Mathewson
nickm at seul.org
Thu Apr 1 20:04:56 UTC 2004
Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/tmp/cvs-serv21409/common
Modified Files:
crypto.c crypto.h
Log Message:
Separate "generate-DH-key" from "get-DH-key" without breaking old interface
Index: crypto.c
===================================================================
RCS file: /home/or/cvsroot/src/common/crypto.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- crypto.c 1 Apr 2004 03:08:34 -0000 1.63
+++ crypto.c 1 Apr 2004 20:04:54 -0000 1.64
@@ -1158,12 +1158,20 @@
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_generate_key(dh->dh))
- return -1;
+ 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);
Index: crypto.h
===================================================================
RCS file: /home/or/cvsroot/src/common/crypto.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- crypto.h 1 Apr 2004 03:08:35 -0000 1.31
+++ crypto.h 1 Apr 2004 20:04:54 -0000 1.32
@@ -86,6 +86,7 @@
#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,
More information about the tor-commits
mailing list