]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/dh/dh_local.h
Rename FIPS_MODE to FIPS_MODULE
[thirdparty/openssl.git] / crypto / dh / dh_local.h
CommitLineData
0aeddcfa 1/*
dc8de3e6 2 * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
0aeddcfa 3 *
e38873f5 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
aa6bb135
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
0aeddcfa 7 * https://www.openssl.org/source/license.html
0aeddcfa
MC
8 */
9
10#include <openssl/dh.h>
2f545ae4 11#include "internal/refcount.h"
dc8de3e6 12#include "internal/ffc.h"
0aeddcfa 13
6de1fe90
BE
14#define DH_MIN_MODULUS_BITS 512
15
0aeddcfa
MC
16struct dh_st {
17 /*
18 * This first argument is used to pick up errors when a DH is passed
19 * instead of a EVP_PKEY
20 */
21 int pad;
22 int version;
dc8de3e6 23 FFC_PARAMS params;
738ee181
SL
24 /* max generated private key length (can be less than len(q)) */
25 int32_t length;
0aeddcfa
MC
26 BIGNUM *pub_key; /* g^x % p */
27 BIGNUM *priv_key; /* x */
28 int flags;
29 BN_MONT_CTX *method_mont_p;
2f545ae4 30 CRYPTO_REF_COUNT references;
f844f9eb 31#ifndef FIPS_MODULE
0aeddcfa 32 CRYPTO_EX_DATA ex_data;
62f49b90 33 ENGINE *engine;
a3327784 34#endif
8083fd3a 35 OPENSSL_CTX *libctx;
0aeddcfa 36 const DH_METHOD *meth;
0aeddcfa 37 CRYPTO_RWLOCK *lock;
8b84b075
RL
38
39 /* Provider data */
40 size_t dirty_cnt; /* If any key material changes, increment this */
0aeddcfa 41};
17e01abb
MC
42
43struct dh_method {
44 char *name;
45 /* Methods here */
46 int (*generate_key) (DH *dh);
47 int (*compute_key) (unsigned char *key, const BIGNUM *pub_key, DH *dh);
0263b992 48
17e01abb
MC
49 /* Can be null */
50 int (*bn_mod_exp) (const DH *dh, BIGNUM *r, const BIGNUM *a,
51 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
52 BN_MONT_CTX *m_ctx);
53 int (*init) (DH *dh);
54 int (*finish) (DH *dh);
55 int flags;
56 char *app_data;
57 /* If this is non-NULL, it will be used to generate parameters */
58 int (*generate_params) (DH *dh, int prime_len, int generator,
59 BN_GENCB *cb);
60};
9aaecbfc 61
62int dh_buf2key(DH *key, const unsigned char *buf, size_t len);
63size_t dh_key2buf(const DH *dh, unsigned char **pbuf);