Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: lib/poly1305 - Build main library on LIB_POLY1305 and split generic code out

Split the lib poly1305 code just as was done with sha256. Make
the main library code conditional on LIB_POLY1305 instead of
LIB_POLY1305_GENERIC.

Reported-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Fixes: 10a6d72ea355 ("crypto: lib/poly1305 - Use block-only interface")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Herbert Xu 9b9d4ef0 64745a9c

+30 -11
+6 -3
lib/crypto/Makefile
··· 40 40 obj-$(CONFIG_CRYPTO_LIB_DES) += libdes.o 41 41 libdes-y := des.o 42 42 43 - obj-$(CONFIG_CRYPTO_LIB_POLY1305_GENERIC) += libpoly1305.o 44 - libpoly1305-y := poly1305-donna32.o 45 - libpoly1305-$(CONFIG_ARCH_SUPPORTS_INT128) := poly1305-donna64.o 43 + obj-$(CONFIG_CRYPTO_LIB_POLY1305) += libpoly1305.o 46 44 libpoly1305-y += poly1305.o 45 + 46 + obj-$(CONFIG_CRYPTO_LIB_POLY1305_GENERIC) += libpoly1305-generic.o 47 + libpoly1305-generic-y := poly1305-donna32.o 48 + libpoly1305-generic-$(CONFIG_ARCH_SUPPORTS_INT128) := poly1305-donna64.o 49 + libpoly1305-generic-y += poly1305-generic.o 47 50 48 51 obj-$(CONFIG_CRYPTO_LIB_SHA1) += libsha1.o 49 52 libsha1-y := sha1.o
+24
lib/crypto/poly1305-generic.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + /* 3 + * Poly1305 authenticator algorithm, RFC7539 4 + * 5 + * Copyright (C) 2015 Martin Willi 6 + * 7 + * Based on public domain code by Andrew Moon and Daniel J. Bernstein. 8 + */ 9 + 10 + #include <crypto/internal/poly1305.h> 11 + #include <linux/kernel.h> 12 + #include <linux/module.h> 13 + 14 + void poly1305_block_init_generic(struct poly1305_block_state *desc, 15 + const u8 raw_key[POLY1305_BLOCK_SIZE]) 16 + { 17 + poly1305_core_init(&desc->h); 18 + poly1305_core_setkey(&desc->core_r, raw_key); 19 + } 20 + EXPORT_SYMBOL_GPL(poly1305_block_init_generic); 21 + 22 + MODULE_LICENSE("GPL"); 23 + MODULE_AUTHOR("Martin Willi <martin@strongswan.org>"); 24 + MODULE_DESCRIPTION("Poly1305 algorithm (generic implementation)");
-8
lib/crypto/poly1305.c
··· 14 14 #include <linux/string.h> 15 15 #include <linux/unaligned.h> 16 16 17 - void poly1305_block_init_generic(struct poly1305_block_state *desc, 18 - const u8 raw_key[POLY1305_BLOCK_SIZE]) 19 - { 20 - poly1305_core_init(&desc->h); 21 - poly1305_core_setkey(&desc->core_r, raw_key); 22 - } 23 - EXPORT_SYMBOL_GPL(poly1305_block_init_generic); 24 - 25 17 void poly1305_init(struct poly1305_desc_ctx *desc, 26 18 const u8 key[POLY1305_KEY_SIZE]) 27 19 {