Ticket #619: nALFS-md5.patch

File nALFS-md5.patch, 18.3 KB (added by kpfleming@…, 21 years ago)

Draft patch to close bug

  • configure.in

    diff -X /usr/src/dontdiff -urN nALFS/configure.in nALFS-new/configure.in
    old new  
    6666
    6767AC_ARG_WITH(ssl,
    6868[  --with-ssl=PREFIX       specify prefix for ssl files (ssl will be used
    69                           for checking MD5 digest in <unpack>)],
     69                          for checking non-MD5 digests in <unpack> elements)],
    7070[
    7171        case "$withval" in
    7272                n|no)
    73                         disable_ssl=yes
    7473                        ;;
    7574                y|ye|yes)
     75                        enable_ssl=yes
    7676                        ;;
    77 
    7877                *)
    7978                        LIBS="$LIBS -L$withval/lib"
     79                        enable_ssl=yes
    8080                        ;;
    8181        esac
    8282])
    8383
    84 if test "$disable_ssl" != "yes" ; then
     84if test "$enable_ssl" == "yes" ; then
    8585        AC_CHECK_LIB(ssl, OpenSSL_add_all_digests, [
    8686                CPPFLAGS="$CPPFLAGS -DHAVE_LIBSSL"
    8787                LIBS="$LIBS -lcrypto -lssl"])
  • src/handlers/Makefile.in

    diff -X /usr/src/dontdiff -urN nALFS/src/handlers/Makefile.in nALFS-new/src/handlers/Makefile.in
    old new  
    2626include $(top_builddir)/Rules.mak
    2727
    2828
    29 CFLAGS += -fPIC -shared
     29CFLAGS += -fPIC
    3030
    31 SO_FILES = $(patsubst $(srcdir)/%.c,%.so, $(C_FILES))
     31DIGEST_C_FILES := $(srcdir)/digest.c $(srcdir)/md5.c
     32DIGEST_FILES := $(patsubst $(srcdir)/%.c,%.o, $(DIGEST_C_FILES))
     33
     34SO_C_FILES := $(filter-out $(DIGEST_C_FILES), $(C_FILES))
     35
     36DIGEST_SO_C_FILES := $(srcdir)/new-unpack.c
     37
     38DIGEST_SO_FILES := $(patsubst $(srcdir)/%.c,%.so, $(DIGEST_SO_C_FILES))
     39
     40SO_C_FILES := $(filter-out $(DIGEST_SO_C_FILES), $(SO_C_FILES))
     41
     42SO_FILES := $(patsubst $(srcdir)/%.c,%.so, $(SO_C_FILES))
    3243
    3344
    3445.PHONY: all
    3546
    36 all: $(SO_FILES)
     47all: $(SO_FILES) $(DIGEST_SO_FILES)
    3748
    3849$(SO_FILES): %.so: $(srcdir)/%.c
    39         $(CC) $(CFLAGS) $(CPPFLAGS) $< -o $@
     50        $(CC) $(CFLAGS) -shared $(CPPFLAGS) $< -o $@
     51
     52$(DIGEST_SO_FILES): %.so: $(srcdir)/%.c $(DIGEST_FILES)
     53        $(CC) $(CFLAGS) -shared $(CPPFLAGS) $< $(DIGEST_FILES) -o $@
    4054
     55$(DIGEST_FILES): %.o: $(srcdir)/%.c
     56        $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
    4157
    4258.PHONY: clean distclean
    4359
    4460clean:
    45         $(RM) $(SO_FILES)
     61        $(RM) $(SO_FILES) $(DIGEST_SO_FILES) $(DIGEST_FILES)
    4662
    4763distclean:
    4864        $(RM) Makefile
  • src/handlers/digest.c

    diff -X /usr/src/dontdiff -urN nALFS/src/handlers/digest.c nALFS-new/src/handlers/digest.c
    old new  
     1/*
     2 *  digest.c - Verify a file's contents have not been changed.
     3 *
     4 *  Copyright (C) 2001-2003
     5 * 
     6 *  Neven Has <haski@sezampro.yu> and
     7 *  Kevin P. Fleming <kpfleming@backtobasicsmgmt.com>
     8 *
     9 *  This program is free software; you can redistribute it and/or modify
     10 *  it under the terms of the GNU General Public License as published by
     11 *  the Free Software Foundation; either version 2 of the License, or
     12 *  (at your option) any later version.
     13 *
     14 *  This program is distributed in the hope that it will be useful,
     15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17 *  GNU General Public License for more details.
     18 *
     19 *  You should have received a copy of the GNU General Public License
     20 *  along with this program; if not, write to the Free Software
     21 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     22 */
     23
     24
     25#include <stdlib.h>
     26#include <string.h>
     27#include <unistd.h>
     28#include <errno.h>
     29#include <ctype.h>
     30#include <sys/types.h>
     31
     32#ifdef HAVE_LIBSSL
     33
     34#include <openssl/evp.h>
     35#define MAX_MD_SIZE EVP_MAX_MD_SIZE
     36
     37#else /* !HAVE_LIBSSL */
     38
     39#define MAX_MD_SIZE 16
     40
     41#endif /* HAVE_LIBSSL */
     42
     43#include "win.h"
     44#include "md5.h"
     45
     46int verify_digest(const char* type, char* digest, const char* file)
     47{
     48        char buffer[4094];
     49        FILE *istream;
     50        unsigned int i;
     51        unsigned int md_len = 0;
     52        unsigned char md_value[MAX_MD_SIZE];
     53        char md_value_hex[2*MAX_MD_SIZE + 1 ];
     54        int use_ssl;
     55
     56        struct md5_context md5_ctx;
     57
     58#ifdef HAVE_LIBSSL
     59        EVP_MD_CTX ssl_ctx;
     60        const EVP_MD *ssl_md;
     61#endif /* HAVE_LIBSSL */
     62
     63        use_ssl = strncasecmp(type, "md5", 3);
     64
     65        if (!use_ssl) {
     66                md5_starts(&md5_ctx);
     67        } else {
     68#ifdef HAVE_LIBSSL
     69                OpenSSL_add_all_digests();
     70                ssl_md = EVP_get_digestbyname(type);
     71                if (ssl_md)
     72                        EVP_DigestInit(&ssl_ctx, ssl_md);
     73                else
     74                        return -1;
     75#else /* !HAVE_LIBSSL */
     76                return -1;
     77#endif /* HAVE_LIBSSL */
     78        }
     79
     80        istream = fopen(file, "r");
     81        if (istream) {
     82                size_t nbbytes;
     83
     84                while ((nbbytes = fread(&buffer[0], 1, sizeof(buffer), istream)) != 0) {
     85                        if (!use_ssl)
     86                                md5_update(&md5_ctx, &buffer[0], nbbytes);
     87#ifdef HAVE_LIBSSL
     88                        else
     89                                EVP_DigestUpdate(&ssl_ctx, &buffer[0], nbbytes);
     90#endif /* HAVE_LIBSSL */
     91                }
     92
     93                if (!use_ssl) {
     94                        md5_finish(&md5_ctx, &md_value[0]);
     95                        md_len = MAX_MD_SIZE;
     96                }
     97#ifdef HAVE_LIBSSL
     98                else
     99                        EVP_DigestFinal(&ssl_ctx, &md_value[0], &md_len);
     100#endif /* HAVE_LIBSSL */
     101
     102                fclose(istream);
     103
     104                for(i = 0; i < md_len; i++)
     105                        sprintf(&md_value_hex[0] + i * 2, "%02x", md_value[i]);
     106
     107                if (! strcmp(digest, &md_value_hex[0])) {
     108                        Nprint("Digest ok.");
     109                        return 0;
     110                }
     111
     112                Nprint_err("Expected digest : %s", digest);
     113                Nprint_err("Found digest    : %s", &md_value_hex[0]);
     114
     115        } else {
     116                Nprint_err(
     117                "Unable to open the archive when checking digest: %s", file);
     118        }
     119
     120        return -1;
     121}
  • src/handlers/digest.h

    diff -X /usr/src/dontdiff -urN nALFS/src/handlers/digest.h nALFS-new/src/handlers/digest.h
    old new  
     1/*
     2 *  digest.h - Verify a file's contents have not been changed.
     3 *
     4 *  Copyright (C) 2003-2003
     5 * 
     6 *  Neven Has <haski@sezampro.yu> and
     7 *  Kevin P. Fleming <kpfleming@backtobasicsmgmt.com>
     8 *
     9 *  This program is free software; you can redistribute it and/or modify
     10 *  it under the terms of the GNU General Public License as published by
     11 *  the Free Software Foundation; either version 2 of the License, or
     12 *  (at your option) any later version.
     13 *
     14 *  This program is distributed in the hope that it will be useful,
     15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17 *  GNU General Public License for more details.
     18 *
     19 *  You should have received a copy of the GNU General Public License
     20 *  along with this program; if not, write to the Free Software
     21 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     22 */
     23
     24#ifndef _DIGEST_H
     25#define _DIGEST_H
     26
     27extern int verify_digest(const char *type, char *digest, const char *file);
     28
     29#endif /* _DIGEST_H */
  • src/handlers/md5.c

    diff -X /usr/src/dontdiff -urN nALFS/src/handlers/md5.c nALFS-new/src/handlers/md5.c
    old new  
     1/*
     2 *  md5.c - MD5 (RFC 1321) sum computation.
     3 *
     4 *  Copyright (C) 2001-2003
     5 * 
     6 *  Christophe Devine <devine@cr0.net>
     7 *
     8 *  This program is free software; you can redistribute it and/or modify
     9 *  it under the terms of the GNU General Public License as published by
     10 *  the Free Software Foundation; either version 2 of the License, or
     11 *  (at your option) any later version.
     12 *
     13 *  This program is distributed in the hope that it will be useful,
     14 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *  GNU General Public License for more details.
     17 *
     18 *  You should have received a copy of the GNU General Public License
     19 *  along with this program; if not, write to the Free Software
     20 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     21 */
     22
     23#include <string.h>
     24#include "md5.h"
     25
     26#define GET_UINT32(n,b,i)                       \
     27{                                               \
     28    (n) = ( (uint32) (b)[(i) + 3] << 24 )       \
     29        | ( (uint32) (b)[(i) + 2] << 16 )       \
     30        | ( (uint32) (b)[(i) + 1] <<  8 )       \
     31        | ( (uint32) (b)[(i)    ]       );      \
     32}
     33
     34#define PUT_UINT32(n,b,i)                       \
     35{                                               \
     36    (b)[(i)    ] = (uint8) ( (n)       );       \
     37    (b)[(i) + 1] = (uint8) ( (n) >>  8 );       \
     38    (b)[(i) + 2] = (uint8) ( (n) >> 16 );       \
     39    (b)[(i) + 3] = (uint8) ( (n) >> 24 );       \
     40}
     41
     42void md5_starts( struct md5_context *ctx )
     43{
     44    ctx->total[0] = 0;
     45    ctx->total[1] = 0;
     46    ctx->state[0] = 0x67452301;
     47    ctx->state[1] = 0xEFCDAB89;
     48    ctx->state[2] = 0x98BADCFE;
     49    ctx->state[3] = 0x10325476;
     50}
     51
     52void md5_process( struct md5_context *ctx, uint8 data[64] )
     53{
     54    uint32 A, B, C, D, X[16];
     55
     56    GET_UINT32( X[0],  data,  0 );
     57    GET_UINT32( X[1],  data,  4 );
     58    GET_UINT32( X[2],  data,  8 );
     59    GET_UINT32( X[3],  data, 12 );
     60    GET_UINT32( X[4],  data, 16 );
     61    GET_UINT32( X[5],  data, 20 );
     62    GET_UINT32( X[6],  data, 24 );
     63    GET_UINT32( X[7],  data, 28 );
     64    GET_UINT32( X[8],  data, 32 );
     65    GET_UINT32( X[9],  data, 36 );
     66    GET_UINT32( X[10], data, 40 );
     67    GET_UINT32( X[11], data, 44 );
     68    GET_UINT32( X[12], data, 48 );
     69    GET_UINT32( X[13], data, 52 );
     70    GET_UINT32( X[14], data, 56 );
     71    GET_UINT32( X[15], data, 60 );
     72
     73#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
     74
     75#define P(a,b,c,d,k,s,t)                                \
     76{                                                       \
     77    a += F(b,c,d) + X[k] + t; a = S(a,s) + b;           \
     78}
     79
     80    A = ctx->state[0];
     81    B = ctx->state[1];
     82    C = ctx->state[2];
     83    D = ctx->state[3];
     84
     85#define F(x,y,z) (z ^ (x & (y ^ z)))
     86
     87    P( A, B, C, D,  0,  7, 0xD76AA478 );
     88    P( D, A, B, C,  1, 12, 0xE8C7B756 );
     89    P( C, D, A, B,  2, 17, 0x242070DB );
     90    P( B, C, D, A,  3, 22, 0xC1BDCEEE );
     91    P( A, B, C, D,  4,  7, 0xF57C0FAF );
     92    P( D, A, B, C,  5, 12, 0x4787C62A );
     93    P( C, D, A, B,  6, 17, 0xA8304613 );
     94    P( B, C, D, A,  7, 22, 0xFD469501 );
     95    P( A, B, C, D,  8,  7, 0x698098D8 );
     96    P( D, A, B, C,  9, 12, 0x8B44F7AF );
     97    P( C, D, A, B, 10, 17, 0xFFFF5BB1 );
     98    P( B, C, D, A, 11, 22, 0x895CD7BE );
     99    P( A, B, C, D, 12,  7, 0x6B901122 );
     100    P( D, A, B, C, 13, 12, 0xFD987193 );
     101    P( C, D, A, B, 14, 17, 0xA679438E );
     102    P( B, C, D, A, 15, 22, 0x49B40821 );
     103
     104#undef F
     105
     106#define F(x,y,z) (y ^ (z & (x ^ y)))
     107
     108    P( A, B, C, D,  1,  5, 0xF61E2562 );
     109    P( D, A, B, C,  6,  9, 0xC040B340 );
     110    P( C, D, A, B, 11, 14, 0x265E5A51 );
     111    P( B, C, D, A,  0, 20, 0xE9B6C7AA );
     112    P( A, B, C, D,  5,  5, 0xD62F105D );
     113    P( D, A, B, C, 10,  9, 0x02441453 );
     114    P( C, D, A, B, 15, 14, 0xD8A1E681 );
     115    P( B, C, D, A,  4, 20, 0xE7D3FBC8 );
     116    P( A, B, C, D,  9,  5, 0x21E1CDE6 );
     117    P( D, A, B, C, 14,  9, 0xC33707D6 );
     118    P( C, D, A, B,  3, 14, 0xF4D50D87 );
     119    P( B, C, D, A,  8, 20, 0x455A14ED );
     120    P( A, B, C, D, 13,  5, 0xA9E3E905 );
     121    P( D, A, B, C,  2,  9, 0xFCEFA3F8 );
     122    P( C, D, A, B,  7, 14, 0x676F02D9 );
     123    P( B, C, D, A, 12, 20, 0x8D2A4C8A );
     124
     125#undef F
     126   
     127#define F(x,y,z) (x ^ y ^ z)
     128
     129    P( A, B, C, D,  5,  4, 0xFFFA3942 );
     130    P( D, A, B, C,  8, 11, 0x8771F681 );
     131    P( C, D, A, B, 11, 16, 0x6D9D6122 );
     132    P( B, C, D, A, 14, 23, 0xFDE5380C );
     133    P( A, B, C, D,  1,  4, 0xA4BEEA44 );
     134    P( D, A, B, C,  4, 11, 0x4BDECFA9 );
     135    P( C, D, A, B,  7, 16, 0xF6BB4B60 );
     136    P( B, C, D, A, 10, 23, 0xBEBFBC70 );
     137    P( A, B, C, D, 13,  4, 0x289B7EC6 );
     138    P( D, A, B, C,  0, 11, 0xEAA127FA );
     139    P( C, D, A, B,  3, 16, 0xD4EF3085 );
     140    P( B, C, D, A,  6, 23, 0x04881D05 );
     141    P( A, B, C, D,  9,  4, 0xD9D4D039 );
     142    P( D, A, B, C, 12, 11, 0xE6DB99E5 );
     143    P( C, D, A, B, 15, 16, 0x1FA27CF8 );
     144    P( B, C, D, A,  2, 23, 0xC4AC5665 );
     145
     146#undef F
     147
     148#define F(x,y,z) (y ^ (x | ~z))
     149
     150    P( A, B, C, D,  0,  6, 0xF4292244 );
     151    P( D, A, B, C,  7, 10, 0x432AFF97 );
     152    P( C, D, A, B, 14, 15, 0xAB9423A7 );
     153    P( B, C, D, A,  5, 21, 0xFC93A039 );
     154    P( A, B, C, D, 12,  6, 0x655B59C3 );
     155    P( D, A, B, C,  3, 10, 0x8F0CCC92 );
     156    P( C, D, A, B, 10, 15, 0xFFEFF47D );
     157    P( B, C, D, A,  1, 21, 0x85845DD1 );
     158    P( A, B, C, D,  8,  6, 0x6FA87E4F );
     159    P( D, A, B, C, 15, 10, 0xFE2CE6E0 );
     160    P( C, D, A, B,  6, 15, 0xA3014314 );
     161    P( B, C, D, A, 13, 21, 0x4E0811A1 );
     162    P( A, B, C, D,  4,  6, 0xF7537E82 );
     163    P( D, A, B, C, 11, 10, 0xBD3AF235 );
     164    P( C, D, A, B,  2, 15, 0x2AD7D2BB );
     165    P( B, C, D, A,  9, 21, 0xEB86D391 );
     166
     167#undef F
     168
     169    ctx->state[0] += A;
     170    ctx->state[1] += B;
     171    ctx->state[2] += C;
     172    ctx->state[3] += D;
     173}
     174
     175void md5_update( struct md5_context *ctx, uint8 *input, uint32 length )
     176{
     177    uint32 left, fill;
     178
     179    if( ! length ) return;
     180
     181    left = ( ctx->total[0] >> 3 ) & 0x3F;
     182    fill = 64 - left;
     183
     184    ctx->total[0] += length <<  3;
     185    ctx->total[1] += length >> 29;
     186
     187    ctx->total[0] &= 0xFFFFFFFF;
     188    ctx->total[1] += ctx->total[0] < ( length << 3 );
     189
     190    if( left && length >= fill )
     191    {
     192        memcpy( (void *) (ctx->buffer + left), (void *) input, fill );
     193        md5_process( ctx, ctx->buffer );
     194        length -= fill;
     195        input  += fill;
     196        left = 0;
     197    }
     198
     199    while( length >= 64 )
     200    {
     201        md5_process( ctx, input );
     202        length -= 64;
     203        input  += 64;
     204    }
     205
     206    if( length )
     207    {
     208        memcpy( (void *) (ctx->buffer + left), (void *) input, length );
     209    }
     210}
     211
     212static uint8 md5_padding[64] =
     213{
     214 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     215    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     216    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     217    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
     218};
     219
     220void md5_finish( struct md5_context *ctx, uint8 digest[16] )
     221{
     222    uint32 last, padn;
     223    uint8 msglen[8];
     224
     225    PUT_UINT32( ctx->total[0], msglen, 0 );
     226    PUT_UINT32( ctx->total[1], msglen, 4 );
     227
     228    last = ( ctx->total[0] >> 3 ) & 0x3F;
     229    padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last );
     230
     231    md5_update( ctx, md5_padding, padn );
     232    md5_update( ctx, msglen, 8 );
     233
     234    PUT_UINT32( ctx->state[0], digest,  0 );
     235    PUT_UINT32( ctx->state[1], digest,  4 );
     236    PUT_UINT32( ctx->state[2], digest,  8 );
     237    PUT_UINT32( ctx->state[3], digest, 12 );
     238}
  • src/handlers/md5.h

    diff -X /usr/src/dontdiff -urN nALFS/src/handlers/md5.h nALFS-new/src/handlers/md5.h
    old new  
     1/*
     2 *  md5.h - MD5 (RFC 1321) sum computation.
     3 *
     4 *  Copyright (C) 2001-2003
     5 * 
     6 *  Christophe Devine <devine@cr0.net>
     7 *
     8 *  This program is free software; you can redistribute it and/or modify
     9 *  it under the terms of the GNU General Public License as published by
     10 *  the Free Software Foundation; either version 2 of the License, or
     11 *  (at your option) any later version.
     12 *
     13 *  This program is distributed in the hope that it will be useful,
     14 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *  GNU General Public License for more details.
     17 *
     18 *  You should have received a copy of the GNU General Public License
     19 *  along with this program; if not, write to the Free Software
     20 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     21 */
     22
     23#ifndef _MD5_H
     24#define _MD5_H
     25
     26#define uint8  unsigned char
     27#define uint32 unsigned long int
     28
     29struct md5_context
     30{
     31    uint32 total[2];
     32    uint32 state[4];
     33    uint8 buffer[64];
     34};
     35
     36void md5_starts( struct md5_context *ctx );
     37void md5_update( struct md5_context *ctx, uint8 *input, uint32 length );
     38void md5_finish( struct md5_context *ctx, uint8 digest[16] );
     39
     40#endif /* _MD5_H */
  • src/handlers/new-unpack.c

    diff -X /usr/src/dontdiff -urN nALFS/src/handlers/new-unpack.c nALFS-new/src/handlers/new-unpack.c
    old new  
    3636#include "nalfs.h"
    3737#include "backend.h"
    3838#include "config.h"
     39#include "digest.h"
    3940
    4041
    4142#define El_unpack_reference(el) alloc_trimmed_param_value("reference", el)
    4243#define El_unpack_archive(el) alloc_trimmed_param_value("archive", el)
    4344#define El_unpack_destination(el) alloc_trimmed_param_value("destination", el)
     45#define El_unpack_digest(el) alloc_trimmed_param_value("digest", el)
    4446
    4547
    4648typedef enum extension_e {
    4749        GZ, TAR_GZ, TGZ, BZ2, TAR_BZ2, TAR, ZIP, TAR_Z, Z, UNKNOWN
    4850} extension_e;
    4951
    50 
    51 #ifdef HAVE_LIBSSL
    52 
    53 #define El_unpack_digest(el) alloc_trimmed_param_value("digest", el)
    54 
    55 #include <openssl/evp.h>
    56 
    57 int verify_digest(char* type, char* digest, char* file)
    58 {
    59         EVP_MD_CTX ctx;
    60         const EVP_MD *md;
    61         char buffer[4094];
    62         FILE *istream;
    63         unsigned char md_value[EVP_MAX_MD_SIZE];
    64         char md_value_hex[2*EVP_MAX_MD_SIZE + 1 ];
    65         unsigned int md_len;
    66         int i;
    67         char *s;
    68 
    69 
    70         OpenSSL_add_all_digests();
    71 
    72         md = EVP_get_digestbyname(type);
    73 
    74         EVP_DigestInit(&ctx, md);
    75 
    76         istream = fopen(file, "r");
    77         if (istream) {
    78                 size_t nbbytes;
    79 
    80                 while ((nbbytes = fread(&buffer[0], 1, sizeof(buffer), istream)) != 0) {
    81                         EVP_DigestUpdate(&ctx, &buffer[0], nbbytes);
    82                 }
    83 
    84                 fclose(istream);
    85 
    86                 EVP_DigestFinal(&ctx, &md_value[0], &md_len);
    87 
    88 
    89                 for(i = 0, s = &md_value_hex[0]; i < (int)md_len; s += 2, ++i) {
    90                         sprintf(s, "%02x", md_value[i]);
    91                 }
    92                 *s = 0;
    93 
    94                 if (! strcmp(digest, &md_value_hex[0])) {
    95                         Nprint("Digest ok.");
    96                         return 0;
    97                 }
    98 
    99                 Nprint_err("Expected digest : %s", digest);
    100                 Nprint_err("Found digest    : %s", &md_value_hex[0]);
    101 
    102         } else {
    103                 Nprint_err(
    104                 "Unable to open the archive when checking digest: %s", file);
    105         }
    106 
    107         return -1;
    108 }
    109 
    110 #endif
    111 
    112 
    11352#ifdef HAVE_LIBCURL
    11453
    11554typedef struct output_file_s {
     
    262201char *handler_syntax_versions[] = { "3.0", "3.1", NULL };
    263202// char *handler_attributes[] = { NULL };
    264203char *handler_parameters[] =
    265 #ifdef HAVE_LIBSSL
    266204        { "digest", "reference", "archive", "destination", NULL };
    267 #else
    268         { "reference", "archive", "destination", NULL };
    269 #endif
    270205int handler_action = 1;
    271206
    272207
     
    276211        char *base_name;
    277212        char *archive;
    278213        char *destination;
    279 #ifdef HAVE_LIBSSL
    280214        char *digest;
    281 #endif
    282215        struct stat file_stat;
    283216        extension_e extension = UNKNOWN;
    284217
     
    326259                }
    327260        }
    328261
    329 #ifdef HAVE_LIBSSL
    330262        if ((digest = El_unpack_digest(el)) != NULL) {
    331263                element_s *el2 = first_param("digest", el);
    332264                char *type = attr_value("type", el2);
     
    351283                        return -1;
    352284                }
    353285        }
    354 #endif
    355286
    356287        /* Watch for the order! */
    357288        if (! (strncmp(archive + strlen(archive) - 7, ".tar.gz", 7)))