Commit 6e9fa57c authored by Matt Caswell's avatar Matt Caswell
Browse files

Make DSA_METHOD opaque



Move the dsa_method structure out of the public header file, and provide
getter and setter functions for creating and modifying custom DSA_METHODs.

Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
Reviewed-by: default avatarStephen Henson <steve@openssl.org>
parent 1258396d
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -243,8 +243,10 @@ int dsa_main(int argc, char **argv)
    }

    if (modulus) {
        BIGNUM *pub_key = NULL;
        DSA_get0_key(dsa, &pub_key, NULL);
        BIO_printf(out, "Public Key=");
        BN_print(out, DSA_get0_pub_key(dsa));
        BN_print(out, pub_key);
        BIO_printf(out, "\n");
    }

+10 −5
Original line number Diff line number Diff line
@@ -263,14 +263,19 @@ int dsaparam_main(int argc, char **argv)
    }

    if (C) {
        int len = BN_num_bytes(DSA_get0_p(dsa));
        int bits_p = BN_num_bits(DSA_get0_p(dsa));
        BIGNUM *p = NULL, *q = NULL, *g = NULL;
        int len, bits_p;

        DSA_get0_pqg(dsa, &p, &q, &g);
        len = BN_num_bytes(p);
        bits_p = BN_num_bits(p);

        unsigned char *data = app_malloc(len + 20, "BN space");

        BIO_printf(bio_out, "DSA *get_dsa%d()\n{\n", bits_p);
        print_bignum_var(bio_out, DSA_get0_p(dsa), "dsap", len, data);
        print_bignum_var(bio_out, DSA_get0_q(dsa), "dsaq", len, data);
        print_bignum_var(bio_out, DSA_get0_g(dsa), "dsag", len, data);
        print_bignum_var(bio_out, p, "dsap", len, data);
        print_bignum_var(bio_out, q, "dsaq", len, data);
        print_bignum_var(bio_out, g, "dsag", len, data);
        BIO_printf(bio_out, "    DSA *dsa = DSA_new();\n"
                            "\n");
        BIO_printf(bio_out, "    if (dsa == NULL)\n"
+3 −1
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ int gendsa_main(int argc, char **argv)
    char *outfile = NULL, *passoutarg = NULL, *passout = NULL, *prog;
    OPTION_CHOICE o;
    int ret = 1, private = 0;
    BIGNUM *p = NULL;

    prog = opt_init(argc, argv, gendsa_options);
    while ((o = opt_next()) != OPT_EOF) {
@@ -168,7 +169,8 @@ int gendsa_main(int argc, char **argv)
        BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
                   app_RAND_load_files(inrand));

    BIO_printf(bio_err, "Generating DSA key, %d bits\n", BN_num_bits(DSA_get0_p(dsa)));
    DSA_get0_pqg(dsa, &p, NULL, NULL);
    BIO_printf(bio_err, "Generating DSA key, %d bits\n", BN_num_bits(p));
    if (!DSA_generate_key(dsa))
        goto end;

+7 −3
Original line number Diff line number Diff line
@@ -734,11 +734,15 @@ int x509_main(int argc, char **argv)
                else
#endif
#ifndef OPENSSL_NO_DSA
                if (EVP_PKEY_id(pkey) == EVP_PKEY_DSA)
                    BN_print(out, DSA_get0_pub_key(EVP_PKEY_get0_DSA(pkey)));
                else
                if (EVP_PKEY_id(pkey) == EVP_PKEY_DSA) {
                    BIGNUM *dsapub = NULL;
                    DSA_get0_key(EVP_PKEY_get0_DSA(pkey), &dsapub, NULL);
                    BN_print(out, dsapub);
                } else
#endif
                {
                    BIO_printf(out, "Wrong Algorithm type");
                }
                BIO_printf(out, "\n");
            } else if (pubkey == i) {
                EVP_PKEY *pkey;
+4 −2
Original line number Diff line number Diff line
@@ -16,9 +16,11 @@ GENERAL=Makefile

LIB=$(TOP)/libcrypto.a
LIBSRC= dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c \
	dsa_err.c dsa_ossl.c dsa_depr.c dsa_ameth.c dsa_pmeth.c dsa_prn.c
	dsa_err.c dsa_ossl.c dsa_depr.c dsa_ameth.c dsa_pmeth.c dsa_prn.c \
	dsa_meth.c
LIBOBJ= dsa_gen.o dsa_key.o dsa_lib.o dsa_asn1.o dsa_vrf.o dsa_sign.o \
	dsa_err.o dsa_ossl.o dsa_depr.o dsa_ameth.o dsa_pmeth.o dsa_prn.o
	dsa_err.o dsa_ossl.o dsa_depr.o dsa_ameth.o dsa_pmeth.o dsa_prn.o \
	dsa_meth.o

SRC= $(LIBSRC)

Loading