[PATCH] twofish: add ARMv6 assembly implementation

Dmitry Eremin-Solenikov dbaryshkov at gmail.com
Mon Oct 21 17:35:53 CEST 2013


On Mon, Oct 21, 2013 at 5:21 PM, Jussi Kivilinna <jussi.kivilinna at iki.fi> wrote:
> * cipher/Makefile.am: Add 'twofish-armv6.S'.
> * cipher/twofish-armv6.S: New.
> * cipher/twofish.c (USE_ARMV6_ASM): New macro.
> [USE_ARMV6_ASM] (_gcry_twofish_armv6_encrypt_block)
> (_gcry_twofish_armv6_decrypt_block): New prototypes.
> [USE_AMDV6_ASM] (twofish_encrypt, twofish_decrypt): Add.
> [USE_AMD64_ASM] (do_twofish_encrypt, do_twofish_decrypt): Remove.
> (_gcry_twofish_ctr_enc, _gcry_twofish_cfb_dec): Use 'twofish_encrypt'
> instead of 'do_twofish_encrypt'.
> (_gcry_twofish_cbc_dec): Use 'twofish_decrypt' instead of
> 'do_twofish_decrypt'.
> * configure.ac [arm]: Add 'twofish-armv6.lo'.

Some time ago I have looked into adapting asm optimizations to earlier
ARM cores.
The main problem was rev instruction, which I conditionally replaced
with 4 insns.
My current code is present at
https://github.com/GostCrypt/libgcrypt/commits/arm-opt .

The main remaining issue is HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS test
in configure.ac. It is too restrictive. E.g. it fails if gcc is
configured to default to armv4te.
Also it has .thumb directive, however all assembler files are compiled
in arm mode.
If I comment out add.w and ,thumb/.code16 lines, I can build code even for armv4
(no thumb), qemu-verified. Code built for armv4t/armv5te successfully
verified on armv5te
core (XScale). Would you have any suggestions on improving/adapting
this configure test?

With best wishes

More information about the Gcrypt-devel mailing list