Debian Codegraph @

debian/rust-vendor/aws-lc-sys/aws-lc/crypto/fipsmodule/dh/internal.h

raw
1 // Copyright (c) 2022, Google Inc.
2 // SPDX-License-Identifier: ISC
3
4 #ifndef OPENSSL_HEADER_CRYPTO_FIPSMODULE_DH_INTERNAL_H
5 #define OPENSSL_HEADER_CRYPTO_FIPSMODULE_DH_INTERNAL_H
6
7 #include <openssl/base.h>
8
9 #include <openssl/thread.h>
10
11 #if defined(__cplusplus)
12 extern "C" {
13 #endif
14
15
16 #define OPENSSL_DH_MAX_MODULUS_BITS 10000
17
18 struct dh_st {
19 BIGNUM *p;
20 BIGNUM *g;
21 BIGNUM *q;
22 BIGNUM *pub_key; // g^x mod p
23 BIGNUM *priv_key; // x
24
25 // priv_length contains the length, in bits, of the private value. If zero,
26 // the private value will be the same length as |p|.
27 unsigned priv_length;
28
29 CRYPTO_MUTEX method_mont_p_lock;
30 BN_MONT_CTX *method_mont_p;
31
32 int flags;
33 CRYPTO_refcount_t references;
34 };
35
36 // dh_check_params_fast checks basic invariants on |dh|'s domain parameters. It
37 // does not check that |dh| forms a valid group, only that the sizes are within
38 // DoS bounds.
39 int dh_check_params_fast(const DH *dh);
40
41 // dh_compute_key_padded_no_self_test does the same as |DH_compute_key_padded|,
42 // but doesn't try to run the self-test first. This is for use in the self tests
43 // themselves, to prevent an infinite loop.
44 int dh_compute_key_padded_no_self_test(unsigned char *out,
45 const BIGNUM *peers_key, DH *dh);
46
47 // DH_get_rfc7919_3072 returns the group `ffdhe3072` from
48 // https://tools.ietf.org/html/rfc7919#appendix-A.2. It returns NULL if out
49 // of memory.
50 OPENSSL_EXPORT DH *DH_get_rfc7919_3072(void);
51
52 // DH_get_rfc7919_8192 returns the group `ffdhe8192` from
53 // https://tools.ietf.org/html/rfc7919#appendix-A.4. It returns NULL if out
54 // of memory.
55 OPENSSL_EXPORT DH *DH_get_rfc7919_8192(void);
56
57 #if defined(__cplusplus)
58 }
59 #endif
60
61 #endif // OPENSSL_HEADER_CRYPTO_FIPSMODULE_DH_INTERNAL_H