linux/arch/x86/crypto/curve25519-x86_64.c

// SPDX-License-Identifier: GPL-2.0 OR MIT
/*
 * Copyright (C) 2020 Jason A. Donenfeld <[email protected]>. All Rights Reserved.
 * Copyright (c) 2016-2020 INRIA, CMU and Microsoft Corporation
 */

#include <crypto/curve25519.h>
#include <crypto/internal/kpp.h>

#include <linux/types.h>
#include <linux/jump_label.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/scatterlist.h>

#include <asm/cpufeature.h>
#include <asm/processor.h>

static __always_inline u64 eq_mask(u64 a, u64 b)
{}

static __always_inline u64 gte_mask(u64 a, u64 b)
{}

/* Computes the addition of four-element f1 with value in f2
 * and returns the carry (if any) */
static inline u64 add_scalar(u64 *out, const u64 *f1, u64 f2)
{}

/* Computes the field addition of two field elements */
static inline void fadd(u64 *out, const u64 *f1, const u64 *f2)
{}

/* Computes the field subtraction of two field elements */
static inline void fsub(u64 *out, const u64 *f1, const u64 *f2)
{}

/* Computes a field multiplication: out <- f1 * f2
 * Uses the 8-element buffer tmp for intermediate results */
static inline void fmul(u64 *out, const u64 *f1, const u64 *f2, u64 *tmp)
{}

/* Computes two field multiplications:
 *   out[0] <- f1[0] * f2[0]
 *   out[1] <- f1[1] * f2[1]
 * Uses the 16-element buffer tmp for intermediate results: */
static inline void fmul2(u64 *out, const u64 *f1, const u64 *f2, u64 *tmp)
{}

/* Computes the field multiplication of four-element f1 with value in f2
 * Requires f2 to be smaller than 2^17 */
static inline void fmul_scalar(u64 *out, const u64 *f1, u64 f2)
{}

/* Computes p1 <- bit ? p2 : p1 in constant time */
static inline void cswap2(u64 bit, const u64 *p1, const u64 *p2)
{}

/* Computes the square of a field element: out <- f * f
 * Uses the 8-element buffer tmp for intermediate results */
static inline void fsqr(u64 *out, const u64 *f, u64 *tmp)
{}

/* Computes two field squarings:
 *   out[0] <- f[0] * f[0]
 *   out[1] <- f[1] * f[1]
 * Uses the 16-element buffer tmp for intermediate results */
static inline void fsqr2(u64 *out, const u64 *f, u64 *tmp)
{}

static void point_add_and_double(u64 *q, u64 *p01_tmp1, u64 *tmp2)
{}

static void point_double(u64 *nq, u64 *tmp1, u64 *tmp2)
{}

static void montgomery_ladder(u64 *out, const u8 *key, u64 *init1)
{}

static void fsquare_times(u64 *o, const u64 *inp, u64 *tmp, u32 n1)
{}

static void finv(u64 *o, const u64 *i, u64 *tmp)
{}

static void store_felem(u64 *b, u64 *f)
{}

static void encode_point(u8 *o, const u64 *i)
{}

static void curve25519_ever64(u8 *out, const u8 *priv, const u8 *pub)
{}

/* The below constants were generated using this sage script:
 *
 * #!/usr/bin/env sage
 * import sys
 * from sage.all import *
 * def limbs(n):
 * 	n = int(n)
 * 	l = ((n >> 0) % 2^64, (n >> 64) % 2^64, (n >> 128) % 2^64, (n >> 192) % 2^64)
 * 	return "0x%016xULL, 0x%016xULL, 0x%016xULL, 0x%016xULL" % l
 * ec = EllipticCurve(GF(2^255 - 19), [0, 486662, 0, 1, 0])
 * p_minus_s = (ec.lift_x(9) - ec.lift_x(1))[0]
 * print("static const u64 p_minus_s[] = { %s };\n" % limbs(p_minus_s))
 * print("static const u64 table_ladder[] = {")
 * p = ec.lift_x(9)
 * for i in range(252):
 * 	l = (p[0] + p[2]) / (p[0] - p[2])
 * 	print(("\t%s" + ("," if i != 251 else "")) % limbs(l))
 * 	p = p * 2
 * print("};")
 *
 */

static const u64 p_minus_s[] =;

static const u64 table_ladder[] =;

static void curve25519_ever64_base(u8 *out, const u8 *priv)
{}

static __ro_after_init DEFINE_STATIC_KEY_FALSE(curve25519_use_bmi2_adx);

void curve25519_arch(u8 mypublic[CURVE25519_KEY_SIZE],
		     const u8 secret[CURVE25519_KEY_SIZE],
		     const u8 basepoint[CURVE25519_KEY_SIZE])
{}
EXPORT_SYMBOL();

void curve25519_base_arch(u8 pub[CURVE25519_KEY_SIZE],
			  const u8 secret[CURVE25519_KEY_SIZE])
{}
EXPORT_SYMBOL();

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

static int curve25519_generate_public_key(struct kpp_request *req)
{}

static int curve25519_compute_shared_secret(struct kpp_request *req)
{}

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

static struct kpp_alg curve25519_alg =;


static int __init curve25519_mod_init(void)
{}

static void __exit curve25519_mod_exit(void)
{}

module_init();
module_exit(curve25519_mod_exit);

MODULE_ALIAS_CRYPTO();
MODULE_ALIAS_CRYPTO();
MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_AUTHOR();