xref: /aosp_15_r20/external/boringssl/src/crypto/dsa/internal.h (revision 8fb009dc861624b67b6cdb62ea21f0f22d0c584b)
1 /* Copyright (c) 2020, Google Inc.
2  *
3  * Permission to use, copy, modify, and/or distribute this software for any
4  * purpose with or without fee is hereby granted, provided that the above
5  * copyright notice and this permission notice appear in all copies.
6  *
7  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14 
15 #ifndef OPENSSL_HEADER_DSA_INTERNAL_H
16 #define OPENSSL_HEADER_DSA_INTERNAL_H
17 
18 #include <openssl/dsa.h>
19 
20 #include <openssl/thread.h>
21 
22 #include "../internal.h"
23 
24 #if defined(__cplusplus)
25 extern "C" {
26 #endif
27 
28 
29 struct dsa_st {
30   BIGNUM *p;
31   BIGNUM *q;
32   BIGNUM *g;
33 
34   BIGNUM *pub_key;
35   BIGNUM *priv_key;
36 
37   // Normally used to cache montgomery values
38   CRYPTO_MUTEX method_mont_lock;
39   BN_MONT_CTX *method_mont_p;
40   BN_MONT_CTX *method_mont_q;
41   CRYPTO_refcount_t references;
42   CRYPTO_EX_DATA ex_data;
43 };
44 
45 #define OPENSSL_DSA_MAX_MODULUS_BITS 10000
46 
47 // dsa_check_key performs cheap self-checks on |dsa|, and ensures it is within
48 // DoS bounds. It returns one on success and zero on error.
49 int dsa_check_key(const DSA *dsa);
50 
51 
52 #if defined(__cplusplus)
53 }  // extern C
54 #endif
55 
56 #endif  // OPENSSL_HEADER_DSA_INTERNAL_H
57