File indexing completed on 2025-01-18 10:05:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef OPENSSL_DSA_H
0011 # define OPENSSL_DSA_H
0012 # pragma once
0013
0014 # include <openssl/macros.h>
0015 # ifndef OPENSSL_NO_DEPRECATED_3_0
0016 # define HEADER_DSA_H
0017 # endif
0018
0019 # include <openssl/opensslconf.h>
0020 # include <openssl/types.h>
0021
0022 # include <stdlib.h>
0023
0024 # ifndef OPENSSL_NO_DSA
0025 # include <openssl/e_os2.h>
0026 # include <openssl/asn1.h>
0027 # include <openssl/bio.h>
0028 # include <openssl/crypto.h>
0029 # include <openssl/bn.h>
0030 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
0031 # include <openssl/dh.h>
0032 # endif
0033 # include <openssl/dsaerr.h>
0034 # ifndef OPENSSL_NO_STDIO
0035 # include <stdio.h>
0036 # endif
0037 # endif
0038
0039 # ifdef __cplusplus
0040 extern "C" {
0041 # endif
0042
0043 int EVP_PKEY_CTX_set_dsa_paramgen_bits(EVP_PKEY_CTX *ctx, int nbits);
0044 int EVP_PKEY_CTX_set_dsa_paramgen_q_bits(EVP_PKEY_CTX *ctx, int qbits);
0045 int EVP_PKEY_CTX_set_dsa_paramgen_md_props(EVP_PKEY_CTX *ctx,
0046 const char *md_name,
0047 const char *md_properties);
0048 int EVP_PKEY_CTX_set_dsa_paramgen_gindex(EVP_PKEY_CTX *ctx, int gindex);
0049 int EVP_PKEY_CTX_set_dsa_paramgen_type(EVP_PKEY_CTX *ctx, const char *name);
0050 int EVP_PKEY_CTX_set_dsa_paramgen_seed(EVP_PKEY_CTX *ctx,
0051 const unsigned char *seed,
0052 size_t seedlen);
0053 int EVP_PKEY_CTX_set_dsa_paramgen_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
0054
0055 # define EVP_PKEY_CTRL_DSA_PARAMGEN_BITS (EVP_PKEY_ALG_CTRL + 1)
0056 # define EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS (EVP_PKEY_ALG_CTRL + 2)
0057 # define EVP_PKEY_CTRL_DSA_PARAMGEN_MD (EVP_PKEY_ALG_CTRL + 3)
0058
0059 # ifndef OPENSSL_NO_DSA
0060 # ifndef OPENSSL_DSA_MAX_MODULUS_BITS
0061 # define OPENSSL_DSA_MAX_MODULUS_BITS 10000
0062 # endif
0063
0064 # define OPENSSL_DSA_FIPS_MIN_MODULUS_BITS 1024
0065
0066 typedef struct DSA_SIG_st DSA_SIG;
0067 DSA_SIG *DSA_SIG_new(void);
0068 void DSA_SIG_free(DSA_SIG *a);
0069 DECLARE_ASN1_ENCODE_FUNCTIONS_only(DSA_SIG, DSA_SIG)
0070 void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps);
0071 int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s);
0072
0073
0074 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
0075
0076
0077
0078 # define DSA_FLAG_NO_EXP_CONSTTIME 0x00
0079 # endif
0080
0081 # ifndef OPENSSL_NO_DEPRECATED_3_0
0082 # define DSA_FLAG_CACHE_MONT_P 0x01
0083
0084
0085
0086
0087
0088
0089
0090
0091 # define DSA_FLAG_FIPS_METHOD 0x0400
0092
0093
0094
0095
0096
0097
0098
0099 # define DSA_FLAG_NON_FIPS_ALLOW 0x0400
0100 # define DSA_FLAG_FIPS_CHECKED 0x0800
0101
0102
0103
0104
0105
0106 # define d2i_DSAparams_fp(fp, x) \
0107 (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \
0108 (char *(*)())d2i_DSAparams, (fp), \
0109 (unsigned char **)(x))
0110 # define i2d_DSAparams_fp(fp, x) \
0111 ASN1_i2d_fp(i2d_DSAparams, (fp), (unsigned char *)(x))
0112 # define d2i_DSAparams_bio(bp, x) \
0113 ASN1_d2i_bio_of(DSA, DSA_new, d2i_DSAparams, bp, x)
0114 # define i2d_DSAparams_bio(bp, x) \
0115 ASN1_i2d_bio_of(DSA, i2d_DSAparams, bp, x)
0116
0117 DECLARE_ASN1_DUP_FUNCTION_name_attr(OSSL_DEPRECATEDIN_3_0, DSA, DSAparams)
0118 OSSL_DEPRECATEDIN_3_0 DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen,
0119 DSA *dsa);
0120 OSSL_DEPRECATEDIN_3_0 int DSA_do_verify(const unsigned char *dgst, int dgst_len,
0121 DSA_SIG *sig, DSA *dsa);
0122
0123 OSSL_DEPRECATEDIN_3_0 const DSA_METHOD *DSA_OpenSSL(void);
0124
0125 OSSL_DEPRECATEDIN_3_0 void DSA_set_default_method(const DSA_METHOD *);
0126 OSSL_DEPRECATEDIN_3_0 const DSA_METHOD *DSA_get_default_method(void);
0127 OSSL_DEPRECATEDIN_3_0 int DSA_set_method(DSA *dsa, const DSA_METHOD *);
0128 OSSL_DEPRECATEDIN_3_0 const DSA_METHOD *DSA_get_method(DSA *d);
0129
0130 OSSL_DEPRECATEDIN_3_0 DSA *DSA_new(void);
0131 OSSL_DEPRECATEDIN_3_0 DSA *DSA_new_method(ENGINE *engine);
0132 OSSL_DEPRECATEDIN_3_0 void DSA_free(DSA *r);
0133
0134 OSSL_DEPRECATEDIN_3_0 int DSA_up_ref(DSA *r);
0135 OSSL_DEPRECATEDIN_3_0 int DSA_size(const DSA *);
0136 OSSL_DEPRECATEDIN_3_0 int DSA_bits(const DSA *d);
0137 OSSL_DEPRECATEDIN_3_0 int DSA_security_bits(const DSA *d);
0138
0139 OSSL_DEPRECATEDIN_3_0 int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in,
0140 BIGNUM **kinvp, BIGNUM **rp);
0141 OSSL_DEPRECATEDIN_3_0 int DSA_sign(int type, const unsigned char *dgst,
0142 int dlen, unsigned char *sig,
0143 unsigned int *siglen, DSA *dsa);
0144 OSSL_DEPRECATEDIN_3_0 int DSA_verify(int type, const unsigned char *dgst,
0145 int dgst_len, const unsigned char *sigbuf,
0146 int siglen, DSA *dsa);
0147
0148 # define DSA_get_ex_new_index(l, p, newf, dupf, freef) \
0149 CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DSA, l, p, newf, dupf, freef)
0150 OSSL_DEPRECATEDIN_3_0 int DSA_set_ex_data(DSA *d, int idx, void *arg);
0151 OSSL_DEPRECATEDIN_3_0 void *DSA_get_ex_data(const DSA *d, int idx);
0152
0153 DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0,
0154 DSA, DSAPublicKey)
0155 DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0,
0156 DSA, DSAPrivateKey)
0157 DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0,
0158 DSA, DSAparams)
0159 # endif
0160
0161 # ifndef OPENSSL_NO_DEPRECATED_0_9_8
0162
0163 OSSL_DEPRECATEDIN_0_9_8
0164 DSA *DSA_generate_parameters(int bits, unsigned char *seed, int seed_len,
0165 int *counter_ret, unsigned long *h_ret,
0166 void (*callback) (int, int, void *),
0167 void *cb_arg);
0168 # endif
0169
0170 # ifndef OPENSSL_NO_DEPRECATED_3_0
0171
0172 OSSL_DEPRECATEDIN_3_0 int DSA_generate_parameters_ex(DSA *dsa, int bits,
0173 const unsigned char *seed,
0174 int seed_len,
0175 int *counter_ret,
0176 unsigned long *h_ret,
0177 BN_GENCB *cb);
0178
0179 OSSL_DEPRECATEDIN_3_0 int DSA_generate_key(DSA *a);
0180
0181 OSSL_DEPRECATEDIN_3_0 int DSAparams_print(BIO *bp, const DSA *x);
0182 OSSL_DEPRECATEDIN_3_0 int DSA_print(BIO *bp, const DSA *x, int off);
0183 # ifndef OPENSSL_NO_STDIO
0184 OSSL_DEPRECATEDIN_3_0 int DSAparams_print_fp(FILE *fp, const DSA *x);
0185 OSSL_DEPRECATEDIN_3_0 int DSA_print_fp(FILE *bp, const DSA *x, int off);
0186 # endif
0187
0188 # define DSS_prime_checks 64
0189
0190
0191
0192
0193
0194
0195 # define DSA_is_prime(n, callback, cb_arg) \
0196 BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg)
0197
0198 # ifndef OPENSSL_NO_DH
0199
0200
0201
0202
0203 OSSL_DEPRECATEDIN_3_0 DH *DSA_dup_DH(const DSA *r);
0204 # endif
0205
0206 OSSL_DEPRECATEDIN_3_0 void DSA_get0_pqg(const DSA *d, const BIGNUM **p,
0207 const BIGNUM **q, const BIGNUM **g);
0208 OSSL_DEPRECATEDIN_3_0 int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g);
0209 OSSL_DEPRECATEDIN_3_0 void DSA_get0_key(const DSA *d, const BIGNUM **pub_key,
0210 const BIGNUM **priv_key);
0211 OSSL_DEPRECATEDIN_3_0 int DSA_set0_key(DSA *d, BIGNUM *pub_key,
0212 BIGNUM *priv_key);
0213 OSSL_DEPRECATEDIN_3_0 const BIGNUM *DSA_get0_p(const DSA *d);
0214 OSSL_DEPRECATEDIN_3_0 const BIGNUM *DSA_get0_q(const DSA *d);
0215 OSSL_DEPRECATEDIN_3_0 const BIGNUM *DSA_get0_g(const DSA *d);
0216 OSSL_DEPRECATEDIN_3_0 const BIGNUM *DSA_get0_pub_key(const DSA *d);
0217 OSSL_DEPRECATEDIN_3_0 const BIGNUM *DSA_get0_priv_key(const DSA *d);
0218 OSSL_DEPRECATEDIN_3_0 void DSA_clear_flags(DSA *d, int flags);
0219 OSSL_DEPRECATEDIN_3_0 int DSA_test_flags(const DSA *d, int flags);
0220 OSSL_DEPRECATEDIN_3_0 void DSA_set_flags(DSA *d, int flags);
0221 OSSL_DEPRECATEDIN_3_0 ENGINE *DSA_get0_engine(DSA *d);
0222
0223 OSSL_DEPRECATEDIN_3_0 DSA_METHOD *DSA_meth_new(const char *name, int flags);
0224 OSSL_DEPRECATEDIN_3_0 void DSA_meth_free(DSA_METHOD *dsam);
0225 OSSL_DEPRECATEDIN_3_0 DSA_METHOD *DSA_meth_dup(const DSA_METHOD *dsam);
0226 OSSL_DEPRECATEDIN_3_0 const char *DSA_meth_get0_name(const DSA_METHOD *dsam);
0227 OSSL_DEPRECATEDIN_3_0 int DSA_meth_set1_name(DSA_METHOD *dsam,
0228 const char *name);
0229 OSSL_DEPRECATEDIN_3_0 int DSA_meth_get_flags(const DSA_METHOD *dsam);
0230 OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_flags(DSA_METHOD *dsam, int flags);
0231 OSSL_DEPRECATEDIN_3_0 void *DSA_meth_get0_app_data(const DSA_METHOD *dsam);
0232 OSSL_DEPRECATEDIN_3_0 int DSA_meth_set0_app_data(DSA_METHOD *dsam,
0233 void *app_data);
0234 OSSL_DEPRECATEDIN_3_0 DSA_SIG *(*DSA_meth_get_sign(const DSA_METHOD *dsam))
0235 (const unsigned char *, int, DSA *);
0236 OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_sign(DSA_METHOD *dsam,
0237 DSA_SIG *(*sign) (const unsigned char *, int, DSA *));
0238 OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_sign_setup(const DSA_METHOD *dsam))
0239 (DSA *, BN_CTX *, BIGNUM **, BIGNUM **);
0240 OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_sign_setup(DSA_METHOD *dsam,
0241 int (*sign_setup) (DSA *, BN_CTX *, BIGNUM **, BIGNUM **));
0242 OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_verify(const DSA_METHOD *dsam))
0243 (const unsigned char *, int, DSA_SIG *, DSA *);
0244 OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_verify(DSA_METHOD *dsam,
0245 int (*verify) (const unsigned char *, int, DSA_SIG *, DSA *));
0246 OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_mod_exp(const DSA_METHOD *dsam))
0247 (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *,
0248 const BIGNUM *, const BIGNUM *, BN_CTX *, BN_MONT_CTX *);
0249 OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_mod_exp(DSA_METHOD *dsam,
0250 int (*mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *,
0251 const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *,
0252 BN_MONT_CTX *));
0253 OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_bn_mod_exp(const DSA_METHOD *dsam))
0254 (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *,
0255 BN_CTX *, BN_MONT_CTX *);
0256 OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_bn_mod_exp(DSA_METHOD *dsam,
0257 int (*bn_mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *,
0258 const BIGNUM *, BN_CTX *, BN_MONT_CTX *));
0259 OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_init(const DSA_METHOD *dsam))(DSA *);
0260 OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_init(DSA_METHOD *dsam,
0261 int (*init)(DSA *));
0262 OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_finish(const DSA_METHOD *dsam))(DSA *);
0263 OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_finish(DSA_METHOD *dsam,
0264 int (*finish)(DSA *));
0265 OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_paramgen(const DSA_METHOD *dsam))
0266 (DSA *, int, const unsigned char *, int, int *, unsigned long *,
0267 BN_GENCB *);
0268 OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_paramgen(DSA_METHOD *dsam,
0269 int (*paramgen) (DSA *, int, const unsigned char *, int, int *,
0270 unsigned long *, BN_GENCB *));
0271 OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_keygen(const DSA_METHOD *dsam))(DSA *);
0272 OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_keygen(DSA_METHOD *dsam,
0273 int (*keygen) (DSA *));
0274
0275 # endif
0276 # endif
0277 # ifdef __cplusplus
0278 }
0279 # endif
0280 #endif