No assembler AES with shared libraries (code doesn't support PIC).
authorPekka Riikonen <priikone@silcnet.org>
Thu, 22 Feb 2007 14:35:24 +0000 (14:35 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Thu, 22 Feb 2007 14:35:24 +0000 (14:35 +0000)
lib/silccrypt/Makefile.ad
lib/silccrypt/aes.c
lib/silccrypt/aes_x86.asm
lib/silccrypt/configure.ad

index 7f369d09d21c9047ec8c68ccb21cd68cbfa2e9d3..766ea169a1292a572f640aec8ea36d482a3e5345 100644 (file)
@@ -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
index 020cc552d2484627afec92abe07d87e832c182c1..49692129d0cc55e857a838688c0c89ac0f745b8d 100644 (file)
@@ -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 */
index f9c34e6623065ac52b66c44790202ca3f4ca2004..cb426a12e8cab2abb512606d33b7ded928512cae 100644 (file)
@@ -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
index b9ccd4dadb01ee9bc548c765c4514dcd7f2d3bba..d392563f8acab0ce26d89e35d3885b158240758c 100644 (file)
@@ -1,9 +1,10 @@
+#ifdef SILC_DIST_CRYPTO
 #
 #  lib/silccrypt/configure.ad
 #
 #  Author: Pekka Riikonen <priikone@silcnet.org>
 #
-#  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