]>
Commit | Line | Data |
---|---|---|
d2e9e320 RS |
1 | /* |
2 | * Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. | |
357d5de5 | 3 | * |
3cdbea65 | 4 | * Licensed under the Apache License 2.0 (the "License"). You may not use |
d2e9e320 RS |
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 | |
357d5de5 NL |
8 | */ |
9 | ||
10 | #include <openssl/dsa.h> | |
2f545ae4 | 11 | #include "internal/refcount.h" |
357d5de5 | 12 | |
1258396d MC |
13 | struct dsa_st { |
14 | /* | |
15 | * This first variable is used to pick up errors where a DSA is passed | |
16 | * instead of of a EVP_PKEY | |
17 | */ | |
18 | int pad; | |
6a32a3c0 | 19 | int32_t version; |
1258396d MC |
20 | BIGNUM *p; |
21 | BIGNUM *q; /* == 20 */ | |
22 | BIGNUM *g; | |
23 | BIGNUM *pub_key; /* y public key */ | |
24 | BIGNUM *priv_key; /* x private key */ | |
25 | int flags; | |
26 | /* Normally used to cache montgomery values */ | |
27 | BN_MONT_CTX *method_mont_p; | |
2f545ae4 | 28 | CRYPTO_REF_COUNT references; |
a3327784 | 29 | #ifndef FIPS_MODE |
1258396d | 30 | CRYPTO_EX_DATA ex_data; |
a3327784 | 31 | #endif |
1258396d MC |
32 | const DSA_METHOD *meth; |
33 | /* functional reference if 'meth' is ENGINE-provided */ | |
34 | ENGINE *engine; | |
35 | CRYPTO_RWLOCK *lock; | |
4889dadc MC |
36 | |
37 | /* Provider data */ | |
38 | size_t dirty_cnt; /* If any key material changes, increment this */ | |
1258396d MC |
39 | }; |
40 | ||
9267c11b EK |
41 | struct DSA_SIG_st { |
42 | BIGNUM *r; | |
43 | BIGNUM *s; | |
44 | }; | |
45 | ||
6e9fa57c MC |
46 | struct dsa_method { |
47 | char *name; | |
48 | DSA_SIG *(*dsa_do_sign) (const unsigned char *dgst, int dlen, DSA *dsa); | |
49 | int (*dsa_sign_setup) (DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, | |
50 | BIGNUM **rp); | |
51 | int (*dsa_do_verify) (const unsigned char *dgst, int dgst_len, | |
52 | DSA_SIG *sig, DSA *dsa); | |
24bf6f3c BL |
53 | int (*dsa_mod_exp) (DSA *dsa, BIGNUM *rr, const BIGNUM *a1, |
54 | const BIGNUM *p1, const BIGNUM *a2, const BIGNUM *p2, | |
55 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont); | |
6e9fa57c | 56 | /* Can be null */ |
24bf6f3c | 57 | int (*bn_mod_exp) (DSA *dsa, BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
6e9fa57c MC |
58 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); |
59 | int (*init) (DSA *dsa); | |
60 | int (*finish) (DSA *dsa); | |
61 | int flags; | |
62 | void *app_data; | |
63 | /* If this is non-NULL, it is used to generate DSA parameters */ | |
64 | int (*dsa_paramgen) (DSA *dsa, int bits, | |
65 | const unsigned char *seed, int seed_len, | |
66 | int *counter_ret, unsigned long *h_ret, | |
67 | BN_GENCB *cb); | |
68 | /* If this is non-NULL, it is used to generate DSA keys */ | |
69 | int (*dsa_keygen) (DSA *dsa); | |
70 | }; | |
71 | ||
357d5de5 | 72 | int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, |
0f113f3e MC |
73 | const EVP_MD *evpmd, const unsigned char *seed_in, |
74 | size_t seed_len, unsigned char *seed_out, | |
75 | int *counter_ret, unsigned long *h_ret, | |
76 | BN_GENCB *cb); | |
3dd9b31d | 77 | |
f55f5f77 | 78 | int dsa_builtin_paramgen2(DSA *ret, size_t L, size_t N, |
0f113f3e MC |
79 | const EVP_MD *evpmd, const unsigned char *seed_in, |
80 | size_t seed_len, int idx, unsigned char *seed_out, | |
81 | int *counter_ret, unsigned long *h_ret, | |
82 | BN_GENCB *cb); | |
e683582b SL |
83 | |
84 | DSA_SIG *dsa_do_sign_int(OPENSSL_CTX *libctx, const unsigned char *dgst, | |
85 | int dlen, DSA *dsa); |