diff options
author | Bodo Möller <bodo@openssl.org> | 1999-08-05 11:50:18 +0000 |
---|---|---|
committer | Bodo Möller <bodo@openssl.org> | 1999-08-05 11:50:18 +0000 |
commit | 48c843c3672c49724b3ccb11204b7ae67b17c9cb (patch) | |
tree | 03ca1f8cbf340b0ca140c09d8dc28526f7b62fd8 /crypto/dsa/dsa_lib.c | |
parent | 90f14e251e2e9836a33bc7ac752abea48e3439af (diff) |
New function DSA_dup_DH, and fixes for bugs that were found
while implementing and using it.
Diffstat (limited to 'crypto/dsa/dsa_lib.c')
-rw-r--r-- | crypto/dsa/dsa_lib.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/crypto/dsa/dsa_lib.c b/crypto/dsa/dsa_lib.c index 8923fb45f4..a5f0182101 100644 --- a/crypto/dsa/dsa_lib.c +++ b/crypto/dsa/dsa_lib.c @@ -145,3 +145,40 @@ int DSA_size(DSA *r) return(ret); } +#ifndef NO_DH +DH *DSA_dup_DH(DSA *r) + { + /* DSA has p, q, g, optional pub_key, optional priv_key. + * DH has p, optional length, g, optional pub_key, optional priv_key. + */ + + DH *ret; + + if (r == NULL) + goto err; + ret = DH_new(); + if (ret == NULL) + goto err; + if (r->p != NULL) + if ((ret->p = BN_dup(r->p)) == NULL) + goto err; + if (r->q != NULL) + ret->length = BN_num_bits(r->q); + if (r->g != NULL) + if ((ret->g = BN_dup(r->g)) == NULL) + goto err; + if (r->pub_key != NULL) + if ((ret->pub_key = BN_dup(r->pub_key)) == NULL) + goto err; + if (r->priv_key != NULL) + if ((ret->priv_key = BN_dup(r->priv_key)) == NULL) + goto err; + + return ret; + + err: + if (ret != NULL) + DH_free(ret); + return NULL; + } +#endif |