From 1c41d8bb1303a036c2c16abe416fdb7628f75c3d Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Thu, 22 Feb 2007 14:35:24 +0000 Subject: [PATCH] No assembler AES with shared libraries (code doesn't support PIC). --- lib/silccrypt/Makefile.ad | 15 ------------ lib/silccrypt/aes.c | 8 +++---- lib/silccrypt/aes_x86.asm | 48 -------------------------------------- lib/silccrypt/configure.ad | 14 +++++++---- 4 files changed, 14 insertions(+), 71 deletions(-) diff --git a/lib/silccrypt/Makefile.ad b/lib/silccrypt/Makefile.ad index 7f369d09..766ea169 100644 --- a/lib/silccrypt/Makefile.ad +++ b/lib/silccrypt/Makefile.ad @@ -60,27 +60,12 @@ CFLAGS = $(LTFLAGS) @SILC_CRYPTO_CFLAGS@ #ifdef SILC_DIST_TOOLKIT include_HEADERS = \ - aes.h \ - blowfish.h \ - cast.h \ - ciphers_def.h \ - ciphers.h \ - md5.h \ - none.h \ - rc5.h \ - rsa.h \ - sha1.h \ - sha1_internal.h \ - sha256.h \ - sha256_internal.h \ silccipher.h \ - silcdh.h \ silchash.h \ silchmac.h \ silcpkcs.h \ silcrng.h \ silcpkcs1.h \ - twofish.h \ silcpk.h SILC_EXTRA_DIST = tests diff --git a/lib/silccrypt/aes.c b/lib/silccrypt/aes.c index 020cc552..49692129 100644 --- a/lib/silccrypt/aes.c +++ b/lib/silccrypt/aes.c @@ -218,9 +218,9 @@ extern "C" #define d_4(t,n,b,e,f,g,h) ALIGN const XP_DIR t n[4][256] = { b(e), b(f), b(g), b(h) } ALIGN const uint_32t t_dec(r,c)[RC_LENGTH] = rc_data(w0); -#ifdef SILC_ASM_AES +#ifdef SILC_AES_ASM d_1(uint_8t, t_dec(i,box), isb_data, h0); -#endif /* SILC_ASM_AES */ +#endif /* SILC_AES_ASM */ d_4(uint_32t, t_dec(f,n), sb_data, u0, u1, u2, u3); d_4(uint_32t, t_dec(f,l), sb_data, w0, w1, w2, w3); d_4(uint_32t, t_dec(i,n), isb_data, v0, v1, v2, v3); @@ -522,7 +522,7 @@ AES_RETURN aes_decrypt_key(const unsigned char *key, int key_len, aes_decrypt_ct } } -#ifndef SILC_ASM_AES +#ifndef SILC_AES_ASM /* C version of AES */ #define si(y,x,k,c) (s(y,c) = word_in(x, c) ^ (k)[c]) @@ -631,4 +631,4 @@ AES_RETURN aes_decrypt(const unsigned char *in, unsigned char *out, const aes_de } #endif -#endif /* SILC_ASM_AES */ +#endif /* SILC_AES_ASM */ diff --git a/lib/silccrypt/aes_x86.asm b/lib/silccrypt/aes_x86.asm index f9c34e66..cb426a12 100644 --- a/lib/silccrypt/aes_x86.asm +++ b/lib/silccrypt/aes_x86.asm @@ -219,10 +219,6 @@ stk_spc equ 20 ; stack space %define eltab_2(x) [t_fl+2048+4*x] %define eltab_3(x) [t_fl+3072+4*x] -%else - -%define etab_b(x) byte [t_fn+3072+4*x] - %endif ; ROUND FUNCTION. Build column[2] on ESI and column[3] on EDI that have the @@ -302,25 +298,6 @@ stk_spc equ 20 ; stack space mov %1,eltab_%3(%4) %endmacro -%else - - %macro lr_xor 4 - movzx %4,%2 - movzx %4,etab_b(%4) - %if %3 != 0 - shl %4,8*%3 - %endif - xor %1,%4 - %endmacro - - %macro lr_mov 4 - movzx %4,%2 - movzx %1,etab_b(%4) - %if %3 != 0 - shl %1,8*%3 - %endif - %endmacro - %endif %macro enc_round 0 @@ -442,12 +419,6 @@ stk_spc equ 20 ; stack space %define dltab_2(x) [t_il+2048+4*x] %define dltab_3(x) [t_il+3072+4*x] -%else - - extern t_ibox - -%define dtab_x(x) byte [t_ibox+x] - %endif %macro irn_fun 2 @@ -504,25 +475,6 @@ stk_spc equ 20 ; stack space mov %1,dltab_%3(%4) %endmacro -%else - - %macro li_xor 4 - movzx %4,%2 - movzx %4,dtab_x(%4) - %if %3 != 0 - shl %4,8*%3 - %endif - xor %1,%4 - %endmacro - - %macro li_mov 4 - movzx %4,%2 - movzx %1,dtab_x(%4) - %if %3 != 0 - shl %1,8*%3 - %endif - %endmacro - %endif %macro dec_round 0 diff --git a/lib/silccrypt/configure.ad b/lib/silccrypt/configure.ad index b9ccd4da..d392563f 100644 --- a/lib/silccrypt/configure.ad +++ b/lib/silccrypt/configure.ad @@ -1,9 +1,10 @@ +#ifdef SILC_DIST_CRYPTO # # lib/silccrypt/configure.ad # # Author: Pekka Riikonen # -# Copyright (C) 2006 Pekka Riikonen +# Copyright (C) 2006 - 2007 Pekka Riikonen # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,13 +24,14 @@ SILC_CRYPTO_CFLAGS= aes_asm=false case "$host_cpu" in i?86) - if test x$have_assembler = xtrue; then + # Don't enable ASM AES with shared libs as the code doesn't support PIC. + if test x$have_assembler = xtrue -a "$enable_shared" != "yes"; then aes_asm=true AC_DEFINE([SILC_AES_ASM], [], [SILC_AES_ASM]) fi ;; x86_64) - if test x$have_assembler = xtrue; then + if test x$have_assembler = xtrue -a "$enable_shared" != "yes"; then aes_asm=true AC_DEFINE([SILC_AES_ASM], [], [SILC_AES_ASM]) fi @@ -38,7 +40,6 @@ case "$host_cpu" in aes_asm=false ;; esac -AM_CONDITIONAL(SILC_AES_ASM, test x$aes_asm = xtrue) SILC_ADD_CC_FLAGS(SILC_CRYPTO, -fno-regmove) if test x$summary_debug = xno; then @@ -55,3 +56,8 @@ lib/silccrypt/tests/Makefile ) fi # compile_libs + +# AM_CONDITIONAL is so bad that it itself cannot be defined in conditional +AM_CONDITIONAL(SILC_AES_ASM, test x$aes_asm = xtrue) + +#endif SILC_DIST_CRYPTO -- 2.24.0