summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2022-01-14 08:27:23 +0000
committertb <>2022-01-14 08:27:23 +0000
commit96b331528b7ab48983a3d8cb43fcf82cd8f322c3 (patch)
tree71161a354db4333f0f856767582e36e074e5c501 /src
parent3412d1fdfdf8698f7e998e555ec4ce73e1d6559f (diff)
downloadopenbsd-96b331528b7ab48983a3d8cb43fcf82cd8f322c3.tar.gz
openbsd-96b331528b7ab48983a3d8cb43fcf82cd8f322c3.tar.bz2
openbsd-96b331528b7ab48983a3d8cb43fcf82cd8f322c3.zip
Make DSA opaque
This moves DSA_SIG, DSA and DSA_METHOD to dsa_locl.h. ok inoguchi jsing
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/dsa/dsa.h66
-rw-r--r--src/lib/libcrypto/dsa/dsa_locl.h56
2 files changed, 57 insertions, 65 deletions
diff --git a/src/lib/libcrypto/dsa/dsa.h b/src/lib/libcrypto/dsa/dsa.h
index b0220856cc..4fafce382d 100644
--- a/src/lib/libcrypto/dsa/dsa.h
+++ b/src/lib/libcrypto/dsa/dsa.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa.h,v 1.34 2022/01/14 07:49:49 tb Exp $ */ 1/* $OpenBSD: dsa.h,v 1.35 2022/01/14 08:27:23 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -109,69 +109,7 @@
109extern "C" { 109extern "C" {
110#endif 110#endif
111 111
112/* Already defined in ossl_typ.h */ 112typedef struct DSA_SIG_st DSA_SIG;
113/* typedef struct dsa_st DSA; */
114/* typedef struct dsa_method DSA_METHOD; */
115
116typedef struct DSA_SIG_st
117 {
118 BIGNUM *r;
119 BIGNUM *s;
120 } DSA_SIG;
121
122struct dsa_method
123 {
124 const char *name;
125 DSA_SIG * (*dsa_do_sign)(const unsigned char *dgst, int dlen, DSA *dsa);
126 int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
127 BIGNUM **rp);
128 int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len,
129 DSA_SIG *sig, DSA *dsa);
130 int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
131 BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx,
132 BN_MONT_CTX *in_mont);
133 int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
134 const BIGNUM *m, BN_CTX *ctx,
135 BN_MONT_CTX *m_ctx); /* Can be null */
136 int (*init)(DSA *dsa);
137 int (*finish)(DSA *dsa);
138 int flags;
139 char *app_data;
140 /* If this is non-NULL, it is used to generate DSA parameters */
141 int (*dsa_paramgen)(DSA *dsa, int bits,
142 const unsigned char *seed, int seed_len,
143 int *counter_ret, unsigned long *h_ret,
144 BN_GENCB *cb);
145 /* If this is non-NULL, it is used to generate DSA keys */
146 int (*dsa_keygen)(DSA *dsa);
147 };
148
149struct dsa_st
150 {
151 /* This first variable is used to pick up errors where
152 * a DSA is passed instead of of a EVP_PKEY */
153 int pad;
154 long version;
155 int write_params;
156 BIGNUM *p;
157 BIGNUM *q; /* == 20 */
158 BIGNUM *g;
159
160 BIGNUM *pub_key; /* y public key */
161 BIGNUM *priv_key; /* x private key */
162
163 BIGNUM *kinv; /* Signing pre-calc */
164 BIGNUM *r; /* Signing pre-calc */
165
166 int flags;
167 /* Normally used to cache montgomery values */
168 BN_MONT_CTX *method_mont_p;
169 int references;
170 CRYPTO_EX_DATA ex_data;
171 const DSA_METHOD *meth;
172 /* functional reference if 'meth' is ENGINE-provided */
173 ENGINE *engine;
174 };
175 113
176DSA *d2i_DSAparams_bio(BIO *bp, DSA **a); 114DSA *d2i_DSAparams_bio(BIO *bp, DSA **a);
177int i2d_DSAparams_bio(BIO *bp, DSA *a); 115int i2d_DSAparams_bio(BIO *bp, DSA *a);
diff --git a/src/lib/libcrypto/dsa/dsa_locl.h b/src/lib/libcrypto/dsa/dsa_locl.h
index cdb38e036b..29a3901dc7 100644
--- a/src/lib/libcrypto/dsa/dsa_locl.h
+++ b/src/lib/libcrypto/dsa/dsa_locl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa_locl.h,v 1.3 2016/12/21 15:49:29 jsing Exp $ */ 1/* $OpenBSD: dsa_locl.h,v 1.4 2022/01/14 08:27:23 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 2007 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2007 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -57,6 +57,60 @@
57 57
58__BEGIN_HIDDEN_DECLS 58__BEGIN_HIDDEN_DECLS
59 59
60struct DSA_SIG_st {
61 BIGNUM *r;
62 BIGNUM *s;
63} /* DSA_SIG */;
64
65struct dsa_method {
66 const char *name;
67 DSA_SIG *(*dsa_do_sign)(const unsigned char *dgst, int dlen, DSA *dsa);
68 int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
69 BIGNUM **rp);
70 int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len,
71 DSA_SIG *sig, DSA *dsa);
72 int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
73 BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx,
74 BN_MONT_CTX *in_mont);
75 int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
76 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); /* Can be null */
77 int (*init)(DSA *dsa);
78 int (*finish)(DSA *dsa);
79 int flags;
80 char *app_data;
81 /* If this is non-NULL, it is used to generate DSA parameters */
82 int (*dsa_paramgen)(DSA *dsa, int bits, const unsigned char *seed,
83 int seed_len, int *counter_ret, unsigned long *h_ret, BN_GENCB *cb);
84 /* If this is non-NULL, it is used to generate DSA keys */
85 int (*dsa_keygen)(DSA *dsa);
86} /* DSA_METHOD */;
87
88struct dsa_st {
89 /* This first variable is used to pick up errors where
90 * a DSA is passed instead of of a EVP_PKEY */
91 int pad;
92 long version;
93 int write_params;
94 BIGNUM *p;
95 BIGNUM *q; /* == 20 */
96 BIGNUM *g;
97
98 BIGNUM *pub_key; /* y public key */
99 BIGNUM *priv_key; /* x private key */
100
101 BIGNUM *kinv; /* Signing pre-calc */
102 BIGNUM *r; /* Signing pre-calc */
103
104 int flags;
105 /* Normally used to cache montgomery values */
106 BN_MONT_CTX *method_mont_p;
107 int references;
108 CRYPTO_EX_DATA ex_data;
109 const DSA_METHOD *meth;
110 /* functional reference if 'meth' is ENGINE-provided */
111 ENGINE *engine;
112} /* DSA */;
113
60int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, 114int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits,
61 const EVP_MD *evpmd, const unsigned char *seed_in, size_t seed_len, 115 const EVP_MD *evpmd, const unsigned char *seed_in, size_t seed_len,
62 unsigned char *seed_out, 116 unsigned char *seed_out,