linux/crypto/dh.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*  Diffie-Hellman Key Agreement Method [RFC2631]
 *
 * Copyright (c) 2016, Intel Corporation
 * Authors: Salvatore Benedetto <[email protected]>
 */

#include <linux/fips.h>
#include <linux/module.h>
#include <crypto/internal/kpp.h>
#include <crypto/kpp.h>
#include <crypto/dh.h>
#include <crypto/rng.h>
#include <linux/mpi.h>

struct dh_ctx {};

static void dh_clear_ctx(struct dh_ctx *ctx)
{}

/*
 * If base is g we compute the public key
 *	ya = g^xa mod p; [RFC2631 sec 2.1.1]
 * else if base if the counterpart public key we compute the shared secret
 *	ZZ = yb^xa mod p; [RFC2631 sec 2.1.1]
 */
static int _compute_val(const struct dh_ctx *ctx, MPI base, MPI val)
{}

static inline struct dh_ctx *dh_get_ctx(struct crypto_kpp *tfm)
{}

static int dh_check_params_length(unsigned int p_len)
{}

static int dh_set_params(struct dh_ctx *ctx, struct dh *params)
{}

static int dh_set_secret(struct crypto_kpp *tfm, const void *buf,
			 unsigned int len)
{}

/*
 * SP800-56A public key verification:
 *
 * * For the safe-prime groups in FIPS mode, Q can be computed
 *   trivially from P and a full validation according to SP800-56A
 *   section 5.6.2.3.1 is performed.
 *
 * * For all other sets of group parameters, only a partial validation
 *   according to SP800-56A section 5.6.2.3.2 is performed.
 */
static int dh_is_pubkey_valid(struct dh_ctx *ctx, MPI y)
{}

static int dh_compute_value(struct kpp_request *req)
{}

static unsigned int dh_max_size(struct crypto_kpp *tfm)
{}

static void dh_exit_tfm(struct crypto_kpp *tfm)
{}

static struct kpp_alg dh =;


struct dh_safe_prime {};

static const char safe_prime_g[]  =;

struct dh_safe_prime_instance_ctx {};

struct dh_safe_prime_tfm_ctx {};

static void dh_safe_prime_free_instance(struct kpp_instance *inst)
{}

static inline struct dh_safe_prime_instance_ctx *dh_safe_prime_instance_ctx(
	struct crypto_kpp *tfm)
{}

static int dh_safe_prime_init_tfm(struct crypto_kpp *tfm)
{}

static void dh_safe_prime_exit_tfm(struct crypto_kpp *tfm)
{}

static u64 __add_u64_to_be(__be64 *dst, unsigned int n, u64 val)
{}

static void *dh_safe_prime_gen_privkey(const struct dh_safe_prime *safe_prime,
				       unsigned int *key_size)
{}

static int dh_safe_prime_set_secret(struct crypto_kpp *tfm, const void *buffer,
				    unsigned int len)
{}

static void dh_safe_prime_complete_req(void *data, int err)
{}

static struct kpp_request *dh_safe_prime_prepare_dh_req(struct kpp_request *req)
{}

static int dh_safe_prime_generate_public_key(struct kpp_request *req)
{}

static int dh_safe_prime_compute_shared_secret(struct kpp_request *req)
{}

static unsigned int dh_safe_prime_max_size(struct crypto_kpp *tfm)
{}

static int __maybe_unused __dh_safe_prime_create(
	struct crypto_template *tmpl, struct rtattr **tb,
	const struct dh_safe_prime *safe_prime)
{}

#ifdef CONFIG_CRYPTO_DH_RFC7919_GROUPS

static const struct dh_safe_prime ffdhe2048_prime =;

static const struct dh_safe_prime ffdhe3072_prime =;

static const struct dh_safe_prime ffdhe4096_prime =;

static const struct dh_safe_prime ffdhe6144_prime =;

static const struct dh_safe_prime ffdhe8192_prime =;

static int dh_ffdhe2048_create(struct crypto_template *tmpl,
			       struct rtattr **tb)
{}

static int dh_ffdhe3072_create(struct crypto_template *tmpl,
			       struct rtattr **tb)
{}

static int dh_ffdhe4096_create(struct crypto_template *tmpl,
			       struct rtattr **tb)
{}

static int dh_ffdhe6144_create(struct crypto_template *tmpl,
			       struct rtattr **tb)
{}

static int dh_ffdhe8192_create(struct crypto_template *tmpl,
			       struct rtattr **tb)
{}

static struct crypto_template crypto_ffdhe_templates[] =;

#else /* ! CONFIG_CRYPTO_DH_RFC7919_GROUPS */

static struct crypto_template crypto_ffdhe_templates[] = {};

#endif /* CONFIG_CRYPTO_DH_RFC7919_GROUPS */


static int __init dh_init(void)
{}

static void __exit dh_exit(void)
{}

subsys_initcall(dh_init);
module_exit(dh_exit);
MODULE_ALIAS_CRYPTO();
MODULE_LICENSE();
MODULE_DESCRIPTION();