Message ID | 20220509191107.3556468-1-nhuck@google.com |
---|---|
Headers | show |
Series | crypto: HCTR2 support | expand |
On Mon, May 09, 2022 at 07:11:06PM +0000, Nathan Huckleberry wrote: > Add hardware accelerated version of POLYVAL for ARM64 CPUs with > Crypto Extensions support. > > This implementation is accelerated using PMULL instructions to perform > the finite field computations. For added efficiency, 8 blocks of the > message are processed simultaneously by precomputing the first 8 > powers of the key. > > Karatsuba multiplication is used instead of Schoolbook multiplication > because it was found to be slightly faster on ARM64 CPUs. Montgomery > reduction must be used instead of Barrett reduction due to the > difference in modulus between POLYVAL's field and other finite fields. > > More information on POLYVAL can be found in the HCTR2 paper: > "Length-preserving encryption with HCTR2": > https://eprint.iacr.org/2021/1441.pdf > > Signed-off-by: Nathan Huckleberry <nhuck@google.com> > Reviewed-by: Ard Biesheuvel <ardb@kernel.org> > --- > arch/arm64/crypto/Kconfig | 5 + > arch/arm64/crypto/Makefile | 3 + > arch/arm64/crypto/polyval-ce-core.S | 361 ++++++++++++++++++++++++++++ > arch/arm64/crypto/polyval-ce-glue.c | 193 +++++++++++++++ > 4 files changed, 562 insertions(+) > create mode 100644 arch/arm64/crypto/polyval-ce-core.S > create mode 100644 arch/arm64/crypto/polyval-ce-glue.c Reviewed-by: Eric Biggers <ebiggers@google.com> - Eric
On Mon, May 09, 2022 at 07:11:05PM +0000, Nathan Huckleberry wrote: > diff --git a/arch/x86/crypto/polyval-clmulni_asm.S b/arch/x86/crypto/polyval-clmulni_asm.S [...] > +/* > + * Computes the product of two 128-bit polynomials at the memory locations > + * specified by (MSG + 16*i) and (KEY_POWERS + 16*i) and XORs the components of > + * the 256-bit product into LO, MI, HI. > + * > + * Given: > + * X = [X_1 : X_0] > + * Y = [Y_1 : Y_0] > + * > + * We compute: > + * LO += X_0 * Y_0 > + * MI += (X_0 + X_1) * (Y_0 + Y_1) > + * HI += X_1 * Y_1 The above comment (changed in v7) is describing Karatsuba multiplication, but the actual code is using schoolbook multiplication. Otherwise this looks good: Reviewed-by: Eric Biggers <ebiggers@google.com> - Eric