xref: /OK3568_Linux_fs/kernel/lib/crypto/curve25519.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0 OR MIT
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * This is an implementation of the Curve25519 ECDH algorithm, using either
6*4882a593Smuzhiyun  * a 32-bit implementation or a 64-bit implementation with 128-bit integers,
7*4882a593Smuzhiyun  * depending on what is supported by the target compiler.
8*4882a593Smuzhiyun  *
9*4882a593Smuzhiyun  * Information: https://cr.yp.to/ecdh.html
10*4882a593Smuzhiyun  */
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun #include <crypto/curve25519.h>
13*4882a593Smuzhiyun #include <linux/module.h>
14*4882a593Smuzhiyun #include <linux/init.h>
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun bool curve25519_selftest(void);
17*4882a593Smuzhiyun 
mod_init(void)18*4882a593Smuzhiyun static int __init mod_init(void)
19*4882a593Smuzhiyun {
20*4882a593Smuzhiyun 	if (!IS_ENABLED(CONFIG_CRYPTO_MANAGER_DISABLE_TESTS) &&
21*4882a593Smuzhiyun 	    WARN_ON(!curve25519_selftest()))
22*4882a593Smuzhiyun 		return -ENODEV;
23*4882a593Smuzhiyun 	return 0;
24*4882a593Smuzhiyun }
25*4882a593Smuzhiyun 
mod_exit(void)26*4882a593Smuzhiyun static void __exit mod_exit(void)
27*4882a593Smuzhiyun {
28*4882a593Smuzhiyun }
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun module_init(mod_init);
31*4882a593Smuzhiyun module_exit(mod_exit);
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun MODULE_LICENSE("GPL v2");
34*4882a593Smuzhiyun MODULE_DESCRIPTION("Curve25519 scalar multiplication");
35*4882a593Smuzhiyun MODULE_AUTHOR("Jason A. Donenfeld <Jason@zx2c4.com>");
36