mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
UPSTREAM: crypto: lib/curve25519 - re-add selftests
Somehow these were dropped when Zinc was being integrated, which is problematic, because testing the library interface for Curve25519 is important.. This commit simply adds them back and wires them in in the same way that the blake2s selftests are wired in. Signed-off-by: Jason A. Donenfeld <[email protected]> Signed-off-by: Herbert Xu <[email protected]> (cherry picked from commit aa127963f1cab2b93c74c9b128a84610203fb674) Bug: 152722841 Signed-off-by: Jason A. Donenfeld <[email protected]> Change-Id: I5752b6c918f00969b7b0b161903071ce7c910ad1 Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
parent
cfac8b1cae
commit
2419413f54
3 changed files with 1339 additions and 0 deletions
|
|
@ -35,4 +35,5 @@ libsha256-y := sha256.o
|
|||
ifneq ($(CONFIG_CRYPTO_MANAGER_DISABLE_TESTS),y)
|
||||
libblake2s-y += blake2s-selftest.o
|
||||
libchacha20poly1305-y += chacha20poly1305-selftest.o
|
||||
libcurve25519-y += curve25519-selftest.o
|
||||
endif
|
||||
|
|
|
|||
1321
lib/crypto/curve25519-selftest.c
Normal file
1321
lib/crypto/curve25519-selftest.c
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -13,6 +13,8 @@
|
|||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
|
||||
bool curve25519_selftest(void);
|
||||
|
||||
const u8 curve25519_null_point[CURVE25519_KEY_SIZE] __aligned(32) = { 0 };
|
||||
const u8 curve25519_base_point[CURVE25519_KEY_SIZE] __aligned(32) = { 9 };
|
||||
|
||||
|
|
@ -20,6 +22,21 @@ EXPORT_SYMBOL(curve25519_null_point);
|
|||
EXPORT_SYMBOL(curve25519_base_point);
|
||||
EXPORT_SYMBOL(curve25519_generic);
|
||||
|
||||
static int __init mod_init(void)
|
||||
{
|
||||
if (!IS_ENABLED(CONFIG_CRYPTO_MANAGER_DISABLE_TESTS) &&
|
||||
WARN_ON(!curve25519_selftest()))
|
||||
return -ENODEV;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit mod_exit(void)
|
||||
{
|
||||
}
|
||||
|
||||
module_init(mod_init);
|
||||
module_exit(mod_exit);
|
||||
|
||||
MODULE_LICENSE("GPL v2");
|
||||
MODULE_DESCRIPTION("Curve25519 scalar multiplication");
|
||||
MODULE_AUTHOR("Jason A. Donenfeld <[email protected]>");
|
||||
|
|
|
|||
Loading…
Reference in a new issue