2 * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
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
10 #include <openssl/dh.h>
11 #include "internal/refcount.h"
12 #include "internal/ffc.h"
14 #define DH_MIN_MODULUS_BITS 512
18 * This first argument is used to pick up errors when a DH is passed
19 * instead of a EVP_PKEY
24 /* max generated private key length (can be less than len(q)) */
26 BIGNUM
*pub_key
; /* g^x % p */
27 BIGNUM
*priv_key
; /* x */
29 BN_MONT_CTX
*method_mont_p
;
30 CRYPTO_REF_COUNT references
;
32 CRYPTO_EX_DATA ex_data
;
36 const DH_METHOD
*meth
;
40 size_t dirty_cnt
; /* If any key material changes, increment this */
46 int (*generate_key
) (DH
*dh
);
47 int (*compute_key
) (unsigned char *key
, const BIGNUM
*pub_key
, DH
*dh
);
50 int (*bn_mod_exp
) (const DH
*dh
, BIGNUM
*r
, const BIGNUM
*a
,
51 const BIGNUM
*p
, const BIGNUM
*m
, BN_CTX
*ctx
,
54 int (*finish
) (DH
*dh
);
57 /* If this is non-NULL, it will be used to generate parameters */
58 int (*generate_params
) (DH
*dh
, int prime_len
, int generator
,