test/recipes/30-test_evp.t: Fix multiple definition of @bffiles
[openssl.git] / crypto / dsa / dsa_local.h
1 /*
2  * Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License 2.0 (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9
10 #include <openssl/dsa.h>
11 #include "internal/refcount.h"
12 #include "internal/ffc.h"
13
14 struct dsa_st {
15     /*
16      * This first variable is used to pick up errors where a DSA is passed
17      * instead of of a EVP_PKEY
18      */
19     int pad;
20     int32_t version;
21     FFC_PARAMS params;
22     BIGNUM *pub_key;            /* y public key */
23     BIGNUM *priv_key;           /* x private key */
24     int flags;
25     /* Normally used to cache montgomery values */
26     BN_MONT_CTX *method_mont_p;
27     CRYPTO_REF_COUNT references;
28 #ifndef FIPS_MODE
29     CRYPTO_EX_DATA ex_data;
30 #endif
31     const DSA_METHOD *meth;
32     /* functional reference if 'meth' is ENGINE-provided */
33     ENGINE *engine;
34     CRYPTO_RWLOCK *lock;
35
36     /* Provider data */
37     size_t dirty_cnt; /* If any key material changes, increment this */
38 };
39
40 struct DSA_SIG_st {
41     BIGNUM *r;
42     BIGNUM *s;
43 };
44
45 struct dsa_method {
46     char *name;
47     DSA_SIG *(*dsa_do_sign) (const unsigned char *dgst, int dlen, DSA *dsa);
48     int (*dsa_sign_setup) (DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
49                            BIGNUM **rp);
50     int (*dsa_do_verify) (const unsigned char *dgst, int dgst_len,
51                           DSA_SIG *sig, DSA *dsa);
52     int (*dsa_mod_exp) (DSA *dsa, BIGNUM *rr, const BIGNUM *a1,
53                         const BIGNUM *p1, const BIGNUM *a2, const BIGNUM *p2,
54                         const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont);
55     /* Can be null */
56     int (*bn_mod_exp) (DSA *dsa, BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
57                        const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
58     int (*init) (DSA *dsa);
59     int (*finish) (DSA *dsa);
60     int flags;
61     void *app_data;
62     /* If this is non-NULL, it is used to generate DSA parameters */
63     int (*dsa_paramgen) (DSA *dsa, int bits,
64                          const unsigned char *seed, int seed_len,
65                          int *counter_ret, unsigned long *h_ret,
66                          BN_GENCB *cb);
67     /* If this is non-NULL, it is used to generate DSA keys */
68     int (*dsa_keygen) (DSA *dsa);
69 };
70
71 int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits,
72                          const EVP_MD *evpmd, const unsigned char *seed_in,
73                          size_t seed_len, unsigned char *seed_out,
74                          int *counter_ret, unsigned long *h_ret,
75                          BN_GENCB *cb);
76
77 int dsa_builtin_paramgen2(DSA *ret, size_t L, size_t N,
78                           const EVP_MD *evpmd, const unsigned char *seed_in,
79                           size_t seed_len, int idx, unsigned char *seed_out,
80                           int *counter_ret, unsigned long *h_ret,
81                           BN_GENCB *cb);
82
83 DSA_SIG *dsa_do_sign_int(OPENSSL_CTX *libctx, const unsigned char *dgst,
84                          int dlen, DSA *dsa);