Changeset 2685

Show
Ignore:
Timestamp:
02/22/08 00:22:23 (9 months ago)
Author:
ensc
Message:

added support for using libnss instead of beecrypt for vhashify's
hash calculation. libnss has bad SHA1 performance on i386, but is a)
maintained and b) gives better performance with all other hashes and
on x86_64.

I am just waiting for somebody to write the OpenSSL layer so that I
can try the padlock hardware crypto device on my C7 ;)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/NEWS

    r2604 r2685  
     1version 0.30.??? 
     2================ 
     3 
     4        - added support for using libnss instead of beecrypt for 
     5        vhashify's hash calculation.  libnss has bad SHA1 performance on 
     6        i386, but is a) maintained and b) gives better performance with 
     7        all other hashes and on x86_64. 
     8         
     9         
    110version 0.30.214 
    211================ 
  • trunk/configure.ac

    r2626 r2685  
    4343AC_PROG_LN_S 
    4444AM_PROG_CC_C_O 
     45PKG_PROG_PKG_CONFIG 
    4546ENSC_CXXCOMPILER 
    4647ENSC_C99COMPILER 
     
    312313dnl ######################## 
    313314dnl 
     315dnl {crypto stuff 
     316dnl 
     317AC_MSG_CHECKING([for used crypto API]) 
     318AC_ARG_WITH(crypto-api, 
     319            AC_HELP_STRING([--with-crypto-api=API], 
     320                           [select crypto api to be used; possible values are `none', `nss', `beecrypt', `auto' (default:auto)]), 
     321            [case $withval in 
     322                (none|nss|beecrypt|auto)        ensc_crypto_api=$withval;; 
     323                (*)     AC_MSG_ERROR([invalid initscripts value, only gentoo and sysv are supported]);; 
     324             esac],[ensc_crypto_api=auto]) 
     325AC_MSG_RESULT($ensc_crypto_api) 
     326 
     327 
     328dnl Now, check for matching crypto api. When selected 'auto', the 
     329dnl first matching one wins 
     330 
     331dnl ######################## 
     332dnl 
    314333dnl {check for beecrypt 
    315334dnl 
     335case $ensc_crypto_api in 
     336(auto|beecrypt) 
    316337if test x"$ensc_cv_c99_c99compiler" = xyes; then 
    317338        ensc_have_beecrypt=yes 
     
    326347                             [ ensc_have_beecrypt=no ]) 
    327348        fi 
    328  
    329         if test x"$ensc_have_beecrypt" != xyes; then 
    330                 AC_MSG_WARN([ 
    331 **** 
    332 **** 'beecrypt' could not be found; 
    333 **** this will disable the build of 'vhashify' 
    334 ****]) 
    335         fi 
    336349else 
    337350        ensc_have_beecrypt=no 
    338 fi 
     351fi;; 
     352esac 
     353 
     354case $ensc_crypto_api in 
     355(auto)          if test x"$ensc_have_beecrypt"  = xyes; then 
     356                        AC_MSG_NOTICE([using beecrypt as crypto api]) 
     357                        ensc_crypto_api=beecrypt 
     358                fi;; 
     359(beecrypt)      if test x"$ensc_have_beecrypt" != xyes; then 
     360                        AC_MSG_ERROR([beecrypt crypto api not found]) 
     361                fi;; 
     362esac 
    339363 
    340364AM_CONDITIONAL(ENSC_HAVE_BEECRYPT, test x"$ensc_have_beecrypt" = xyes) 
     
    342366dnl 
    343367dnl beecrypt stuff ends here} 
     368dnl 
     369dnl ######################## 
     370 
     371 
     372dnl ######################## 
     373dnl 
     374dnl {check for nss 
     375dnl 
     376 
     377case $ensc_crypto_api in 
     378(nss)   PKG_CHECK_MODULES(NSS, nss);; 
     379(auto)  PKG_CHECK_MODULES(NSS, nss, [ 
     380                AC_MSG_NOTICE([using NSS as crypto api]) 
     381                ensc_crypto_api=nss], 
     382                AC_MSG_RESULT(no));; 
     383esac 
     384 
     385dnl 
     386dnl nss stuff ends here} 
     387dnl 
     388dnl ######################## 
     389 
     390case $ensc_crypto_api in 
     391(beecrypt) 
     392        ENSC_HAVE_CRYPTO=true 
     393        ENSC_CRYPTO_API=ENSC_CRYPTO_API_BEECRYPT 
     394        ENSC_CRYPTO_CFLAGS= 
     395        ENSC_CRYPTO_LIB=-lbeecrypt 
     396        ENSC_CAN_CRYPTO_WITH_DIETLIBC=false 
     397        ;; 
     398 
     399(nss) 
     400        ENSC_HAVE_CRYPTO=true 
     401        ENSC_CRYPTO_API=ENSC_CRYPTO_API_NSS 
     402        ENSC_CRYPTO_CFLAGS=$NSS_CFLAGS 
     403        ENSC_CRYPTO_LIB=$NSS_LIBS 
     404        ENSC_CAN_CRYPTO_WITH_DIETLIBC=false 
     405        ;; 
     406 
     407(none) 
     408        ENSC_HAVE_CRYPTO=false 
     409        ENSC_CRYPTO_API=ENSC_CRYPTO_API_NONE 
     410        ENSC_CRYPTO_CFLAGS= 
     411        ENSC_CRYPTO_LIB= 
     412        ENSC_CAN_CRYPTO_WITH_DIETLIBC=false 
     413 
     414        AC_MSG_WARN([No crypto api found/select. This will disable the build of `vhashify']) 
     415        ;; 
     416 
     417(*)     AC_MSG_ERROR([internal error]) 
     418esac 
     419 
     420AM_CONDITIONAL(ENSC_HAVE_CRYPTO, $ENSC_HAVE_CRYPTO) 
     421AM_CONDITIONAL(ENSC_CAN_CRYPTO_WITH_DIETLIBC, $ENSC_CAN_CRYPTO_WITH_DIETLIBC) 
     422AC_SUBST(ENSC_CRYPTO_CFLAGS, $ENSC_CRYPTO_CFLAGS) 
     423AC_SUBST(ENSC_CRYPTO_LIB,    $ENSC_CRYPTO_LIB) 
     424AC_DEFINE_UNQUOTED(ENSC_CRYPTO_API, $ENSC_CRYPTO_API, [Used crypto API]) 
     425 
     426dnl 
     427dnl crypto stuff ends here} 
    344428dnl 
    345429dnl ######################## 
     
    408492    syscall(2) invocation: $with_syscall 
    409493      vserver(2) syscall#: $ensc_cv_value_syscall_vserver 
     494               crypto api: $ensc_crypto_api 
    410495    
    411496Paths: 
  • trunk/lib_internal/Makefile-files

    r2579 r2685  
    5353noinst_HEADERS += \ 
    5454                                lib_internal/coreassert.h \ 
     55                                lib_internal/crypto-wrapper.h \ 
     56                                lib_internal/crypto-wrapper-nss.h \ 
     57                                lib_internal/crypto-wrapper-beecrypt.h \ 
    5558                                lib_internal/errinfo.h \ 
    5659                                lib_internal/jail.h \ 
  • trunk/lib_internal/testsuite/Makefile-files

    r2569 r2685  
    3737endif 
    3838 
     39if ENSC_HAVE_CRYPTO 
     40check_PROGRAMS +=               lib_internal/testsuite/crypto \ 
     41                                lib_internal/testsuite/crypto-speed 
     42TESTS +=                        lib_internal/testsuite/crypto 
     43endif 
     44 
    3945DIETPROGS +=                    lib_internal/testsuite/isnumber \ 
    4046                                lib_internal/testsuite/sigbus \ 
    4147                                lib_internal/testsuite/matchlist 
     48 
     49if ENSC_CAN_CRYPTO_WITH_DIETLIBC 
     50DIETPROGS +=                    lib_internal/testsuite/crypto \ 
     51                                lib_internal/testsuite/crypto-speed 
     52endif 
    4253 
    4354EXTRA_DIST +=                   lib_internal/testsuite/copy-check 
     
    8091lib_internal_testsuite_matchlist_gnu_LDADD =    $(LIBINTERNAL_GLIBC) 
    8192lib_internal_testsuite_matchlist_gnu_CPPFLAGS = $(AM_CPPFLAGS)          # see note above 
     93 
     94if ENSC_HAVE_CRYPTO 
     95lib_internal_testsuite_crypto_speed_SOURCES =   lib_internal/testsuite/crypto-speed.c 
     96lib_internal_testsuite_crypto_speed_CFLAGS =    $(AM_CFLAGS) $(ENSC_CRYPTO_CFLAGS) 
     97lib_internal_testsuite_crypto_speed_LDADD =     $(ENSC_CRYPTO_LIB) -lrt 
     98 
     99lib_internal_testsuite_crypto_SOURCES =         lib_internal/testsuite/crypto.c 
     100lib_internal_testsuite_crypto_CFLAGS =          $(AM_CFLAGS) $(ENSC_CRYPTO_CFLAGS) 
     101lib_internal_testsuite_crypto_LDADD =           $(ENSC_CRYPTO_LIB) 
     102 
     103if !ENSC_CAN_CRYPTO_WITH_DIETLIBC 
     104lib_internal_testsuite_crypto_speed_LDFLAGS =   -Wl,--as-needed 
     105lib_internal_testsuite_crypto_LDFLAGS =         -Wl,--as-needed 
     106endif 
     107endif 
  • trunk/src/Makefile-files

    r2619 r2685  
    8787                        src/vmemctrl 
    8888 
    89 if ENSC_CAN_BEECRYPT_WITH_DIETLIBC 
     89if ENSC_CAN_CRYPTO_WITH_DIETLIBC 
    9090DIETPROGS +=            src/vhashify 
    9191endif 
     
    128128 
    129129if ENSC_HAVE_C99_COMPILER 
    130 if ENSC_HAVE_BEECRYPT 
     130if ENSC_HAVE_CRYPTO 
    131131pkglib_PROGRAMS +=      src/vhashify 
    132 endif ENSC_HAVE_BEECRYPT 
     132endif ENSC_HAVE_CRYPTO 
    133133endif ENSC_HAVE_C99_COMPILER 
    134134 
     
    296296 
    297297src_vhashify_SOURCES =          src/vhashify.c 
    298 if ENSC_CAN_BEECRYPT_WITH_DIETLIBC 
    299 src_vhashify_LDADD =            $(LIBINTERNAL) $(LIBENSCVECTOR) -lbeecrypt $(VSERVER_LDADDS) 
     298src_vhashify_CFLAGS =           $(AM_CFLAGS) $(ENSC_CRYPTO_CFLAGS) 
     299if ENSC_CAN_CRYPTO_WITH_DIETLIBC 
     300src_vhashify_LDADD =            $(LIBINTERNAL) $(LIBENSCVECTOR) $(ENSC_CRYPTO_LIB) $(VSERVER_LDADDS) 
    300301src_vhashify_LDFLAGS =          $(VSERVER_LDFLGS) 
    301302else 
    302 src_vhashify_LDADD =            $(LIBINTERNAL_GLIBC) $(LIBENSCVECTOR_GLIBC) $(LIBVSERVER_GLIBC) -lbeecrypt 
    303 src_vhashify_LDFLAGS = 
     303src_vhashify_LDADD =            $(LIBINTERNAL_GLIBC) $(LIBENSCVECTOR_GLIBC) $(LIBVSERVER_GLIBC) $(ENSC_CRYPTO_LIB) 
     304src_vhashify_LDFLAGS =          -Wl,--as-needed 
    304305endif 
    305306 
  • trunk/src/testsuite/Makefile-files

    r2245 r2685  
    2323 
    2424if ENSC_HAVE_C99_COMPILER 
    25 if ENSC_HAVE_BEECRYPT 
     25if ENSC_HAVE_CRYPTO 
    2626src_testsuite_check_passive_PRGS +=     src/testsuite/hashcalc          \ 
    2727                                        src/testsuite/hashcalc-plain 
     
    3434if ENSC_HAVE_C99_COMPILER 
    3535src_testsuite_check_src_C99_SCRPTS =    src/testsuite/vunify-test.sh 
    36 if ENSC_HAVE_BEECRYPT 
     36if ENSC_HAVE_CRYPTO 
    3737src_testsuite_check_src_C99_SCRPTS +=   src/testsuite/hashcalc-plain.sh         \ 
    3838                                        src/testsuite/hashcalc.sh 
     
    7474src_testsuite_hashcalc_SOURCES =        src/testsuite/hashcalc.c 
    7575src_testsuite_hashcalc_plain_SOURCES =  src/testsuite/hashcalc-plain.c 
    76 if ENSC_CAN_BEECRYPT_WITH_DIETLIBC 
    77 src_testsuite_hashcalc_LDADD =          $(LIBINTERNAL) $(LIBENSCVECTOR) -lbeecrypt $(VSERVER_LDADDS) 
     76src_testsuite_hashcalc_CFLAGS =         $(AM_CFLAGS) $(ENSC_CRYPTO_CFLAGS) 
     77src_testsuite_hashcalc_plain_CFLAGS =   $(AM_CFLAGS) $(ENSC_CRYPTO_CFLAGS) 
     78 
     79if ENSC_CAN_CRYPTO_WITH_DIETLIBC 
     80src_testsuite_hashcalc_LDADD =          $(LIBINTERNAL) $(LIBENSCVECTOR) $(ENSC_CRYPTO_LIB) $(VSERVER_LDADDS) 
    7881src_testsuite_hashcalc_LDFLAGS =        $(VSERVER_LDFLGS) 
    7982 
    80 src_testsuite_hashcalc_plain_LDADD =    $(LIBINTERNAL) $(LIBENSCVECTOR) -lbeecrypt $(VSERVER_LDADDS) 
     83src_testsuite_hashcalc_plain_LDADD =    $(LIBINTERNAL) $(LIBENSCVECTOR) $(ENSC_CRYPTO_LIB) $(VSERVER_LDADDS) 
    8184src_testsuite_hashcalc_plain_LDFLAGS =  $(VSERVER_LDFLGS) 
    8285else 
    83 src_testsuite_hashcalc_LDADD =          $(LIBINTERNAL_GLIBC) $(LIBENSCVECTOR_GLIBC) $(LIBVSERVER_GLIBC) -lbeecrypt 
    84 src_testsuite_hashcalc_LDFLAGS = 
     86src_testsuite_hashcalc_LDADD =          $(LIBINTERNAL_GLIBC) $(LIBENSCVECTOR_GLIBC) $(LIBVSERVER_GLIBC) $(ENSC_CRYPTO_LIB) 
     87src_testsuite_hashcalc_LDFLAGS =        -Wl,--as-needed 
    8588 
    86 src_testsuite_hashcalc_plain_LDADD =    $(LIBINTERNAL_GLIBC) $(LIBENSCVECTOR_GLIBC) $(LIBVSERVER_GLIBC) -lbeecrypt 
    87 src_testsuite_hashcalc_plain_LDFLAGS = 
     89src_testsuite_hashcalc_plain_LDADD =    $(LIBINTERNAL_GLIBC) $(LIBENSCVECTOR_GLIBC) $(LIBVSERVER_GLIBC) $(ENSC_CRYPTO_LIB) 
     90src_testsuite_hashcalc_plain_LDFLAGS =  -Wl,--as-needed 
    8891endif 
    8992 
  • trunk/src/testsuite/hashcalc-plain.c

    r2245 r2685  
    2121#endif 
    2222 
    23 #include <beecrypt/beecrypt.h> 
     23#include <lib_internal/crypto-wrapper.h> 
    2424#include <stdbool.h> 
    2525#include <unistd.h> 
     
    3333 
    3434static bool 
    35 convertDigest(char res[], hashFunctionContext * h_ctx) 
     35convertDigest(char res[], ensc_hash_context * h_ctx) 
    3636{ 
    3737  static char const             HEX_DIGIT[] = "0123456789abcdef"; 
    38   size_t                        d_size   = h_ctx->algo->digestsize
     38  size_t                        d_size   = ensc_crypto_hashctx_get_digestsize(h_ctx)
    3939     
    4040  unsigned char                 digest[d_size]; 
    4141  size_t                        out = 0; 
    4242 
    43   if (hashFunctionContextDigest(h_ctx, digest)==-1) 
     43  if (ensc_crypto_hashctx_get_digest(h_ctx, digest, NULL, d_size)==-1) 
    4444    return false; 
    4545   
     
    5555int main(int UNUSED argc, char *argv[]) 
    5656{ 
    57   int                   fd = open(argv[1], O_NOFOLLOW|O_NONBLOCK|O_RDONLY|O_NOCTTY); 
    58   hashFunctionContext hash_context; 
    59   hashFunction const  *method; 
    60   struct stat           st; 
    61   off_t                 size; 
    62   loff_t                offset = 0; 
    63   char                  digest[1024]; 
     57  int                          fd = open(argv[1], O_NOFOLLOW|O_NONBLOCK|O_RDONLY|O_NOCTTY); 
     58  ensc_hash_context           hash_context; 
     59  ensc_hash_method const      *method; 
     60  struct stat                  st; 
     61  off_t                        size; 
     62  loff_t                       offset = 0; 
     63  char                         digest[2048]; 
    6464 
    65   assert((method = hashFunctionFind(argv[2]))!=0); 
    66   assert(hashFunctionContextInit(&hash_context, method)!=-1); 
     65  ensc_crypto_init(); 
     66  assert((method = ensc_crypto_hash_find(argv[2]))!=0); 
     67  assert(ensc_crypto_hashctx_init(&hash_context, method)!=-1); 
    6768 
    6869  assert(fstat(fd, &st)!=-1); 
    69   assert(hashFunctionContextReset(&hash_context)!=-1); 
     70  assert(ensc_crypto_hashctx_reset(&hash_context)!=-1); 
    7071 
    7172  size = st.st_size; 
     
    7879    assert((buf=mmap(0, buf_size, PROT_READ, MAP_SHARED, fd, offset))!=0); 
    7980    offset += buf_size; 
    80     assert(hashFunctionContextUpdate(&hash_context, buf, buf_size)!=-1); 
     81    assert(ensc_crypto_hashctx_update(&hash_context, buf, buf_size)!=-1); 
    8182    munmap((void *)(buf), buf_size); 
    8283  } 
     
    8788  Vwrite(1, "\n", 1); 
    8889   
    89   hashFunctionContextFree(&hash_context); 
     90  ensc_crypto_hashctx_free(&hash_context); 
    9091   
    9192  return 0; 
  • trunk/src/testsuite/hashcalc.c

    r2209 r2685  
    4040      volatile unsigned int     canary3; 
    4141  } __attribute__((__packed__)) d_path; 
    42  
     42  
    4343  d_path.canary0 = 0x12345678; 
    4444  d_path.canary1 = 0x21436587; 
     
    4747  memset(d_path.d, 0x66, sizeof d_path.d); 
    4848 
    49   global_info.hash_conf.method = hashFunctionFind(argv[2]); 
     49  ensc_crypto_init(); 
     50  global_info.hash_conf.method = ensc_crypto_hash_find(argv[2]); 
    5051   
    51   assert(hashFunctionContextInit(&global_info.hash_context, 
    52                                  global_info.hash_conf.method)!=-1); 
     52  assert(ensc_crypto_hashctx_init(&global_info.hash_context, 
     53                                  global_info.hash_conf.method)!=-1); 
    5354 
    5455  assert(fstat(fd, &st)!=-1); 
     
    6970  Vwrite(1, "\n", 1); 
    7071   
    71   hashFunctionContextFree(&global_info.hash_context); 
     72  ensc_crypto_hashctx_free(&global_info.hash_context); 
    7273   
    7374  return 0; 
  • trunk/src/testsuite/hashcalc.sh

    r2176 r2685  
    5252 
    5353for i in $tmpdir/rand-*; do 
    54     sha1_0=$($hashcalc "$i" SHA-1 | tr -d / ) 
    55     sha1_1=$(sha1sum   "$i" | awk '{ print $1}' ) 
     54    for m in md5 sha1 sha256 sha512; do 
     55        sum_0=$($hashcalc "$i" "$m" | tr -d / ) 
     56        sum_1=$(${m}sum   "$i" | awk '{ print $1}' ) 
    5657 
    57     test x"$sha1_0" = x"$sha1_1" || { 
    58         echo "SHA-1 mismatch at $(basename $i)" 
    59         exit 1 
    60     } 
    61  
    62     md5_0=$($hashcalc "$i" MD5  | tr -d / ) 
    63     md5_1=$(md5sum   "$i" | awk '{ print $1}' ) 
    64  
    65     test x"$md5_0" = x"$md5_1" || { 
    66         echo "MD5 mismatch at $(basename $i)" 
    67         exit 1 
    68     } 
     58        # compare only the first 80 chars as vhashify will cut digest to MAXPATHLEN 
     59        test x"${sum_0::80}" = x"${sum_1::80}" || { 
     60          echo "$m mismatch at $(basename $i): '$sum_0' vs. '$sum_1'" 
     61          exit 1 
     62        } 
     63    done 
    6964done 
    7065 
  • trunk/src/vhashify-init.hc

    r1967 r2685  
    9797  int           fd = open(filename, O_RDONLY); 
    9898  if (fd==-1 && conf->method==0) 
    99     conf->method = hashFunctionDefault(); 
     99    conf->method = ensc_crypto_hash_get_default(); 
    100100 
    101101  if (fd==-1) { 
     102    char const  *hash_name; 
    102103    assert(conf->method!=0); 
    103104    if (conf->method==0)      return false; 
    104105    if (global_args->dry_run) return true;      // do not create the file 
    105      
     106 
    106107    fd = Eopen(filename, O_WRONLY|O_CREAT|O_EXCL|O_NOFOLLOW, 0644); 
    107     TEMP_FAILURE_RETRY(write(fd, conf->method->name, strlen(conf->method->name))); 
     108 
     109    hash_name = ensc_crypto_hash_get_name(conf->method); 
     110    TEMP_FAILURE_RETRY(write(fd, hash_name, strlen(hash_name))); 
    108111    TEMP_FAILURE_RETRY(write(fd, "\n", 1)); 
    109112  } 
     
    120123      buf[s] = '\0'; 
    121124 
    122       conf->method = hashFunctionFind(buf); 
     125      conf->method = ensc_crypto_hash_find(buf); 
    123126      if (conf->method==0) { 
    124127        WRITE_MSG(2, "Can not find hash-function '"); 
     
    131134  } 
    132135 
    133   if (conf->method!=0 && conf->method->digestsize*8>HASH_MAXBITS) { 
     136  if (conf->method!=0 && ensc_crypto_hash_get_digestsize(conf->method)*8>HASH_MAXBITS) { 
    134137    WRITE_MSG(2, "Wow... what an huge hash-function. I can not handle so much bits; giving up...\n"); 
    135138    conf->method=0; 
  • trunk/src/vhashify.c

    r2569 r2685  
    3131#include "ensc_vector/vector.h" 
    3232 
    33 #include <beecrypt/beecrypt.h> 
     33#include "lib_internal/crypto-wrapper.h" 
    3434 
    3535#include <setjmp.h> 
     
    9696struct HashDirConfiguration 
    9797{ 
    98     hashFunction const                        *method; 
     98    ensc_hash_method const                    *method; 
    9999    enum { hshALL=0, hshSTART = 1, hshMIDDLE=2, 
    100100           hshEND = 4, hshINVALID = -1 }        blocks; 
     
    110110    size_t                      hash_dirs_max_size; 
    111111 
    112     hashFunctionContext               hash_context; 
     112    ensc_hash_context         hash_context; 
    113113}; 
    114114 
     
    252252{ 
    253253  static char const             HEX_DIGIT[] = "0123456789abcdef"; 
    254   hashFunctionContext * const h_ctx    = &global_info.hash_context; 
    255   size_t                        d_size   = h_ctx->algo->digestsize
    256      
     254  ensc_hash_context * const   h_ctx    = &global_info.hash_context; 
     255  size_t                        d_size   = ensc_crypto_hashctx_get_digestsize(h_ctx)
     256 
    257257  unsigned char                 digest[d_size]; 
    258258  size_t                        out = 0; 
    259259 
    260   if (hashFunctionContextDigest(h_ctx, digest)==-1) 
     260  if (ensc_crypto_hashctx_get_digest(h_ctx, digest, NULL, d_size)==-1) 
    261261    return false; 
    262262   
     
    276276#ifndef ENSC_TESTSUITE 
    277277static bool 
    278 addStatHash(hashFunctionContext *h_ctx, struct stat const * const st) 
     278addStatHash(ensc_hash_context *h_ctx, struct stat const * const st) 
    279279{ 
    280280#define DECL_ATTR(X)    __typeof__(st->st_##X)  X 
     
    301301 
    302302   
    303   return hashFunctionContextUpdate(h_ctx, (void *)&tmp, sizeof tmp)!=-1; 
     303  return ensc_crypto_hashctx_update(h_ctx, (void *)&tmp, sizeof tmp)!=-1; 
    304304} 
    305305#else 
    306306static bool 
    307 addStatHash(hashFunctionContext UNUSED *h_ctx, struct stat const UNUSED * const st) 
     307addStatHash(ensc_hash_context UNUSED *h_ctx, struct stat const UNUSED * const st) 
    308308{ 
    309309  return true; 
     
    314314calculateHashFromFD(int fd, HashPath d_path, struct stat const * const st) 
    315315{ 
    316   hashFunctionContext * const h_ctx    = &global_info.hash_context; 
     316  ensc_hash_context * const   h_ctx    = &global_info.hash_context; 
    317317  void const * volatile         buf      = 0; 
    318318  loff_t volatile               buf_size = 0; 
     
    320320 
    321321 
    322   if (hashFunctionContextReset(h_ctx)==-1 || 
     322  if (ensc_crypto_hashctx_reset(h_ctx)==-1 || 
    323323      !addStatHash(h_ctx, st)) 
    324324    return false; 
     
    341341      madvise(const_cast(void *)(buf), buf_size, MADV_SEQUENTIAL);      // ignore error... 
    342342 
    343       if (hashFunctionContextUpdate(h_ctx, buf, buf_size)==-1) goto out; 
     343      if (ensc_crypto_hashctx_update(h_ctx, buf, buf_size)==-1) goto out; 
    344344 
    345345      munmap(const_cast(void *)(buf), buf_size); 
     
    669669  } 
    670670 
     671  ensc_crypto_init(); 
    671672  switch (args.mode) { 
    672673    case mdMANUALLY     :  initModeManually(&args, argc-optind, argv+optind); break; 
     
    675676  }; 
    676677 
    677   if (hashFunctionContextInit(&global_info.hash_context, 
    678                               global_info.hash_conf.method)==-1) { 
     678  if (ensc_crypto_hashctx_init(&global_info.hash_context, 
     679                              global_info.hash_conf.method)==-1) { 
    679680    WRITE_MSG(2, "Failed to initialize hash-context\n"); 
    680681    return EXIT_FAILURE; 
     
    692693  MatchList_destroy(&global_info.dst_list); 
    693694  freeHashList(&global_info.hash_dirs); 
    694   hashFunctionContextFree(&global_info.hash_context); 
     695  ensc_crypto_hashctx_free(&global_info.hash_context); 
    695696#endif 
    696697