diff options
author | Matt Caswell <matt@openssl.org> | 2016-03-30 15:21:39 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-04-03 00:23:56 +0100 |
commit | 1258396d73cf937e4daaf2c35377011b9366f956 (patch) | |
tree | 6448183bf775904be79b29786795ade508f7fe4d /crypto/dsa | |
parent | 25c78440d21c814705e0e50c6e567300936aa02b (diff) | |
download | openssl-1258396d73cf937e4daaf2c35377011b9366f956.tar.gz |
Make the DSA structure opaque
Move the dsa_st structure out of the public header file. Add some accessor
functions to enable access to the internal fields, and update all internal
usage to use the new functions.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Stephen Henson <steve@openssl.org>
Diffstat (limited to 'crypto/dsa')
-rw-r--r-- | crypto/dsa/dsa_ameth.c | 2 | ||||
-rw-r--r-- | crypto/dsa/dsa_asn1.c | 2 | ||||
-rw-r--r-- | crypto/dsa/dsa_key.c | 2 | ||||
-rw-r--r-- | crypto/dsa/dsa_lib.c | 75 | ||||
-rw-r--r-- | crypto/dsa/dsa_locl.h | 23 | ||||
-rw-r--r-- | crypto/dsa/dsa_ossl.c | 2 | ||||
-rw-r--r-- | crypto/dsa/dsa_sign.c | 2 | ||||
-rw-r--r-- | crypto/dsa/dsa_vrf.c | 2 |
8 files changed, 103 insertions, 7 deletions
diff --git a/crypto/dsa/dsa_ameth.c b/crypto/dsa/dsa_ameth.c index f0f28bdf2a..54cdb3dae0 100644 --- a/crypto/dsa/dsa_ameth.c +++ b/crypto/dsa/dsa_ameth.c @@ -60,7 +60,7 @@ #include "internal/cryptlib.h" #include <openssl/x509.h> #include <openssl/asn1.h> -#include <openssl/dsa.h> +#include "dsa_locl.h" #include <openssl/bn.h> #include <openssl/cms.h> #include "internal/asn1_int.h" diff --git a/crypto/dsa/dsa_asn1.c b/crypto/dsa/dsa_asn1.c index c338b5f3a8..1468fb1e66 100644 --- a/crypto/dsa/dsa_asn1.c +++ b/crypto/dsa/dsa_asn1.c @@ -58,7 +58,7 @@ #include <stdio.h> #include "internal/cryptlib.h" -#include <openssl/dsa.h> +#include "dsa_locl.h" #include <openssl/asn1.h> #include <openssl/asn1t.h> #include <openssl/rand.h> diff --git a/crypto/dsa/dsa_key.c b/crypto/dsa/dsa_key.c index 831c2b1d9b..441588498e 100644 --- a/crypto/dsa/dsa_key.c +++ b/crypto/dsa/dsa_key.c @@ -59,7 +59,7 @@ #include <time.h> #include "internal/cryptlib.h" #include <openssl/bn.h> -#include <openssl/dsa.h> +#include "dsa_locl.h" #include <openssl/rand.h> static int dsa_builtin_keygen(DSA *dsa); diff --git a/crypto/dsa/dsa_lib.c b/crypto/dsa/dsa_lib.c index fa8330fd84..08226181f9 100644 --- a/crypto/dsa/dsa_lib.c +++ b/crypto/dsa/dsa_lib.c @@ -60,7 +60,7 @@ #include <stdio.h> #include "internal/cryptlib.h" #include <openssl/bn.h> -#include <openssl/dsa.h> +#include "dsa_locl.h" #include <openssl/asn1.h> #include <openssl/engine.h> #include <openssl/dh.h> @@ -280,3 +280,76 @@ DH *DSA_dup_DH(const DSA *r) return NULL; } #endif + +BIGNUM *DSA_get0_p(const DSA *d) +{ + return d->p; +} + +BIGNUM *DSA_get0_q(const DSA *d) +{ + return d->q; +} + +BIGNUM *DSA_get0_g(const DSA *d) +{ + return d->g; +} + +int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g) +{ + if (p == NULL || q == NULL || g == NULL) + return 0; + BN_free(d->p); + BN_free(d->q); + BN_free(d->g); + d->p = p; + d->q = q; + d->g = g; + + return 1; +} + +BIGNUM *DSA_get0_priv_key(const DSA *d) +{ + return d->priv_key; +} + +BIGNUM *DSA_get0_pub_key(const DSA *d) +{ + return d->pub_key; +} + +void DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key) +{ + /* Note that it is valid for priv_key to be NULL */ + if (pub_key == NULL) + return 0; + + BN_free(d->pub_key); + BN_free(d->priv_key); + d->pub_key = pub_key; + d->priv_key = priv_key; + + return 1; +} + +void DSA_clear_flags(DSA *d, int flags) +{ + d->flags &= ~flags; +} + +int DSA_test_flags(const DSA *d, int flags) +{ + return d->flags & flags; +} + +void DSA_set_flags(DSA *d, int flags) +{ + d->flags |= flags; +} + +ENGINE *DSA_get0_engine(DSA *d) +{ + return d->engine; +} diff --git a/crypto/dsa/dsa_locl.h b/crypto/dsa/dsa_locl.h index 6182495848..9b25634ae3 100644 --- a/crypto/dsa/dsa_locl.h +++ b/crypto/dsa/dsa_locl.h @@ -54,6 +54,29 @@ #include <openssl/dsa.h> +struct dsa_st { + /* + * This first variable is used to pick up errors where a DSA is passed + * instead of of a EVP_PKEY + */ + int pad; + long version; + BIGNUM *p; + BIGNUM *q; /* == 20 */ + BIGNUM *g; + BIGNUM *pub_key; /* y public key */ + BIGNUM *priv_key; /* x private key */ + int flags; + /* Normally used to cache montgomery values */ + BN_MONT_CTX *method_mont_p; + int references; + CRYPTO_EX_DATA ex_data; + const DSA_METHOD *meth; + /* functional reference if 'meth' is ENGINE-provided */ + ENGINE *engine; + CRYPTO_RWLOCK *lock; +}; + int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, const EVP_MD *evpmd, const unsigned char *seed_in, size_t seed_len, unsigned char *seed_out, diff --git a/crypto/dsa/dsa_ossl.c b/crypto/dsa/dsa_ossl.c index 31a6d53c9a..92855537b8 100644 --- a/crypto/dsa/dsa_ossl.c +++ b/crypto/dsa/dsa_ossl.c @@ -61,7 +61,7 @@ #include "internal/cryptlib.h" #include <openssl/bn.h> #include <openssl/sha.h> -#include <openssl/dsa.h> +#include "dsa_locl.h" #include <openssl/rand.h> #include <openssl/asn1.h> diff --git a/crypto/dsa/dsa_sign.c b/crypto/dsa/dsa_sign.c index ca712cf201..b9dcd5b28d 100644 --- a/crypto/dsa/dsa_sign.c +++ b/crypto/dsa/dsa_sign.c @@ -58,7 +58,7 @@ /* Original version from Steven Schoch <schoch@sheba.arc.nasa.gov> */ #include "internal/cryptlib.h" -#include <openssl/dsa.h> +#include "dsa_locl.h" #include <openssl/rand.h> #include <openssl/bn.h> diff --git a/crypto/dsa/dsa_vrf.c b/crypto/dsa/dsa_vrf.c index 6724b7545f..6ce9968eaf 100644 --- a/crypto/dsa/dsa_vrf.c +++ b/crypto/dsa/dsa_vrf.c @@ -58,7 +58,7 @@ /* Original version from Steven Schoch <schoch@sheba.arc.nasa.gov> */ #include "internal/cryptlib.h" -#include <openssl/dsa.h> +#include "dsa_locl.h" int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, DSA *dsa) |