Skip to contentSkip to conversation

lib/crypto: powerpc/poly1305: Remove BROKEN implementation

PATCH In review Eric Biggers 2 participants 3 messages Oct 29

Subsystems (2)
lore
Share & tools
lore

Eric Biggers

author maintainer
#0 lore raw

PATCH 1/1 lib/crypto: powerpc/poly1305: Remove BROKEN implementation

The PowerPC implementation of Poly1305 has been marked as BROKEN for well over a year, since commit bc8169003b41 ("crypto: powerpc/poly1305 - add depends on BROKEN for now"). So, it's not being built or used.

The justification for marking it BROKEN was that it didn't work in softirq context. That still fully applies.

However, it turns out the assembly file actually also contains logic bugs that make it compute incorrect Poly1305 values in some cases. This is shown by it failing the test case test_poly1305_split_update_carry (if "depends on BROKEN" is removed). The cause of that appears to be a lost carry bit in Carry_reduction. However, there also appears to be a bug in do_final_update where it incorrectly assumes v6 is fully reduced.

In addition, poly1305_emit_64 contains a secret-dependent branch.

Let's just drop this code. A fixed version can be reconsidered later.

---
 lib/crypto/Kconfig                     |    6 +-
 lib/crypto/Makefile                    |    2 -
 lib/crypto/powerpc/poly1305-p10le_64.S | 1076 ------------------------
 lib/crypto/powerpc/poly1305.h          |   76 --
 4 files changed, 1 insertion(+), 1159 deletions(-)
 delete mode 100644 lib/crypto/powerpc/poly1305-p10le_64.S
 delete mode 100644 lib/crypto/powerpc/poly1305.h
lib/crypto/Kconfig +1 -5
index 56f308dd02731..778a8b5f0c922 100644
@@ -197,8 +197,6 @@ config CRYPTO_LIB_POLY1305_ARCH
 	default y if ARM
 	default y if ARM64
 	default y if MIPS
-	# The PPC64 code needs to be fixed to work in softirq context.
-	default y if PPC64 && CPU_LITTLE_ENDIAN && VSX && BROKEN
 	default y if RISCV
 	default y if X86_64
 
@@ -209,9 +207,7 @@ config CRYPTO_LIB_POLY1305_ARCH
 config CRYPTO_LIB_POLY1305_GENERIC
 	bool
 	depends on CRYPTO_LIB_POLY1305
-	# Enable if there's no arch impl or the arch impl requires the generic
-	# impl as a fallback.  (Or if selected explicitly.)
-	default y if !CRYPTO_LIB_POLY1305_ARCH || PPC64
+	default y if !CRYPTO_LIB_POLY1305_ARCH
 
 config CRYPTO_LIB_POLY1305_RSIZE
 	int
lib/crypto/Makefile +0 -2
index 832d170cab941..126e72419ebbf 100644
@@ -256,8 +256,6 @@ $(obj)/mips/poly1305-core.S: $(src)/mips/poly1305-mips.pl FORCE
 targets += mips/poly1305-core.S
 endif
 
-libpoly1305-$(CONFIG_PPC) += powerpc/poly1305-p10le_64.o
-
 ifeq ($(CONFIG_RISCV),y)
 libpoly1305-y += riscv/poly1305-core.o
 poly1305-perlasm-flavour-$(CONFIG_32BIT) := 32
lib/crypto/powerpc/poly1305-p10le_64.S deleted +0 -1076

1,076 lines not on this page · raw message

lib/crypto/powerpc/poly1305.h deleted +0 -76

76 lines not on this page · raw message

base-commit: c339f4010dea8b0d754f84ace70cd1b089878ef8

Signature · 1 line
2.56.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Eric Biggers

The PowerPC implementation of Poly1305 has been marked as BROKEN for well over a year, since commit bc8169003b41 ("crypto: powerpc/poly1305 - add depends on BROKEN for now"). So, it's not being built or used.

The justification for marking it BROKEN was that it didn't work in softirq context. That still fully applies.

However, it turns out the assembly file actually also contains logic bugs that make it compute incorrect Poly1305 values in some cases. This is shown by it failing the test case test_poly1305_split_update_carry (if "depends on BROKEN" is removed). The cause of that appears to be a lost carry bit in Carry_reduction. However, there also appears to be a bug in do_final_update where it incorrectly assumes v6 is fully reduced.

In addition, poly1305_emit_64 contains a secret-dependent branch.

Let's just drop this code. A fixed version can be reconsidered later.

Quoted 9 lines
---
 lib/crypto/Kconfig                     |    6 +-
 lib/crypto/Makefile                    |    2 -
 lib/crypto/powerpc/poly1305-p10le_64.S | 1076 ------------------------
 lib/crypto/powerpc/poly1305.h          |   76 --
 4 files changed, 1 insertion(+), 1159 deletions(-)
 delete mode 100644 lib/crypto/powerpc/poly1305-p10le_64.S
 delete mode 100644 lib/crypto/powerpc/poly1305.h
author maintainer Applied
#2 lore raw
Quoted 30 lines · Ard Biesheuvel
Quoted 19 lines · Eric Biggers

The PowerPC implementation of Poly1305 has been marked as BROKEN for well over a year, since commit bc8169003b41 ("crypto: powerpc/poly1305 - add depends on BROKEN for now"). So, it's not being built or used.

The justification for marking it BROKEN was that it didn't work in softirq context. That still fully applies.

However, it turns out the assembly file actually also contains logic bugs that make it compute incorrect Poly1305 values in some cases. This is shown by it failing the test case test_poly1305_split_update_carry (if "depends on BROKEN" is removed). The cause of that appears to be a lost carry bit in Carry_reduction. However, there also appears to be a bug in do_final_update where it incorrectly assumes v6 is fully reduced.

In addition, poly1305_emit_64 contains a secret-dependent branch.

Let's just drop this code. A fixed version can be reconsidered later.

Quoted 9 lines
---
 lib/crypto/Kconfig                     |    6 +-
 lib/crypto/Makefile                    |    2 -
 lib/crypto/powerpc/poly1305-p10le_64.S | 1076 ------------------------
 lib/crypto/powerpc/poly1305.h          |   76 --
 4 files changed, 1 insertion(+), 1159 deletions(-)
 delete mode 100644 lib/crypto/powerpc/poly1305-p10le_64.S
 delete mode 100644 lib/crypto/powerpc/poly1305.h
Quoted 1 line

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=libcrypto-fixes

- Eric