summaryrefslogtreecommitdiffstats
path: root/crypto/dsa/dsa_lib.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2016-03-30 15:21:39 +0100
committerMatt Caswell <matt@openssl.org>2016-04-03 00:23:56 +0100
commit1258396d73cf937e4daaf2c35377011b9366f956 (patch)
tree6448183bf775904be79b29786795ade508f7fe4d /crypto/dsa/dsa_lib.c
parent25c78440d21c814705e0e50c6e567300936aa02b (diff)
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/dsa_lib.c')
-rw-r--r--crypto/dsa/dsa_lib.c75
1 files changed, 74 insertions, 1 deletions
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;
+}