summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/dsa/dsa.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/dsa/dsa.h')
-rw-r--r--src/lib/libcrypto/dsa/dsa.h69
1 files changed, 43 insertions, 26 deletions
diff --git a/src/lib/libcrypto/dsa/dsa.h b/src/lib/libcrypto/dsa/dsa.h
index ac50a5c846..702c50d6dc 100644
--- a/src/lib/libcrypto/dsa/dsa.h
+++ b/src/lib/libcrypto/dsa/dsa.h
@@ -88,6 +88,8 @@
88# define OPENSSL_DSA_MAX_MODULUS_BITS 10000 88# define OPENSSL_DSA_MAX_MODULUS_BITS 10000
89#endif 89#endif
90 90
91#define OPENSSL_DSA_FIPS_MIN_MODULUS_BITS 1024
92
91#define DSA_FLAG_CACHE_MONT_P 0x01 93#define DSA_FLAG_CACHE_MONT_P 0x01
92#define DSA_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DSA 94#define DSA_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DSA
93 * implementation now uses constant time 95 * implementation now uses constant time
@@ -97,6 +99,25 @@
97 * be used for all exponents. 99 * be used for all exponents.
98 */ 100 */
99 101
102/* If this flag is set the DSA method is FIPS compliant and can be used
103 * in FIPS mode. This is set in the validated module method. If an
104 * application sets this flag in its own methods it is its reposibility
105 * to ensure the result is compliant.
106 */
107
108#define DSA_FLAG_FIPS_METHOD 0x0400
109
110/* If this flag is set the operations normally disabled in FIPS mode are
111 * permitted it is then the applications responsibility to ensure that the
112 * usage is compliant.
113 */
114
115#define DSA_FLAG_NON_FIPS_ALLOW 0x0400
116
117#ifdef OPENSSL_FIPS
118#define FIPS_DSA_SIZE_T int
119#endif
120
100#ifdef __cplusplus 121#ifdef __cplusplus
101extern "C" { 122extern "C" {
102#endif 123#endif
@@ -118,7 +139,7 @@ struct dsa_method
118 int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, 139 int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
119 BIGNUM **rp); 140 BIGNUM **rp);
120 int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len, 141 int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len,
121 DSA_SIG *sig, DSA *dsa); 142 DSA_SIG *sig, DSA *dsa);
122 int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, 143 int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
123 BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx, 144 BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx,
124 BN_MONT_CTX *in_mont); 145 BN_MONT_CTX *in_mont);
@@ -131,7 +152,7 @@ struct dsa_method
131 char *app_data; 152 char *app_data;
132 /* If this is non-NULL, it is used to generate DSA parameters */ 153 /* If this is non-NULL, it is used to generate DSA parameters */
133 int (*dsa_paramgen)(DSA *dsa, int bits, 154 int (*dsa_paramgen)(DSA *dsa, int bits,
134 const unsigned char *seed, int seed_len, 155 unsigned char *seed, int seed_len,
135 int *counter_ret, unsigned long *h_ret, 156 int *counter_ret, unsigned long *h_ret,
136 BN_GENCB *cb); 157 BN_GENCB *cb);
137 /* If this is non-NULL, it is used to generate DSA keys */ 158 /* If this is non-NULL, it is used to generate DSA keys */
@@ -165,6 +186,7 @@ struct dsa_st
165 ENGINE *engine; 186 ENGINE *engine;
166 }; 187 };
167 188
189#define DSAparams_dup(x) ASN1_dup_of_const(DSA,i2d_DSAparams,d2i_DSAparams,x)
168#define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \ 190#define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \
169 (char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x)) 191 (char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x))
170#define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \ 192#define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \
@@ -173,7 +195,6 @@ struct dsa_st
173#define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x) 195#define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x)
174 196
175 197
176DSA *DSAparams_dup(DSA *x);
177DSA_SIG * DSA_SIG_new(void); 198DSA_SIG * DSA_SIG_new(void);
178void DSA_SIG_free(DSA_SIG *a); 199void DSA_SIG_free(DSA_SIG *a);
179int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp); 200int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);
@@ -189,6 +210,11 @@ void DSA_set_default_method(const DSA_METHOD *);
189const DSA_METHOD *DSA_get_default_method(void); 210const DSA_METHOD *DSA_get_default_method(void);
190int DSA_set_method(DSA *dsa, const DSA_METHOD *); 211int DSA_set_method(DSA *dsa, const DSA_METHOD *);
191 212
213#ifdef OPENSSL_FIPS
214DSA * FIPS_dsa_new(void);
215void FIPS_dsa_free (DSA *r);
216#endif
217
192DSA * DSA_new(void); 218DSA * DSA_new(void);
193DSA * DSA_new_method(ENGINE *engine); 219DSA * DSA_new_method(ENGINE *engine);
194void DSA_free (DSA *r); 220void DSA_free (DSA *r);
@@ -220,7 +246,7 @@ DSA * DSA_generate_parameters(int bits,
220 246
221/* New version */ 247/* New version */
222int DSA_generate_parameters_ex(DSA *dsa, int bits, 248int DSA_generate_parameters_ex(DSA *dsa, int bits,
223 const unsigned char *seed,int seed_len, 249 unsigned char *seed,int seed_len,
224 int *counter_ret, unsigned long *h_ret, BN_GENCB *cb); 250 int *counter_ret, unsigned long *h_ret, BN_GENCB *cb);
225 251
226int DSA_generate_key(DSA *a); 252int DSA_generate_key(DSA *a);
@@ -249,13 +275,10 @@ int DSA_print_fp(FILE *bp, const DSA *x, int off);
249DH *DSA_dup_DH(const DSA *r); 275DH *DSA_dup_DH(const DSA *r);
250#endif 276#endif
251 277
252#define EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, nbits) \ 278#ifdef OPENSSL_FIPS
253 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \ 279int FIPS_dsa_sig_encode(unsigned char *out, DSA_SIG *sig);
254 EVP_PKEY_CTRL_DSA_PARAMGEN_BITS, nbits, NULL) 280int FIPS_dsa_sig_decode(DSA_SIG *sig, const unsigned char *in, int inlen);
255 281#endif
256#define EVP_PKEY_CTRL_DSA_PARAMGEN_BITS (EVP_PKEY_ALG_CTRL + 1)
257#define EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS (EVP_PKEY_ALG_CTRL + 2)
258#define EVP_PKEY_CTRL_DSA_PARAMGEN_MD (EVP_PKEY_ALG_CTRL + 3)
259 282
260/* BEGIN ERROR CODES */ 283/* BEGIN ERROR CODES */
261/* The following lines are auto generated by the script mkerr.pl. Any changes 284/* The following lines are auto generated by the script mkerr.pl. Any changes
@@ -267,39 +290,33 @@ void ERR_load_DSA_strings(void);
267 290
268/* Function codes. */ 291/* Function codes. */
269#define DSA_F_D2I_DSA_SIG 110 292#define DSA_F_D2I_DSA_SIG 110
270#define DSA_F_DO_DSA_PRINT 104
271#define DSA_F_DSAPARAMS_PRINT 100 293#define DSA_F_DSAPARAMS_PRINT 100
272#define DSA_F_DSAPARAMS_PRINT_FP 101 294#define DSA_F_DSAPARAMS_PRINT_FP 101
295#define DSA_F_DSA_BUILTIN_KEYGEN 119
296#define DSA_F_DSA_BUILTIN_PARAMGEN 118
273#define DSA_F_DSA_DO_SIGN 112 297#define DSA_F_DSA_DO_SIGN 112
274#define DSA_F_DSA_DO_VERIFY 113 298#define DSA_F_DSA_DO_VERIFY 113
299#define DSA_F_DSA_GENERATE_PARAMETERS 117
275#define DSA_F_DSA_NEW_METHOD 103 300#define DSA_F_DSA_NEW_METHOD 103
276#define DSA_F_DSA_PARAM_DECODE 119 301#define DSA_F_DSA_PRINT 104
277#define DSA_F_DSA_PRINT_FP 105 302#define DSA_F_DSA_PRINT_FP 105
278#define DSA_F_DSA_PRIV_DECODE 115 303#define DSA_F_DSA_SET_DEFAULT_METHOD 115
279#define DSA_F_DSA_PRIV_ENCODE 116 304#define DSA_F_DSA_SET_METHOD 116
280#define DSA_F_DSA_PUB_DECODE 117
281#define DSA_F_DSA_PUB_ENCODE 118
282#define DSA_F_DSA_SIGN 106 305#define DSA_F_DSA_SIGN 106
283#define DSA_F_DSA_SIGN_SETUP 107 306#define DSA_F_DSA_SIGN_SETUP 107
284#define DSA_F_DSA_SIG_NEW 109 307#define DSA_F_DSA_SIG_NEW 109
285#define DSA_F_DSA_VERIFY 108 308#define DSA_F_DSA_VERIFY 108
286#define DSA_F_I2D_DSA_SIG 111 309#define DSA_F_I2D_DSA_SIG 111
287#define DSA_F_OLD_DSA_PRIV_DECODE 122
288#define DSA_F_PKEY_DSA_CTRL 120
289#define DSA_F_PKEY_DSA_KEYGEN 121
290#define DSA_F_SIG_CB 114 310#define DSA_F_SIG_CB 114
291 311
292/* Reason codes. */ 312/* Reason codes. */
293#define DSA_R_BAD_Q_VALUE 102 313#define DSA_R_BAD_Q_VALUE 102
294#define DSA_R_BN_DECODE_ERROR 108
295#define DSA_R_BN_ERROR 109
296#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100 314#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100
297#define DSA_R_DECODE_ERROR 104 315#define DSA_R_KEY_SIZE_TOO_SMALL 106
298#define DSA_R_INVALID_DIGEST_TYPE 106
299#define DSA_R_MISSING_PARAMETERS 101 316#define DSA_R_MISSING_PARAMETERS 101
300#define DSA_R_MODULUS_TOO_LARGE 103 317#define DSA_R_MODULUS_TOO_LARGE 103
301#define DSA_R_NO_PARAMETERS_SET 107 318#define DSA_R_NON_FIPS_METHOD 104
302#define DSA_R_PARAMETER_ENCODING_ERROR 105 319#define DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE 105
303 320
304#ifdef __cplusplus 321#ifdef __cplusplus
305} 322}