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 | |
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')
-rw-r--r-- | crypto/dsa/Makefile.ssl | 62 | ||||
-rw-r--r-- | crypto/dsa/dsa.h | 9 | ||||
-rw-r--r-- | crypto/dsa/dsa_lib.c | 37 |
3 files changed, 80 insertions, 28 deletions
diff --git a/crypto/dsa/Makefile.ssl b/crypto/dsa/Makefile.ssl index 1a380966cc..6d80ce77be 100644 --- a/crypto/dsa/Makefile.ssl +++ b/crypto/dsa/Makefile.ssl @@ -81,47 +81,53 @@ clean: dsa_asn1.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h dsa_asn1.o: ../../include/openssl/bio.h ../../include/openssl/bn.h dsa_asn1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h -dsa_asn1.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h -dsa_asn1.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h -dsa_asn1.o: ../../include/openssl/opensslconf.h +dsa_asn1.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h +dsa_asn1.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h +dsa_asn1.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h dsa_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h dsa_asn1.o: ../../include/openssl/stack.h ../cryptlib.h -dsa_err.o: ../../include/openssl/bn.h ../../include/openssl/dsa.h -dsa_err.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h +dsa_err.o: ../../include/openssl/bn.h ../../include/openssl/dh.h +dsa_err.o: ../../include/openssl/dsa.h ../../include/openssl/err.h +dsa_err.o: ../../include/openssl/opensslconf.h dsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h dsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h -dsa_gen.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h -dsa_gen.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h -dsa_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h -dsa_gen.o: ../../include/openssl/rand.h ../../include/openssl/sha.h -dsa_gen.o: ../../include/openssl/stack.h ../cryptlib.h +dsa_gen.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h +dsa_gen.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h +dsa_gen.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h +dsa_gen.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h +dsa_gen.o: ../../include/openssl/sha.h ../../include/openssl/stack.h +dsa_gen.o: ../cryptlib.h dsa_key.o: ../../include/openssl/bio.h ../../include/openssl/bn.h dsa_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h -dsa_key.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h -dsa_key.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h -dsa_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h -dsa_key.o: ../../include/openssl/rand.h ../../include/openssl/sha.h -dsa_key.o: ../../include/openssl/stack.h ../cryptlib.h +dsa_key.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h +dsa_key.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h +dsa_key.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h +dsa_key.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h +dsa_key.o: ../../include/openssl/sha.h ../../include/openssl/stack.h +dsa_key.o: ../cryptlib.h dsa_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h dsa_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h -dsa_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dsa.h -dsa_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h -dsa_lib.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h -dsa_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h -dsa_lib.o: ../../include/openssl/stack.h ../cryptlib.h +dsa_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h +dsa_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h +dsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +dsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +dsa_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +dsa_lib.o: ../cryptlib.h dsa_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h dsa_sign.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h -dsa_sign.o: ../../include/openssl/crypto.h ../../include/openssl/dsa.h -dsa_sign.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h -dsa_sign.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h +dsa_sign.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h +dsa_sign.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h +dsa_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +dsa_sign.o: ../../include/openssl/opensslconf.h dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h dsa_sign.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h dsa_sign.o: ../cryptlib.h dsa_vrf.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h dsa_vrf.o: ../../include/openssl/bio.h ../../include/openssl/bn.h dsa_vrf.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h -dsa_vrf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h -dsa_vrf.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h -dsa_vrf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h -dsa_vrf.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h -dsa_vrf.o: ../../include/openssl/stack.h ../cryptlib.h +dsa_vrf.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h +dsa_vrf.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h +dsa_vrf.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h +dsa_vrf.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h +dsa_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +dsa_vrf.o: ../cryptlib.h diff --git a/crypto/dsa/dsa.h b/crypto/dsa/dsa.h index d9ff1933ee..20b3f8d90a 100644 --- a/crypto/dsa/dsa.h +++ b/crypto/dsa/dsa.h @@ -74,6 +74,9 @@ extern "C" { #endif #include <openssl/bn.h> +#ifndef NO_DH +# include <openssl/dh.h> +#endif #define DSA_FLAG_CACHE_MONT_P 0x01 @@ -162,6 +165,12 @@ int DSA_print_fp(FILE *bp, DSA *x, int off); int DSA_is_prime(BIGNUM *q,void (*callback)(),char *cb_arg); +#ifndef NO_DH +/* Convert DSA structure (key or just parameters) into DH structure + * (be careful to avoid small subgroup attacks when using this!) */ +DH *DSA_dup_DH(DSA *r); +#endif + /* BEGIN ERROR CODES */ /* The following lines are auto generated by the script mkerr.pl. Any changes * made after this point may be overwritten when the script is next run. 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 |