2019-06-13 00:19:53 +08:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
2022-07-26 02:36:34 +08:00
|
|
|
obj-$(CONFIG_CRYPTO_LIB_UTILS) += libcryptoutils.o
|
2022-07-26 02:36:35 +08:00
|
|
|
libcryptoutils-y := memneq.o utils.o
|
2022-07-26 02:36:34 +08:00
|
|
|
|
2019-11-08 20:22:08 +08:00
|
|
|
# chacha is used by the /dev/random driver which is always builtin
|
|
|
|
obj-y += chacha.o
|
|
|
|
obj-$(CONFIG_CRYPTO_LIB_CHACHA_GENERIC) += libchacha.o
|
|
|
|
|
2019-11-08 20:22:07 +08:00
|
|
|
obj-$(CONFIG_CRYPTO_LIB_AES) += libaes.o
|
|
|
|
libaes-y := aes.o
|
2019-07-03 03:41:22 +08:00
|
|
|
|
crypto: lib/aesgcm - Provide minimal library implementation
Implement a minimal library version of AES-GCM based on the existing
library implementations of AES and multiplication in GF(2^128). Using
these primitives, GCM can be implemented in a straight-forward manner.
GCM has a couple of sharp edges, i.e., the amount of input data
processed with the same initialization vector (IV) should be capped to
protect the counter from 32-bit rollover (or carry), and the size of the
authentication tag should be fixed for a given key. [0]
The former concern is addressed trivially, given that the function call
API uses 32-bit signed types for the input lengths. It is still up to
the caller to avoid IV reuse in general, but this is not something we
can police at the implementation level.
As for the latter concern, let's make the authentication tag size part
of the key schedule, and only permit it to be configured as part of the
key expansion routine.
Note that table based AES implementations are susceptible to known
plaintext timing attacks on the encryption key. The AES library already
attempts to mitigate this to some extent, but given that the counter
mode encryption used by GCM operates exclusively on known plaintext by
construction (the IV and therefore the initial counter value are known
to an attacker), let's take some extra care to mitigate this, by calling
the AES library with interrupts disabled.
[0] https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpublication800-38d.pdf
Link: https://lore.kernel.org/all/c6fb9b25-a4b6-2e4a-2dd1-63adda055a49@amd.com/
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Nikunj A Dadhania <nikunj@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2022-11-04 03:22:59 +08:00
|
|
|
obj-$(CONFIG_CRYPTO_LIB_AESGCM) += libaesgcm.o
|
|
|
|
libaesgcm-y := aesgcm.o
|
|
|
|
|
2019-11-08 20:22:07 +08:00
|
|
|
obj-$(CONFIG_CRYPTO_LIB_ARC4) += libarc4.o
|
|
|
|
libarc4-y := arc4.o
|
2019-08-15 17:01:09 +08:00
|
|
|
|
2022-11-04 03:22:57 +08:00
|
|
|
obj-$(CONFIG_CRYPTO_LIB_GF128MUL) += gf128mul.o
|
|
|
|
|
2021-12-22 21:56:58 +08:00
|
|
|
# blake2s is used by the /dev/random driver which is always builtin
|
|
|
|
obj-y += libblake2s.o
|
|
|
|
libblake2s-y := blake2s.o
|
|
|
|
libblake2s-$(CONFIG_CRYPTO_LIB_BLAKE2S_GENERIC) += blake2s-generic.o
|
2019-11-08 20:22:28 +08:00
|
|
|
|
2019-11-08 20:22:39 +08:00
|
|
|
obj-$(CONFIG_CRYPTO_LIB_CHACHA20POLY1305) += libchacha20poly1305.o
|
|
|
|
libchacha20poly1305-y += chacha20poly1305.o
|
|
|
|
|
2020-01-08 12:37:35 +08:00
|
|
|
obj-$(CONFIG_CRYPTO_LIB_CURVE25519_GENERIC) += libcurve25519-generic.o
|
|
|
|
libcurve25519-generic-y := curve25519-fiat32.o
|
|
|
|
libcurve25519-generic-$(CONFIG_ARCH_SUPPORTS_INT128) := curve25519-hacl64.o
|
|
|
|
libcurve25519-generic-y += curve25519-generic.o
|
|
|
|
|
|
|
|
obj-$(CONFIG_CRYPTO_LIB_CURVE25519) += libcurve25519.o
|
2019-11-08 20:22:32 +08:00
|
|
|
libcurve25519-y += curve25519.o
|
|
|
|
|
2019-11-08 20:22:07 +08:00
|
|
|
obj-$(CONFIG_CRYPTO_LIB_DES) += libdes.o
|
|
|
|
libdes-y := des.o
|
2019-08-17 22:24:33 +08:00
|
|
|
|
2019-11-08 20:22:19 +08:00
|
|
|
obj-$(CONFIG_CRYPTO_LIB_POLY1305_GENERIC) += libpoly1305.o
|
crypto: poly1305 - add new 32 and 64-bit generic versions
These two C implementations from Zinc -- a 32x32 one and a 64x64 one,
depending on the platform -- come from Andrew Moon's public domain
poly1305-donna portable code, modified for usage in the kernel. The
precomputation in the 32-bit version and the use of 64x64 multiplies in
the 64-bit version make these perform better than the code it replaces.
Moon's code is also very widespread and has received many eyeballs of
scrutiny.
There's a bit of interference between the x86 implementation, which
relies on internal details of the old scalar implementation. In the next
commit, the x86 implementation will be replaced with a faster one that
doesn't rely on this, so none of this matters much. But for now, to keep
this passing the tests, we inline the bits of the old implementation
that the x86 implementation relied on. Also, since we now support a
slightly larger key space, via the union, some offsets had to be fixed
up.
Nonce calculation was folded in with the emit function, to take
advantage of 64x64 arithmetic. However, Adiantum appeared to rely on no
nonce handling in emit, so this path was conditionalized. We also
introduced a new struct, poly1305_core_key, to represent the precise
amount of space that particular implementation uses.
Testing with kbench9000, depending on the CPU, the update function for
the 32x32 version has been improved by 4%-7%, and for the 64x64 by
19%-30%. The 32x32 gains are small, but I think there's great value in
having a parallel implementation to the 64x64 one so that the two can be
compared side-by-side as nice stand-alone units.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-01-06 11:40:46 +08:00
|
|
|
libpoly1305-y := poly1305-donna32.o
|
|
|
|
libpoly1305-$(CONFIG_ARCH_SUPPORTS_INT128) := poly1305-donna64.o
|
|
|
|
libpoly1305-y += poly1305.o
|
2019-11-08 20:22:19 +08:00
|
|
|
|
2022-07-10 05:18:49 +08:00
|
|
|
obj-$(CONFIG_CRYPTO_LIB_SHA1) += libsha1.o
|
|
|
|
libsha1-y := sha1.o
|
2022-07-10 05:18:48 +08:00
|
|
|
|
2019-11-08 20:22:07 +08:00
|
|
|
obj-$(CONFIG_CRYPTO_LIB_SHA256) += libsha256.o
|
|
|
|
libsha256-y := sha256.o
|
2019-11-08 20:22:28 +08:00
|
|
|
|
|
|
|
ifneq ($(CONFIG_CRYPTO_MANAGER_DISABLE_TESTS),y)
|
|
|
|
libblake2s-y += blake2s-selftest.o
|
2019-11-08 20:22:39 +08:00
|
|
|
libchacha20poly1305-y += chacha20poly1305-selftest.o
|
2019-12-17 02:53:26 +08:00
|
|
|
libcurve25519-y += curve25519-selftest.o
|
2019-11-08 20:22:28 +08:00
|
|
|
endif
|