Use OpenSSL for hashing.

This commit is contained in:
Shawn Webb 2014-02-08 00:31:12 -05:00
parent 9a0221255d
commit b2e7c931d0
184 changed files with 2957 additions and 2213 deletions

View file

@ -156,6 +156,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
$(top_srcdir)/m4/reorganization/libs/curl.m4 \
$(top_srcdir)/m4/reorganization/libs/libconfig.m4 \
$(top_srcdir)/m4/reorganization/libs/xml.m4 \
$(top_srcdir)/m4/reorganization/libs/openssl.m4 \
$(top_srcdir)/m4/reorganization/substitutions.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \

View file

@ -138,6 +138,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
$(top_srcdir)/m4/reorganization/libs/curl.m4 \
$(top_srcdir)/m4/reorganization/libs/libconfig.m4 \
$(top_srcdir)/m4/reorganization/libs/xml.m4 \
$(top_srcdir)/m4/reorganization/libs/openssl.m4 \
$(top_srcdir)/m4/reorganization/substitutions.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \

View file

@ -119,6 +119,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
$(top_srcdir)/m4/reorganization/libs/curl.m4 \
$(top_srcdir)/m4/reorganization/libs/libconfig.m4 \
$(top_srcdir)/m4/reorganization/libs/xml.m4 \
$(top_srcdir)/m4/reorganization/libs/openssl.m4 \
$(top_srcdir)/m4/reorganization/substitutions.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \

View file

@ -27,6 +27,11 @@
#include <sys/time.h>
#endif
#include <stdlib.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "bytecode.h"
#include "bytecode_priv.h"
#include "clamav.h"

View file

@ -137,6 +137,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
$(top_srcdir)/m4/reorganization/libs/curl.m4 \
$(top_srcdir)/m4/reorganization/libs/libconfig.m4 \
$(top_srcdir)/m4/reorganization/libs/xml.m4 \
$(top_srcdir)/m4/reorganization/libs/openssl.m4 \
$(top_srcdir)/m4/reorganization/substitutions.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \

View file

@ -35,6 +35,10 @@
#include <sys/stat.h>
#include <dirent.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "shared/optparser.h"
#include "shared/misc.h"

View file

@ -137,6 +137,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
$(top_srcdir)/m4/reorganization/libs/curl.m4 \
$(top_srcdir)/m4/reorganization/libs/libconfig.m4 \
$(top_srcdir)/m4/reorganization/libs/xml.m4 \
$(top_srcdir)/m4/reorganization/libs/openssl.m4 \
$(top_srcdir)/m4/reorganization/substitutions.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \

View file

@ -53,6 +53,10 @@
#include <sys/resource.h>
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "target.h"
#include "libclamav/clamav.h"

View file

@ -34,6 +34,10 @@
#include <string.h>
#include <errno.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include <linux/fanotify.h>
#include "fan-syscalllib.h"
#include "fan.h"

View file

@ -65,6 +65,10 @@
#endif /* HAVE_POLL_H */
#endif /* HAVE_POLL */
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include <limits.h>
#include "shared/optparser.h"
#include "shared/output.h"

View file

@ -49,6 +49,10 @@
#include <stddef.h>
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "libclamav/clamav.h"
#include "libclamav/others.h"
#include "libclamav/scanners.h"

View file

@ -40,6 +40,10 @@
#include <unistd.h>
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include <fcntl.h>
#ifdef C_SOLARIS
#include <stdio_ext.h>

View file

@ -49,6 +49,10 @@
#include <stddef.h>
#include <limits.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "libclamav/clamav.h"
#include "libclamav/str.h"
#include "libclamav/others.h"

View file

@ -29,6 +29,10 @@
#include <errno.h>
#include <string.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "shared/output.h"
#include "thrmgr.h"

View file

@ -137,6 +137,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
$(top_srcdir)/m4/reorganization/libs/curl.m4 \
$(top_srcdir)/m4/reorganization/libs/libconfig.m4 \
$(top_srcdir)/m4/reorganization/libs/xml.m4 \
$(top_srcdir)/m4/reorganization/libs/openssl.m4 \
$(top_srcdir)/m4/reorganization/substitutions.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \

View file

@ -52,6 +52,10 @@
#include <sys/uio.h>
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "shared/optparser.h"
#include "shared/output.h"
#include "shared/misc.h"

View file

@ -43,6 +43,10 @@
#include <sys/socket.h>
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "libclamav/others.h"
#include "shared/actions.h"
#include "shared/output.h"

View file

@ -119,6 +119,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
$(top_srcdir)/m4/reorganization/libs/curl.m4 \
$(top_srcdir)/m4/reorganization/libs/libconfig.m4 \
$(top_srcdir)/m4/reorganization/libs/xml.m4 \
$(top_srcdir)/m4/reorganization/libs/openssl.m4 \
$(top_srcdir)/m4/reorganization/substitutions.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \

View file

@ -138,6 +138,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
$(top_srcdir)/m4/reorganization/libs/curl.m4 \
$(top_srcdir)/m4/reorganization/libs/libconfig.m4 \
$(top_srcdir)/m4/reorganization/libs/xml.m4 \
$(top_srcdir)/m4/reorganization/libs/openssl.m4 \
$(top_srcdir)/m4/reorganization/substitutions.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \

View file

@ -38,6 +38,10 @@
#include <sys/resource.h>
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "others.h"
#include "global.h"
#include "manager.h"

View file

@ -48,6 +48,10 @@
#include <errno.h>
#include <target.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "manager.h"
#include "global.h"

View file

@ -137,6 +137,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
$(top_srcdir)/m4/reorganization/libs/curl.m4 \
$(top_srcdir)/m4/reorganization/libs/libconfig.m4 \
$(top_srcdir)/m4/reorganization/libs/xml.m4 \
$(top_srcdir)/m4/reorganization/libs/openssl.m4 \
$(top_srcdir)/m4/reorganization/substitutions.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \

View file

@ -3,6 +3,10 @@
#include <unistd.h>
#include <string.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include <curl/curl.h>
#include "libclamav/clamav.h"

127
configure vendored
View file

@ -906,6 +906,7 @@ with_libcurl
with_libconfig
enable_xml
with_xml
with_openssl
'
ac_precious_vars='build_alias
host_alias
@ -1612,6 +1613,8 @@ Optional Packages:
/usr/local or /usr if not found in /usr/local)
--with-xml=DIR path to directory containing libxml2 library (default=
/usr/local or /usr if not found in /usr/local)
--with-openssl=DIR path to directory containing openssl (default=
/usr/local or /usr if not found in /usr/local)
Some influential environment variables:
CC C compiler command
@ -21592,6 +21595,7 @@ CLAMBC_CPPFLAGS="$CLAMBC_CPPFLAGS -I$LIBCONFIG_HOME/include"
LDFLAGS="$save_ldflags"
want_xml="auto"
# Check whether --enable-xml was given.
if test "${enable_xml+set}" = set; then :
@ -21749,6 +21753,129 @@ $as_echo "$as_me: ****** libxml2 support unavailable" >&6;}
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenSSL installation" >&5
$as_echo_n "checking for OpenSSL installation... " >&6; }
# Check whether --with-openssl was given.
if test "${with_openssl+set}" = set; then :
withval=$with_openssl;
if test "$withval"; then
LIBSSL_HOME="$withval"
fi
else
LIBSSL_HOME=/usr/local
if test ! -f "$LIBSSL_HOME/include/openssl/ssl.h"
then
LIBSSL_HOME=/usr
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBSSL_HOME" >&5
$as_echo "$LIBSSL_HOME" >&6; }
fi
if test ! -f "$LIBSSL_HOME/include/openssl/ssl.h"
then
as_fn_error $? "OpenSSL not found." "$LINENO" 5
fi
SSL_LDFLAGS="-L$LIBSSL_HOME/lib -lssl"
SSL_CPPFLAGS="-I$LIBSSL_HOME/include"
save_LDFLAGS="$LDFLAGS"
LDFLAGS="-L$LIBSSL_HOME/lib -lssl"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_library_init in -lssl" >&5
$as_echo_n "checking for SSL_library_init in -lssl... " >&6; }
if ${ac_cv_lib_ssl_SSL_library_init+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lssl $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char SSL_library_init ();
int
main ()
{
return SSL_library_init ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_ssl_SSL_library_init=yes
else
ac_cv_lib_ssl_SSL_library_init=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssl_SSL_library_init" >&5
$as_echo "$ac_cv_lib_ssl_SSL_library_init" >&6; }
if test "x$ac_cv_lib_ssl_SSL_library_init" = xyes; then :
LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS $SSL_LDFLAGS"
else
as_fn_error $? "Your OpenSSL is misconfigured" "$LINENO" 5
fi
LDFLAGS="-L$LIBSSL_HOME/lib -lcrypto"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for EVP_EncryptInit in -lcrypto" >&5
$as_echo_n "checking for EVP_EncryptInit in -lcrypto... " >&6; }
if ${ac_cv_lib_crypto_EVP_EncryptInit+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lcrypto $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char EVP_EncryptInit ();
int
main ()
{
return EVP_EncryptInit ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_crypto_EVP_EncryptInit=yes
else
ac_cv_lib_crypto_EVP_EncryptInit=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_EVP_EncryptInit" >&5
$as_echo "$ac_cv_lib_crypto_EVP_EncryptInit" >&6; }
if test "x$ac_cv_lib_crypto_EVP_EncryptInit" = xyes; then :
LIBCLAMAV_LIBS="$LIBCLAMAV_LIBS -lcrypto"
else
as_fn_error $? "Your OpenSSL installation is misconfigured" "$LINENO" 5
fi
LDFLAGS="$save_LDFLAGS"

View file

@ -123,7 +123,10 @@ m4_include([m4/reorganization/bsd.m4])
dnl Freshclam dependencies
m4_include([m4/reorganization/libs/curl.m4])
m4_include([m4/reorganization/libs/libconfig.m4])
dnl libclamav dependencies
m4_include([m4/reorganization/libs/xml.m4])
m4_include([m4/reorganization/libs/openssl.m4])
m4_include([m4/reorganization/substitutions.m4])

View file

@ -136,6 +136,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
$(top_srcdir)/m4/reorganization/libs/curl.m4 \
$(top_srcdir)/m4/reorganization/libs/libconfig.m4 \
$(top_srcdir)/m4/reorganization/libs/xml.m4 \
$(top_srcdir)/m4/reorganization/libs/openssl.m4 \
$(top_srcdir)/m4/reorganization/substitutions.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \

View file

@ -135,6 +135,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
$(top_srcdir)/m4/reorganization/libs/curl.m4 \
$(top_srcdir)/m4/reorganization/libs/libconfig.m4 \
$(top_srcdir)/m4/reorganization/libs/xml.m4 \
$(top_srcdir)/m4/reorganization/libs/openssl.m4 \
$(top_srcdir)/m4/reorganization/substitutions.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \

View file

@ -137,6 +137,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
$(top_srcdir)/m4/reorganization/libs/curl.m4 \
$(top_srcdir)/m4/reorganization/libs/libconfig.m4 \
$(top_srcdir)/m4/reorganization/libs/xml.m4 \
$(top_srcdir)/m4/reorganization/libs/openssl.m4 \
$(top_srcdir)/m4/reorganization/substitutions.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \

View file

@ -138,6 +138,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
$(top_srcdir)/m4/reorganization/libs/curl.m4 \
$(top_srcdir)/m4/reorganization/libs/libconfig.m4 \
$(top_srcdir)/m4/reorganization/libs/xml.m4 \
$(top_srcdir)/m4/reorganization/libs/openssl.m4 \
$(top_srcdir)/m4/reorganization/substitutions.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \

View file

@ -46,6 +46,10 @@
#include <syslog.h>
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "target.h"
#include "clamav.h"
#include "freshclamcodes.h"

View file

@ -30,7 +30,6 @@
* fails on Solaris because it would require a c99 compiler,
* 500 fails completely on Solaris, and FreeBSD, and w/o _XOPEN_SOURCE
* strptime is not defined on Linux */
#define _GNU_SOURCE
#define __EXTENSIONS
#include <stdio.h>
@ -61,6 +60,10 @@
#include <errno.h>
#include <zlib.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "target.h"
#include "freshclamcodes.h"

View file

@ -1,6 +1,10 @@
/* 7zCrc.c -- CRC32 calculation
2009-11-23 : Igor Pavlov : Public domain */
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "7zCrc.h"
#include "CpuArch.h"

View file

@ -1,6 +1,10 @@
/* 7zCrcOpt.c -- CRC32 calculation : optimized version
2009-11-23 : Igor Pavlov : Public domain */
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "CpuArch.h"
#ifdef MY_CPU_LE

View file

@ -3,6 +3,10 @@
#include <string.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#define _7ZIP_PPMD_SUPPPORT
#include "7z.h"

View file

@ -3,6 +3,10 @@
#include <string.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "7z.h"
#include "7zCrc.h"
#include "CpuArch.h"

View file

@ -1,6 +1,10 @@
/* CpuArch.c -- CPU specific code
2010-10-26: Igor Pavlov : Public domain */
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "CpuArch.h"
#ifdef MY_CPU_X86_OR_AMD64

View file

@ -4,6 +4,10 @@ This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
#include <memory.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "Ppmd7.h"
const Byte PPMD7_kExpEscape[16] = { 25, 14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2 };

View file

@ -2,6 +2,10 @@
2010-03-12 : Igor Pavlov : Public domain
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "Ppmd7.h"
#define kTopValue (1 << 24)

View file

@ -1,35 +0,0 @@
/* Sha256.h -- SHA-256 Hash
2010-06-11 : Igor Pavlov : Public domain */
#ifndef __CRYPTO_SHA256_H
#define __CRYPTO_SHA256_H
#include "Types.h"
EXTERN_C_BEGIN
#define SHA256_DIGEST_SIZE 32
#define __USE_CLAM_SHA256_FOR_7Z__
#ifndef __USE_CLAM_SHA256_FOR_7Z__
typedef struct
{
UInt32 state[8];
UInt64 count;
Byte buffer[64];
} CSha256;
void Sha256_Init(CSha256 *p);
void Sha256_Update(CSha256 *p, const Byte *data, size_t size);
void Sha256_Final(CSha256 *p, Byte *digest);
#else
#include "../sha256.h"
#define CSha256 SHA256_CTX
#define Sha256_Init sha256_init
#define Sha256_Update sha256_update
#define Sha256_Final sha256_final
#endif
EXTERN_C_END
#endif

View file

@ -1,6 +1,10 @@
/* Xz.c - Xz
2009-04-15 : Igor Pavlov : Public domain */
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "7zCrc.h"
#include "CpuArch.h"
#include "Xz.h"
@ -49,7 +53,7 @@ void XzCheck_Init(CXzCheck *p, int mode)
{
case XZ_CHECK_CRC32: p->crc = CRC_INIT_VAL; break;
case XZ_CHECK_CRC64: p->crc64 = CRC64_INIT_VAL; break;
case XZ_CHECK_SHA256: Sha256_Init(&p->sha); break;
case XZ_CHECK_SHA256: EVP_DigestInit(&p->sha, EVP_sha256()); break;
}
}
@ -59,7 +63,7 @@ void XzCheck_Update(CXzCheck *p, const void *data, size_t size)
{
case XZ_CHECK_CRC32: p->crc = CrcUpdate(p->crc, data, size); break;
case XZ_CHECK_CRC64: p->crc64 = Crc64Update(p->crc64, data, size); break;
case XZ_CHECK_SHA256: Sha256_Update(&p->sha, (const Byte *)data, size); break;
case XZ_CHECK_SHA256: EVP_DigestUpdate(&p->sha, (const Byte *)data, size); break;
}
}
@ -79,7 +83,7 @@ int XzCheck_Final(CXzCheck *p, Byte *digest)
break;
}
case XZ_CHECK_SHA256:
Sha256_Final(&p->sha, digest);
EVP_DigestFinal(&p->sha, digest, NULL);
break;
default:
return 0;

View file

@ -4,7 +4,9 @@
#ifndef __XZ_H
#define __XZ_H
#include "Sha256.h"
#include "Types.h"
#define SHA256_DIGEST_SIZE 32
EXTERN_C_BEGIN
@ -79,7 +81,7 @@ typedef struct
int mode;
UInt32 crc;
UInt64 crc64;
CSha256 sha;
EVP_MD_CTX sha;
} CXzCheck;
void XzCheck_Init(CXzCheck *p, int mode);
@ -215,7 +217,7 @@ typedef struct
CMixCoder decoder;
CXzBlock block;
CXzCheck check;
CSha256 sha;
EVP_MD_CTX sha;
Byte shaDigest[SHA256_DIGEST_SIZE];
Byte buf[XZ_BLOCK_HEADER_SIZE_MAX];
} CXzUnpacker;

View file

@ -10,6 +10,10 @@
#include <stdlib.h>
#include <string.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "7zCrc.h"
#include "Alloc.h"
#include "Bra.h"
@ -642,7 +646,7 @@ SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,
Byte temp[32];
unsigned num = Xz_WriteVarInt(temp, p->packSize + p->blockHeaderSize + XzFlags_GetCheckSize(p->streamFlags));
num += Xz_WriteVarInt(temp + num, p->unpackSize);
Sha256_Update(&p->sha, temp, num);
EVP_DigestUpdate(&p->sha, temp, num);
p->indexSize += num;
p->numBlocks++;
@ -677,7 +681,7 @@ SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,
{
RINOK(Xz_ParseHeader(&p->streamFlags, p->buf));
p->state = XZ_STATE_BLOCK_HEADER;
Sha256_Init(&p->sha);
EVP_DigestInit(&p->sha, EVP_sha256());
p->indexSize = 0;
p->numBlocks = 0;
p->pos = 0;
@ -696,8 +700,8 @@ SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,
p->indexPreSize = 1 + Xz_WriteVarInt(p->buf + 1, p->numBlocks);
p->indexPos = p->indexPreSize;
p->indexSize += p->indexPreSize;
Sha256_Final(&p->sha, p->shaDigest);
Sha256_Init(&p->sha);
EVP_DigestFinal(&p->sha, p->shaDigest, NULL);
EVP_DigestInit(&p->sha, EVP_sha256());
p->crc = CrcUpdate(CRC_INIT_VAL, p->buf, p->indexPreSize);
p->state = XZ_STATE_STREAM_INDEX;
}
@ -775,7 +779,7 @@ SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,
if (srcRem > cur)
srcRem = (SizeT)cur;
p->crc = CrcUpdate(p->crc, src, srcRem);
Sha256_Update(&p->sha, src, srcRem);
EVP_DigestUpdate(&p->sha, src, srcRem);
(*srcLen) += srcRem;
src += srcRem;
p->indexPos += srcRem;
@ -796,7 +800,7 @@ SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,
p->state = XZ_STATE_STREAM_INDEX_CRC;
p->indexSize += 4;
p->pos = 0;
Sha256_Final(&p->sha, digest);
EVP_DigestFinal(&p->sha, digest, NULL);
if (memcmp(digest, p->shaDigest, SHA256_DIGEST_SIZE) != 0)
return SZ_ERROR_CRC;
}

View file

@ -3,6 +3,10 @@
#include <string.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "7zCrc.h"
#include "CpuArch.h"
#include "Xz.h"

View file

@ -19,6 +19,10 @@
*/
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "7z_iface.h"
#include "lzma_iface.h"
#include "scanners.h"

View file

@ -73,10 +73,13 @@ endif
libclamav_internal_utils_la_SOURCES=str.c\
str.h\
conv.c \
conv.h \
crypto.c \
crypto.h \
clamav.h \
iowrap.c \
iowrap.h \
md5.c\
md5.h\
others_common.c \
others.h \
qsort.c \
@ -91,15 +94,18 @@ libclamav_internal_utils_la_SOURCES=str.c\
regex/regex2.h \
regex/utils.h
libclamav_internal_utils_la_LDFLAGS=-static
libclamav_internal_utils_la_LDFLAGS=-static @LIBCLAMAV_LIBS@
libclamav_internal_utils_la_CFLAGS=$(AM_CFLAGS) -fPIC -DPIC
libclamav_internal_utils_nothreads_la_SOURCES=str.c\
conv.c \
conv.h \
crypto.c \
crypto.h \
clamav.h \
str.h\
iowrap.c \
iowrap.h \
md5.c\
md5.h\
others_common.c \
others.h \
qsort.c \
@ -114,7 +120,7 @@ libclamav_internal_utils_nothreads_la_SOURCES=str.c\
regex/regex2.h \
regex/utils.h
libclamav_internal_utils_nothreads_la_LDFLAGS=-static
libclamav_internal_utils_nothreads_la_LDFLAGS=-static @LIBCLAMAV_LIBS@
libclamav_internal_utils_nothreads_la_CFLAGS=$(AM_CFLAGS) -DCL_NOTHREADS
if ENABLE_LLVM
@ -143,7 +149,6 @@ endif
include_HEADERS = clamav.h
libclamav_la_SOURCES = \
clamav.h \
matcher-ac.c \
matcher-ac.h \
matcher-bm.c \
@ -325,7 +330,6 @@ libclamav_la_SOURCES = \
7z/XzCrc64.h \
7z/XzDec.c \
7z/XzIn.c \
7z/Sha256.h \
7z/Delta.c \
7z/Delta.h \
7z/Alloc.h \
@ -357,10 +361,6 @@ libclamav_la_SOURCES = \
perflogging.c\
perflogging.h\
default.h\
sha256.c\
sha256.h\
sha1.c\
sha1.h\
bytecode.c\
bytecode.h\
bytecode_vm.c\

View file

@ -148,6 +148,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
$(top_srcdir)/m4/reorganization/libs/curl.m4 \
$(top_srcdir)/m4/reorganization/libs/libconfig.m4 \
$(top_srcdir)/m4/reorganization/libs/xml.m4 \
$(top_srcdir)/m4/reorganization/libs/openssl.m4 \
$(top_srcdir)/m4/reorganization/substitutions.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@ -237,7 +238,6 @@ am_libclamav_la_OBJECTS = libclamav_la-matcher-ac.lo \
libclamav_la-uniq.lo libclamav_la-version.lo \
libclamav_la-mpool.lo libclamav_la-filtering.lo \
libclamav_la-fmap.lo libclamav_la-perflogging.lo \
libclamav_la-sha256.lo libclamav_la-sha1.lo \
libclamav_la-bytecode.lo libclamav_la-bytecode_vm.lo \
libclamav_la-cpio.lo libclamav_la-macho.lo \
libclamav_la-ishield.lo libclamav_la-bytecode_api.lo \
@ -312,8 +312,9 @@ libclamav_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
libclamav_internal_utils_la_LIBADD =
am_libclamav_internal_utils_la_OBJECTS = \
libclamav_internal_utils_la-str.lo \
libclamav_internal_utils_la-conv.lo \
libclamav_internal_utils_la-crypto.lo \
libclamav_internal_utils_la-iowrap.lo \
libclamav_internal_utils_la-md5.lo \
libclamav_internal_utils_la-others_common.lo \
libclamav_internal_utils_la-qsort.lo \
libclamav_internal_utils_la-strlcpy.lo \
@ -330,8 +331,9 @@ libclamav_internal_utils_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
libclamav_internal_utils_nothreads_la_LIBADD =
am_libclamav_internal_utils_nothreads_la_OBJECTS = \
libclamav_internal_utils_nothreads_la-str.lo \
libclamav_internal_utils_nothreads_la-conv.lo \
libclamav_internal_utils_nothreads_la-crypto.lo \
libclamav_internal_utils_nothreads_la-iowrap.lo \
libclamav_internal_utils_nothreads_la-md5.lo \
libclamav_internal_utils_nothreads_la-others_common.lo \
libclamav_internal_utils_nothreads_la-qsort.lo \
libclamav_internal_utils_nothreads_la-strlcpy.lo \
@ -693,10 +695,13 @@ EXTRA_DIST = c++/Makefile.nollvm.in $(am__append_4) regex/engine.c \
@ENABLE_UNRAR_TRUE@IFACEDEP = libclamunrar_iface.la
libclamav_internal_utils_la_SOURCES = str.c\
str.h\
conv.c \
conv.h \
crypto.c \
crypto.h \
clamav.h \
iowrap.c \
iowrap.h \
md5.c\
md5.h\
others_common.c \
others.h \
qsort.c \
@ -711,14 +716,17 @@ libclamav_internal_utils_la_SOURCES = str.c\
regex/regex2.h \
regex/utils.h
libclamav_internal_utils_la_LDFLAGS = -static
libclamav_internal_utils_la_LDFLAGS = -static @LIBCLAMAV_LIBS@
libclamav_internal_utils_la_CFLAGS = $(AM_CFLAGS) -fPIC -DPIC
libclamav_internal_utils_nothreads_la_SOURCES = str.c\
conv.c \
conv.h \
crypto.c \
crypto.h \
clamav.h \
str.h\
iowrap.c \
iowrap.h \
md5.c\
md5.h\
others_common.c \
others.h \
qsort.c \
@ -733,7 +741,7 @@ libclamav_internal_utils_nothreads_la_SOURCES = str.c\
regex/regex2.h \
regex/utils.h
libclamav_internal_utils_nothreads_la_LDFLAGS = -static
libclamav_internal_utils_nothreads_la_LDFLAGS = -static @LIBCLAMAV_LIBS@
libclamav_internal_utils_nothreads_la_CFLAGS = $(AM_CFLAGS) -DCL_NOTHREADS
@ENABLE_LLVM_FALSE@LLVMLIBADD = libclamav_nocxx.la
@ENABLE_LLVM_TRUE@LLVMLIBADD = c++/libclamavcxx.la -lstdc++ -lm
@ -747,7 +755,7 @@ libclamav_la_CFLAGS = $(AM_CFLAGS) $(XML_CPPFLAGS) -DSEARCH_LIBDIR=\"$(libdir)\"
libclamav_la_LDFLAGS = @TH_SAFE@ $(XML_LIBS) -version-info \
@LIBCLAMAV_VERSION@ -no-undefined $(am__append_6)
include_HEADERS = clamav.h
libclamav_la_SOURCES = clamav.h matcher-ac.c matcher-ac.h matcher-bm.c \
libclamav_la_SOURCES = matcher-ac.c matcher-ac.h matcher-bm.c \
matcher-bm.h matcher-hash.c matcher-hash.h matcher.c matcher.h \
others.c others.h readdb.c readdb.h cvd.c cvd.h dsig.c dsig.h \
scanners.c scanners.h textdet.c textdet.h filetypes.c \
@ -780,14 +788,13 @@ libclamav_la_SOURCES = clamav.h matcher-ac.c matcher-ac.h matcher-bm.c \
7z/Bra.c 7z/Bra.h 7z/Bra86.c 7z/CpuArch.h 7z/Lzma2Dec.c \
7z/Lzma2Dec.h 7z/LzmaDec.c 7z/LzmaDec.h 7z/Ppmd.h 7z/Ppmd7.c \
7z/Ppmd7.h 7z/Ppmd7Dec.c 7z/Types.h 7z/Xz.c 7z/Xz.h \
7z/XzCrc64.c 7z/XzCrc64.h 7z/XzDec.c 7z/XzIn.c 7z/Sha256.h \
7z/Delta.c 7z/Delta.h 7z/Alloc.h 7z/BraIA64.c 7z/CpuArch.c \
7z/CpuArch.h 7z/7zCrcOpt.c 7z/RotateDefs.h explode.c explode.h \
textnorm.c textnorm.h dlp.c dlp.h jsparse/js-norm.c \
jsparse/js-norm.h jsparse/lexglobal.h jsparse/textbuf.h uniq.c \
uniq.h version.c version.h mpool.c mpool.h filtering.h \
filtering.c fmap.c fmap.h perflogging.c perflogging.h \
default.h sha256.c sha256.h sha1.c sha1.h bytecode.c \
7z/XzCrc64.c 7z/XzCrc64.h 7z/XzDec.c 7z/XzIn.c 7z/Delta.c \
7z/Delta.h 7z/Alloc.h 7z/BraIA64.c 7z/CpuArch.c 7z/CpuArch.h \
7z/7zCrcOpt.c 7z/RotateDefs.h explode.c explode.h textnorm.c \
textnorm.h dlp.c dlp.h jsparse/js-norm.c jsparse/js-norm.h \
jsparse/lexglobal.h jsparse/textbuf.h uniq.c uniq.h version.c \
version.h mpool.c mpool.h filtering.h filtering.c fmap.c \
fmap.h perflogging.c perflogging.h default.h bytecode.c \
bytecode.h bytecode_vm.c bytecode_priv.h clambc.h cpio.c \
cpio.h macho.c macho.h ishield.c ishield.h type_desc.h \
bcfeatures.h bytecode_api.c bytecode_api_decl.c bytecode_api.h \
@ -964,8 +971,9 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bytecode_nojit.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_la-conv.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_la-crypto.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_la-iowrap.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_la-md5.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_la-others_common.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_la-qsort.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_la-regcomp.Plo@am__quote@
@ -974,8 +982,9 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_la-regfree.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_la-str.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_la-strlcpy.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_nothreads_la-conv.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_nothreads_la-crypto.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_nothreads_la-iowrap.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_nothreads_la-md5.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_nothreads_la-others_common.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_nothreads_la-qsort.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_nothreads_la-regcomp.Plo@am__quote@
@ -1169,8 +1178,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-s_fp_sub.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-scanners.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-sf_base64decode.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-sha1.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-sha256.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-sis.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-special.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-spin.Plo@am__quote@
@ -1920,20 +1927,6 @@ libclamav_la-perflogging.lo: perflogging.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -c -o libclamav_la-perflogging.lo `test -f 'perflogging.c' || echo '$(srcdir)/'`perflogging.c
libclamav_la-sha256.lo: sha256.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -MT libclamav_la-sha256.lo -MD -MP -MF $(DEPDIR)/libclamav_la-sha256.Tpo -c -o libclamav_la-sha256.lo `test -f 'sha256.c' || echo '$(srcdir)/'`sha256.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_la-sha256.Tpo $(DEPDIR)/libclamav_la-sha256.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sha256.c' object='libclamav_la-sha256.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -c -o libclamav_la-sha256.lo `test -f 'sha256.c' || echo '$(srcdir)/'`sha256.c
libclamav_la-sha1.lo: sha1.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -MT libclamav_la-sha1.lo -MD -MP -MF $(DEPDIR)/libclamav_la-sha1.Tpo -c -o libclamav_la-sha1.lo `test -f 'sha1.c' || echo '$(srcdir)/'`sha1.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_la-sha1.Tpo $(DEPDIR)/libclamav_la-sha1.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sha1.c' object='libclamav_la-sha1.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -c -o libclamav_la-sha1.lo `test -f 'sha1.c' || echo '$(srcdir)/'`sha1.c
libclamav_la-bytecode.lo: bytecode.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_la_CFLAGS) $(CFLAGS) -MT libclamav_la-bytecode.lo -MD -MP -MF $(DEPDIR)/libclamav_la-bytecode.Tpo -c -o libclamav_la-bytecode.lo `test -f 'bytecode.c' || echo '$(srcdir)/'`bytecode.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_la-bytecode.Tpo $(DEPDIR)/libclamav_la-bytecode.Plo
@ -2718,6 +2711,20 @@ libclamav_internal_utils_la-str.lo: str.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -c -o libclamav_internal_utils_la-str.lo `test -f 'str.c' || echo '$(srcdir)/'`str.c
libclamav_internal_utils_la-conv.lo: conv.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -MT libclamav_internal_utils_la-conv.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_la-conv.Tpo -c -o libclamav_internal_utils_la-conv.lo `test -f 'conv.c' || echo '$(srcdir)/'`conv.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_internal_utils_la-conv.Tpo $(DEPDIR)/libclamav_internal_utils_la-conv.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='conv.c' object='libclamav_internal_utils_la-conv.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -c -o libclamav_internal_utils_la-conv.lo `test -f 'conv.c' || echo '$(srcdir)/'`conv.c
libclamav_internal_utils_la-crypto.lo: crypto.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -MT libclamav_internal_utils_la-crypto.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_la-crypto.Tpo -c -o libclamav_internal_utils_la-crypto.lo `test -f 'crypto.c' || echo '$(srcdir)/'`crypto.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_internal_utils_la-crypto.Tpo $(DEPDIR)/libclamav_internal_utils_la-crypto.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='crypto.c' object='libclamav_internal_utils_la-crypto.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -c -o libclamav_internal_utils_la-crypto.lo `test -f 'crypto.c' || echo '$(srcdir)/'`crypto.c
libclamav_internal_utils_la-iowrap.lo: iowrap.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -MT libclamav_internal_utils_la-iowrap.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_la-iowrap.Tpo -c -o libclamav_internal_utils_la-iowrap.lo `test -f 'iowrap.c' || echo '$(srcdir)/'`iowrap.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_internal_utils_la-iowrap.Tpo $(DEPDIR)/libclamav_internal_utils_la-iowrap.Plo
@ -2725,13 +2732,6 @@ libclamav_internal_utils_la-iowrap.lo: iowrap.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -c -o libclamav_internal_utils_la-iowrap.lo `test -f 'iowrap.c' || echo '$(srcdir)/'`iowrap.c
libclamav_internal_utils_la-md5.lo: md5.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -MT libclamav_internal_utils_la-md5.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_la-md5.Tpo -c -o libclamav_internal_utils_la-md5.lo `test -f 'md5.c' || echo '$(srcdir)/'`md5.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_internal_utils_la-md5.Tpo $(DEPDIR)/libclamav_internal_utils_la-md5.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='md5.c' object='libclamav_internal_utils_la-md5.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -c -o libclamav_internal_utils_la-md5.lo `test -f 'md5.c' || echo '$(srcdir)/'`md5.c
libclamav_internal_utils_la-others_common.lo: others_common.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -MT libclamav_internal_utils_la-others_common.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_la-others_common.Tpo -c -o libclamav_internal_utils_la-others_common.lo `test -f 'others_common.c' || echo '$(srcdir)/'`others_common.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_internal_utils_la-others_common.Tpo $(DEPDIR)/libclamav_internal_utils_la-others_common.Plo
@ -2788,6 +2788,20 @@ libclamav_internal_utils_nothreads_la-str.lo: str.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_nothreads_la_CFLAGS) $(CFLAGS) -c -o libclamav_internal_utils_nothreads_la-str.lo `test -f 'str.c' || echo '$(srcdir)/'`str.c
libclamav_internal_utils_nothreads_la-conv.lo: conv.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_nothreads_la_CFLAGS) $(CFLAGS) -MT libclamav_internal_utils_nothreads_la-conv.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_nothreads_la-conv.Tpo -c -o libclamav_internal_utils_nothreads_la-conv.lo `test -f 'conv.c' || echo '$(srcdir)/'`conv.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_internal_utils_nothreads_la-conv.Tpo $(DEPDIR)/libclamav_internal_utils_nothreads_la-conv.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='conv.c' object='libclamav_internal_utils_nothreads_la-conv.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_nothreads_la_CFLAGS) $(CFLAGS) -c -o libclamav_internal_utils_nothreads_la-conv.lo `test -f 'conv.c' || echo '$(srcdir)/'`conv.c
libclamav_internal_utils_nothreads_la-crypto.lo: crypto.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_nothreads_la_CFLAGS) $(CFLAGS) -MT libclamav_internal_utils_nothreads_la-crypto.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_nothreads_la-crypto.Tpo -c -o libclamav_internal_utils_nothreads_la-crypto.lo `test -f 'crypto.c' || echo '$(srcdir)/'`crypto.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_internal_utils_nothreads_la-crypto.Tpo $(DEPDIR)/libclamav_internal_utils_nothreads_la-crypto.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='crypto.c' object='libclamav_internal_utils_nothreads_la-crypto.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_nothreads_la_CFLAGS) $(CFLAGS) -c -o libclamav_internal_utils_nothreads_la-crypto.lo `test -f 'crypto.c' || echo '$(srcdir)/'`crypto.c
libclamav_internal_utils_nothreads_la-iowrap.lo: iowrap.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_nothreads_la_CFLAGS) $(CFLAGS) -MT libclamav_internal_utils_nothreads_la-iowrap.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_nothreads_la-iowrap.Tpo -c -o libclamav_internal_utils_nothreads_la-iowrap.lo `test -f 'iowrap.c' || echo '$(srcdir)/'`iowrap.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_internal_utils_nothreads_la-iowrap.Tpo $(DEPDIR)/libclamav_internal_utils_nothreads_la-iowrap.Plo
@ -2795,13 +2809,6 @@ libclamav_internal_utils_nothreads_la-iowrap.lo: iowrap.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_nothreads_la_CFLAGS) $(CFLAGS) -c -o libclamav_internal_utils_nothreads_la-iowrap.lo `test -f 'iowrap.c' || echo '$(srcdir)/'`iowrap.c
libclamav_internal_utils_nothreads_la-md5.lo: md5.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_nothreads_la_CFLAGS) $(CFLAGS) -MT libclamav_internal_utils_nothreads_la-md5.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_nothreads_la-md5.Tpo -c -o libclamav_internal_utils_nothreads_la-md5.lo `test -f 'md5.c' || echo '$(srcdir)/'`md5.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_internal_utils_nothreads_la-md5.Tpo $(DEPDIR)/libclamav_internal_utils_nothreads_la-md5.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='md5.c' object='libclamav_internal_utils_nothreads_la-md5.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_nothreads_la_CFLAGS) $(CFLAGS) -c -o libclamav_internal_utils_nothreads_la-md5.lo `test -f 'md5.c' || echo '$(srcdir)/'`md5.c
libclamav_internal_utils_nothreads_la-others_common.lo: others_common.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_nothreads_la_CFLAGS) $(CFLAGS) -MT libclamav_internal_utils_nothreads_la-others_common.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_nothreads_la-others_common.Tpo -c -o libclamav_internal_utils_nothreads_la-others_common.lo `test -f 'others_common.c' || echo '$(srcdir)/'`others_common.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_internal_utils_nothreads_la-others_common.Tpo $(DEPDIR)/libclamav_internal_utils_nothreads_la-others_common.Plo

View file

@ -28,6 +28,10 @@
#include <string.h>
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "cltypes.h"
#include "others.h"
#include "adc.h"

View file

@ -24,9 +24,11 @@
#include <time.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "asn1.h"
#include "sha1.h"
#include "md5.h"
#include "bignum.h"
#include "matcher-hash.h"
@ -97,37 +99,19 @@ struct cli_asn1 {
};
static int map_sha1(fmap_t *map, const void *data, unsigned int len, uint8_t sha1[SHA1_HASH_SIZE]) {
SHA1Context ctx;
if(!fmap_need_ptr_once(map, data, len)) {
cli_dbgmsg("map_sha1: failed to read hash data\n");
return 1;
}
SHA1Init(&ctx);
while(len) {
unsigned int todo = MIN(len, map->pgsz);
SHA1Update(&ctx, data, todo);
data = (uint8_t *)data + todo;
len -= todo;
}
SHA1Final(&ctx, sha1);
return 0;
return (cl_sha1(data, len, sha1, NULL) == NULL);
}
static int map_md5(fmap_t *map, const void *data, unsigned int len, uint8_t *md5) {
cli_md5_ctx ctx;
if(!fmap_need_ptr_once(map, data, len)) {
cli_dbgmsg("map_md5: failed to read hash data\n");
return 1;
}
cli_md5_init(&ctx);
while(len) {
unsigned int todo = MIN(len, map->pgsz);
cli_md5_update(&ctx, data, len);
data = (uint8_t *)data + todo;
len -= todo;
}
cli_md5_final(md5, &ctx);
return 0;
return (cl_hash_data("md5", data, len, md5, NULL) == NULL);
}
@ -746,8 +730,8 @@ static int asn1_parse_mscat(fmap_t *map, size_t offset, unsigned int size, crtmg
const uint8_t *message, *attrs;
unsigned int dsize, message_size, attrs_size;
cli_crt_hashtype hashtype;
SHA1Context ctx;
cli_crt *x509;
EVP_MD_CTX *ctx;
int result;
int isBlacklisted = 0;
@ -1037,10 +1021,15 @@ static int asn1_parse_mscat(fmap_t *map, size_t offset, unsigned int size, crtmg
break;
}
SHA1Init(&ctx);
SHA1Update(&ctx, "\x31", 1);
SHA1Update(&ctx, attrs + 1, attrs_size - 1);
SHA1Final(&ctx, sha1);
ctx = EVP_MD_CTX_create();
if (!(ctx))
break;
EVP_DigestInit(ctx, EVP_sha1());
EVP_DigestUpdate(ctx, "\x31", 1);
EVP_DigestUpdate(ctx, attrs + 1, attrs_size - 1);
EVP_DigestFinal(ctx, sha1, NULL);
EVP_MD_CTX_destroy(ctx);
if(!fmap_need_ptr_once(map, asn1.content, asn1.size)) {
cli_dbgmsg("asn1_parse_mscat: failed to read encryptedDigest\n");
@ -1278,16 +1267,25 @@ static int asn1_parse_mscat(fmap_t *map, size_t offset, unsigned int size, crtmg
}
if(hashtype == CLI_SHA1RSA) {
SHA1Init(&ctx);
SHA1Update(&ctx, "\x31", 1);
SHA1Update(&ctx, attrs + 1, attrs_size - 1);
SHA1Final(&ctx, sha1);
ctx = EVP_MD_CTX_create();
if (!(ctx))
break;
EVP_DigestInit(ctx, EVP_sha1());
EVP_DigestUpdate(ctx, "\x31", 1);
EVP_DigestUpdate(ctx, attrs + 1, attrs_size - 1);
EVP_DigestFinal(ctx, sha1, NULL);
EVP_MD_CTX_destroy(ctx);
} else {
cli_md5_ctx ctx;
cli_md5_init(&ctx);
cli_md5_update(&ctx, "\x31", 1);
cli_md5_update(&ctx, attrs + 1, attrs_size - 1);
cli_md5_final(sha1, &ctx);
ctx = EVP_MD_CTX_create();
if (!(ctx))
break;
EVP_DigestInit(ctx, EVP_md5());
EVP_DigestUpdate(ctx, "\x31", 1);
EVP_DigestUpdate(ctx, attrs + 1, attrs_size - 1);
EVP_DigestFinal(ctx, sha1, NULL);
EVP_MD_CTX_destroy(ctx);
}
if(!fmap_need_ptr_once(map, asn1.content, asn1.size)) {

View file

@ -19,6 +19,11 @@
*/
#include <string.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "cltypes.h"
#include "execs.h"
#include "others.h"

View file

@ -35,6 +35,10 @@
#include <unistd.h>
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "others.h"
#include "scanners.h"
#include "autoit.h"

View file

@ -25,6 +25,10 @@
#include <string.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "scanners.h"
#include "cltypes.h"
#include "others.h"

View file

@ -44,6 +44,10 @@ static char const rcsid[] = "$Id: blob.c,v 1.64 2007/02/12 22:25:14 njh Exp $";
#include <unistd.h>
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "others.h"
#include "mbox.h"
#include "matcher.h"

View file

@ -24,8 +24,14 @@
#include "clamav-config.h"
#endif
#include <string.h>
#include <assert.h>
#include <fcntl.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "dconf.h"
#include "clamav.h"
#include "others.h"
@ -38,7 +44,6 @@
#include "bytecode_api.h"
#include "bytecode_api_impl.h"
#include "builtin_bytecodes.h"
#include <string.h>
#define MAX_BC 64
#define BC_EVENTS_PER_SIG 2

View file

@ -33,6 +33,11 @@
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "cltypes.h"
#include "clambc.h"
#include "bytecode.h"

View file

@ -23,6 +23,11 @@
#if HAVE_CONFIG_H
#include "clamav-config.h"
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "target.h"
#include "cltypes.h"

View file

@ -22,6 +22,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "cltypes.h"
#include "bytecode.h"
#include "bytecode_priv.h"

View file

@ -22,6 +22,11 @@
#if HAVE_CONFIG_H
#include "clamav-config.h"
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "clamav.h"
#include "others.h"
#include "bytecode.h"

View file

@ -24,6 +24,7 @@
#ifndef _WIN32
#include <sys/time.h>
#endif
#include "ClamBCModule.h"
#include "ClamBCDiagnostics.h"
#include "llvm/Analysis/DebugInfo.h"
@ -126,15 +127,20 @@ void LLVMInitializePowerPCAsmPrinter();
#undef PACKAGE_URL
#include "clamav-config.h"
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
extern "C" {
#include "libclamav/crypto.h"
}
#include "dconf.h"
#include "clamav.h"
#include "clambc.h"
#include "bytecode.h"
#include "bytecode_priv.h"
#include "type_desc.h"
extern "C" {
#include "md5.h"
}
#define MODULE "libclamav JIT: "
@ -2201,15 +2207,12 @@ int cli_vm_execute_jit(const struct cli_all_bc *bcs, struct cli_bc_ctx *ctx,
static unsigned char name_salt[16] = { 16, 38, 97, 12, 8, 4, 72, 196, 217, 144, 33, 124, 18, 11, 17, 253 };
static void setGuard(unsigned char* guardbuf)
{
cli_md5_ctx ctx;
char salt[48];
memcpy(salt, name_salt, 16);
for(unsigned i = 16; i < 48; i++)
salt[i] = cli_rndnum(255);
salt[i] = cli_rndnum(255);
cli_md5_init(&ctx);
cli_md5_update(&ctx, salt, 48);
cli_md5_final(guardbuf, &ctx);
cl_hash_data("md5", salt, 48, guardbuf, NULL);
}
static void addFPasses(FunctionPassManager &FPM, bool trusted, const TargetData *TD)

View file

@ -32,6 +32,10 @@
#endif
#include <fcntl.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "cltypes.h"
#include "others.h"
#include "mspack.h"

View file

@ -27,7 +27,10 @@
#include <pthread.h>
#include <assert.h>
#include "md5.h"
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "mpool.h"
#include "clamav.h"
#include "cache.h"
@ -902,7 +905,7 @@ void cache_remove(unsigned char *md5, size_t size, const struct cl_engine *engin
int cache_check(unsigned char *hash, cli_ctx *ctx) {
fmap_t *map;
size_t todo, at = 0;
cli_md5_ctx md5;
EVP_MD_CTX *hashctx;
int ret;
if(!ctx || !ctx->engine || !ctx->engine->cache)
@ -916,20 +919,30 @@ int cache_check(unsigned char *hash, cli_ctx *ctx) {
map = *ctx->fmap;
todo = map->len;
cli_md5_init(&md5);
hashctx = EVP_MD_CTX_create();
if (!(hashctx))
return CL_VIRUS;
EVP_DigestInit(hashctx, EVP_md5());
while(todo) {
const void *buf;
size_t readme = todo < FILEBUFF ? todo : FILEBUFF;
if(!(buf = fmap_need_off_once(map, at, readme)))
return CL_EREAD;
todo -= readme;
at += readme;
if (cli_md5_update(&md5, buf, readme)) {
cli_errmsg("cache_check: error reading while generating hash!\n");
return CL_EREAD;
}
const void *buf;
size_t readme = todo < FILEBUFF ? todo : FILEBUFF;
if(!(buf = fmap_need_off_once(map, at, readme)))
return CL_EREAD;
todo -= readme;
at += readme;
if (!EVP_DigestUpdate(hashctx, buf, readme)) {
cli_errmsg("cache_check: error reading while generating hash!\n");
return CL_EREAD;
}
}
cli_md5_final(hash, &md5);
EVP_DigestFinal(hashctx, hash, NULL);
EVP_MD_CTX_destroy(hashctx);
ret = cache_lookup_hash(hash, map->len, ctx->engine->cache, ctx->recursion);
cli_dbgmsg("cache_check: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x is %s\n", hash[0], hash[1], hash[2], hash[3], hash[4], hash[5], hash[6], hash[7], hash[8], hash[9], hash[10], hash[11], hash[12], hash[13], hash[14], hash[15], (ret == CL_VIRUS) ? "negative" : "positive");
return ret;

View file

@ -34,6 +34,10 @@
#include <string.h>
#include <errno.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "fmap.h"
#include "others.h"
#include "mspack.h"

189
libclamav/conv.c Normal file
View file

@ -0,0 +1,189 @@
/*
* Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
*
* Author: Shawn Webb
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#if HAVE_CONF_H
#include "clamav-config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <math.h>
#include <sys/types.h>
#include <openssl/bio.h>
#include <openssl/evp.h>
#include "libclamav/conv.h"
#include "libclamav/crypto.h"
/** Get the expected decoded length of a base64-encoded string
* @param[in] data Base64-encoded string
* @param[in] len length of the string
* @return The expected decoded length of the base64-encoded string
*/
static size_t base64_len(const char *data, size_t len)
{
int padding=0;
size_t i;
if (!len)
return 0;
for (i=len-1; i > 0 && data[i] == '='; i--)
padding++;
return (size_t)((3*len)/4 - padding);
}
/** Decode a base64-encoded string
* @param[in] data The base64-encoded string
* @param[in] len Length of the base64-encoded string
* @param[out] obuf If obuf is not set to NULL, store the decoded data in obuf. Otherwise, the decoded data is stored in a dynamically-allocated buffer.
* @param[out] olen The length of the decoded data
* @return The base64-decoded data
*/
void *cl_base64_decode(char *data, size_t len, void *obuf, size_t *olen)
{
BIO *bio, *b64;
void *buf, *ret;
buf = (obuf) ? obuf : malloc(base64_len(data, len)+1);
if (!(buf))
return NULL;
b64 = BIO_new(BIO_f_base64());
if (!(b64)) {
if (!(obuf))
free(buf);
return NULL;
}
bio = BIO_new_mem_buf(data, len);
if (!(bio)) {
BIO_free(b64);
if (!(obuf))
free(buf);
return NULL;
}
bio = BIO_push(b64, bio);
BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL);
*olen = BIO_read(bio, buf, base64_len(data, len));
BIO_free_all(bio);
return buf;
}
/** Base64-encode data
* @param[in] data The data to be encoded
* @param[in] len The length of the data
* @return A pointer to the base64-encoded data. The data is stored in a dynamically-allocated buffer.
*/
char *cl_base64_encode(void *data, size_t len)
{
BIO *bio, *b64;
char *buf, *p;
size_t elen;
b64 = BIO_new(BIO_f_base64());
bio = BIO_new(BIO_s_mem());
bio = BIO_push(b64, bio);
BIO_write(bio, data, len);
BIO_flush(bio);
elen = (size_t)BIO_get_mem_data(bio, &buf);
/* Ensure we're dealing with a NULL-terminated string */
p = (char *)malloc(elen+1);
memcpy((void *)p, (void *)buf, elen);
p[elen] = 0x00;
buf = p;
BIO_free_all(bio);
return buf;
}
#if defined(CONV_SELF_TEST)
int main(int argc, char *argv[])
{
char *plaintext, *encoded, *decoded;
unsigned char *sha_plaintext, *sha_decoded;
size_t len;
int ret=0;
unsigned int shalen;
initialize_crypto();
plaintext = (argv[1]) ? argv[1] : "Hello. This is dog";
sha_plaintext = sha256(plaintext, strlen(plaintext), NULL, NULL);
if (!(sha_plaintext)) {
fprintf(stderr, "Could not generate sha256 of plaintext\n");
return 1;
}
encoded = base64_encode(plaintext, strlen(plaintext));
if (!(encoded)) {
fprintf(stderr, "Could not base64 encode plaintest\n");
return 1;
}
fprintf(stderr, "Base64 encoded: %s\n", encoded);
decoded = base64_decode(encoded, strlen(encoded), NULL, &len);
if (!(decoded)) {
fprintf(stderr, "Could not base64 decoded string\n");
return 1;
}
sha_decoded = sha256(decoded, len, NULL, &shalen);
if (!(sha_decoded)) {
fprintf(stderr, "Could not generate sha256 of decoded data\n");
return 1;
}
if (memcmp(sha_plaintext, sha_decoded, shalen)) {
fprintf(stderr, "Decoded does not match plaintext: %s\n", decoded);
ret = 1;
}
free(sha_decoded);
free(sha_plaintext);
free(encoded);
free(decoded);
cleanup_crypto();
return ret;
}
#endif

27
libclamav/conv.h Normal file
View file

@ -0,0 +1,27 @@
/*
* Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
*
* Author: Shawn Webb
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#if !defined(_CLAMAV_CONV_H)
#define _CLAMAV_CONV_H
void *cl_base64_decode(char *, size_t, void *, size_t *);
char *cl_base64_encode(void *, size_t);
#endif

View file

@ -32,6 +32,10 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "cltypes.h"
#include "others.h"
#include "cpio.h"

View file

@ -22,6 +22,10 @@
#include "clamav-config.h"
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "others.h"
#include "crtmgr.h"

View file

@ -24,7 +24,6 @@
#include <time.h>
#include "bignum.h"
#include "sha1.h"
typedef enum { CLI_SHA1RSA, CLI_MD5RSA } cli_crt_hashtype;
typedef enum {VRFY_CODE, VRFY_TIME} cli_vrfy_type;

1021
libclamav/crypto.c Normal file

File diff suppressed because it is too large Load diff

277
libclamav/crypto.h Normal file
View file

@ -0,0 +1,277 @@
/*
* Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
*
* Author: Shawn Webb
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#if !defined(_CLAMAV_CRYPTO_H)
#define _CLAMAV_CRYPTO_H
/**
* \defgroup CryptoAPI ClamAV Crypto API
* @{
*/
#define SHA1_HASH_SIZE 20
#define SHA256_HASH_SIZE 32
/**
* Initialize the crypto system.
* @return Always returns 0
*/
int cl_initialize_crypto(void);
/** Clean up the crypto system prior to program exit.
*/
void cl_cleanup_crypto(void);
/** Generate a hash of data.
@param[in] alg The hashing algorithm to use
@param[in] buf The data to be hashed
@param[in] len The length of the to-be-hashed data
@param[out] obuf An optional buffer to store the generated hash. Use NULL to dynamically allocate buffer.
@param[out] olen An optional pointer that stores how long the generated hash is.
@return A pointer to the generated hash or obuf if obuf is not NULL.
*/
unsigned char *cl_hash_data(char *alg, const void *buf, size_t len, unsigned char *obuf, unsigned int *olen);
/** Generate a hash of a file.
@param[in] ctx A pointer to the OpenSSL EVP_MD_CTX object
@param[in] fd The file descriptor
@param[out] olen An optional pointer that stores how long the generated hash is
@return A pointer to a dynamically-created buffer that holds the generated hash
*/
unsigned char *cl_hash_file_fd_ctx(EVP_MD_CTX *ctx, int fd, unsigned int *olen);
/** Generate a hash of a file.
@param[in] fd The file descriptor
@param[in] alg The hashing algorithm to use
@param[out] olen An optional pointer that stores how long the generated hash is
@return A pointer to a dynamically-created buffer that holds the generated hash
*/
unsigned char *cl_hash_file_fd(int fd, char *alg, unsigned int *olen);
/** Generate a hash of a file.
@param[in] fp A pointer to a FILE object
@param[in] alg The hashing algorithm to use
@param[out] olen An optional pointer that stores how long the generated hash is
@return A pointer to a dynamically-created buffer that holds the generated hash
*/
unsigned char *cl_hash_file_fp(FILE *fp, char *alg, unsigned int *olen);
/** Generate a sha256 hash of data
@param[in] buf The data to hash
@param[in] len The length of the to-be-hashed data
@param[out] obuf An optional pointer to store the generated hash. Use NULL to dynamically allocate buffer.
@param[out] olen An optional pointer that stores how long the generated hash is.
@return A pointer to the buffer that holds the generated hash
*/
unsigned char *cl_sha256(const void *buf, size_t len, unsigned char *obuf, unsigned int *olen);
/** Generate a sha1 hash of data
@param[in] buf The data to hash
@param[in] len The length of the to-be-hashed data
@param[out] obuf An optional pointer to store the generated hash. Use NULL to dynamically allocate buffer.
@param[out] olen An optional pointer that stores how long the generated hash is.
@return A pointer to the buffer that holds the generated hash or obuf if obuf is not NULL
*/
unsigned char *cl_sha1(const void *buf, size_t len, unsigned char *obuf, unsigned int *olen);
/** Verify validity of signed data
@param[in] pkey The public key of the keypair that signed the data
@param[in] alg The algorithm used to hash the data
@param[in] sig The signature block
@param[in] siglen The length of the signature
@param[in] data The data that was signed
@param[in] datalen The length of the data
@param[in] decode Whether or not to base64-decode the signature prior to verification. 1 for yes, 0 for no.
@return 0 for success, -1 for error or invalid signature
*/
int cl_verify_signature(EVP_PKEY *pkey, char *alg, unsigned char *sig, unsigned int siglen, unsigned char *data, size_t datalen, int decode);
/** Verify validity of signed data
@param[in] pkey The public key of the keypair that signed the data
@param[in] alg The algorithm used to hash the data
@param[in] sig The signature block
@param[in] siglen The length of the signature
@param[in] digest The hash of the signed data
@return 0 for success, -1 for error or invalid signature
*/
int cl_verify_signature_hash(EVP_PKEY *pkey, char *alg, unsigned char *sig, unsigned int siglen, unsigned char *digest);
/** Verify validity of signed data
@param[in] pkey The public key of the keypair that signed the data
@param[in] alg The algorithm used to hash the data
@param[in] sig The signature block
@param[in] siglen The length of the signature
@param[in] fd The file descriptor
@return 0 for success, -1 for error or invalid signature
*/
int cl_verify_signature_fd(EVP_PKEY *pkey, char *alg, unsigned char *sig, unsigned int siglen, int fd);
/** Verify validity of signed data
@param[in] x509path The path to the public key of the keypair that signed the data
@param[in] alg The algorithm used to hash the data
@param[in] sig The signature block
@param[in] siglen The length of the signature
@param[in] digest The hash of the signed data
@return 0 for success, -1 for error or invalid signature
*/
int cl_verify_signature_hash_x509_keyfile(char *x509path, char *alg, unsigned char *sig, unsigned int siglen, unsigned char *digest);
/** Verify validity of signed data
@param[in] x509path The path to the public key of the keypair that signed the data
@param[in] alg The algorithm used to hash the data
@param[in] sig The signature block
@param[in] siglen The length of the signature
@param[in] fd The file descriptor
@return 0 for success, -1 for error or invalid signature
*/
int cl_verify_signature_fd_x509_keyfile(char *x509path, char *alg, unsigned char *sig, unsigned int siglen, int fd);
/** Verify validity of signed data
@param[in] x509path The path to the public key of the keypair that signed the data
@param[in] alg The algorithm used to hash the data
@param[in] sig The signature block
@param[in] siglen The length of the signature
@param[in] data The data that was signed
@param[in] datalen The length of the data
@param[in] decode Whether or not to base64-decode the signature prior to verification. 1 for yes, 0 for no.
@return 0 for success, -1 for error or invalid signature
*/
int cl_verify_signature_x509_keyfile(char *x509path, char *alg, unsigned char *sig, unsigned int siglen, unsigned char *data, size_t datalen, int decode);
/** Verify validity of signed data
@param[in] x509 The X509 object of the public key of the keypair that signed the data
@param[in] alg The algorithm used to hash the data
@param[in] sig The signature block
@param[in] siglen The length of the signature
@param[in] digest The hash of the signed data
@return 0 for success, -1 for error or invalid signature
*/
int cl_verify_signature_hash_x509(X509 *x509, char *alg, unsigned char *sig, unsigned int siglen, unsigned char *digest);
/** Verify validity of signed data
@param[in] x509 The X509 object of the public key of the keypair that signed the data
@param[in] alg The algorithm used to hash the data
@param[in] sig The signature block
@param[in] siglen The length of the signature
@param[in] fd The file descriptor
@return 0 for success, -1 for error or invalid signature
*/
int cl_verify_signature_fd_x509(X509 *x509, char *alg, unsigned char *sig, unsigned int siglen, int fd);
/** Verify validity of signed data
@param[in] x509 The X509 object of the public key of the keypair that signed the data
@param[in] alg The algorithm used to hash the data
@param[in] sig The signature block
@param[in] siglen The length of the signature
@param[in] data The data that was signed
@param[in] datalen The length of the data
@param[in] decode Whether or not to base64-decode the signature prior to verification. 1 for yes, 0 for no.
@return 0 for success, -1 for error or invalid signature
*/
int cl_verify_signature_x509(X509 *x509, char *alg, unsigned char *sig, unsigned int siglen, unsigned char *data, size_t datalen, int decode);
/** Get an X509 object from memory
* @param[in] data A pointer to a spot in memory that contains the PEM X509 cert
* @param[in] len The length of the data
* @return a pointer to the X509 object on success, NULL on error
*/
X509 *cl_get_x509_from_mem(void *data, unsigned int len);
/** Validate an X509 certificate chain, with the chain being located in a directory
@param[in] tsdir The path to the trust store directory
@param[in] certpath The path to the X509 certificate to be validated.
@return 0 for success, -1 for error or invalid certificate.
*/
int cl_validate_certificate_chain_ts_dir(char *tsdir, char *certpath);
/** Validate an X509 certificate chain with support for a CRL
@param[in] authorities A NULL-terminated array of strings that hold the path of the CA's X509 certificate
@param[in] crlpath An optional path to the CRL file. NULL if no CRL.
@param[in] certpath The path to the X509 certificate to be validated.
@return 0 for success, -1 for error or invalid certificate.
*/
int cl_validate_certificate_chain(char **authorities, char *crlpath, char *certpath);
/** Load an X509 certificate from a file
@param[in] certpath The path to the X509 certificate
*/
X509 *cl_load_cert(const char *certpath);
/** Parse an ASN1_TIME object
@param[in] timeobj The ASN1_TIME object
@return A pointer to a (struct tm). Adjusted for time zone and daylight savings time.
*/
struct tm *cl_ASN1_GetTimeT(ASN1_TIME *timeobj);
/** Load a CRL file into an X509_CRL object
@param[in] file The path to the CRL
@return A pointer to an X509_CRL object or NULL on error.
*/
X509_CRL *cl_load_crl(const char *timeobj);
/** Sign data with a key stored on disk
@param[in] keypath The path to the RSA private key
@param[in] alg The hash/signature algorithm to use
@param[in] hash The hash to sign
@param[out] olen A pointer that stores the size of the signature
@param[in] Whether or not to base64-encode the signature. 1 for yes, 0 for no.
@return The generated signature
*/
unsigned char *cl_sign_data_keyfile(char *keypath, char *alg, unsigned char *hash, unsigned int *olen, int encode);
/** Sign data with an RSA private key object
@param[in] pkey The RSA private key object
@param[in] alg The hash/signature algorithm to use
@param[in] hash The hash to sign
@param[out] olen A pointer that stores the size of the signature
@param[in] Whether or not to base64-encode the signature. 1 for yes, 0 for no.
@return The generated signature
*/
unsigned char *cl_sign_data(EVP_PKEY *pkey, char *alg, unsigned char *hash, unsigned int *olen, int encode);
/** Sign a file with an RSA private key object
@param[in] fd The file descriptor
@param[in] pkey The RSA private key object
@param[in] alg The hash/signature algorithm to use
@param[out] olen A pointer that stores the size of the signature
@param[in] encode Whether or not to base64-encode the signature. 1 for yes, 0 for no.
*/
unsigned char *cl_sign_file_fd(int fd, EVP_PKEY *pkey, char *alg, unsigned int *olen, int encode);
/** Sign a file with an RSA private key object
@param[in] fp A pointer to a FILE object
@param[in] pkey The RSA private key object
@param[in] alg The hash/signature algorithm to use
@param[out] olen A pointer that stores the size of the signature
@param[in] encode Whether or not to base64-encode the signature. 1 for yes, 0 for no.
*/
unsigned char *cl_sign_file_fp(FILE *fp, EVP_PKEY *pkey, char *alg, unsigned int *olen, int encode);
/** Get the Private Key stored on disk
* @param[in] keypath The path on disk where the private key is stored
* @return A pointer to the EVP_PKEY object that contains the private key in memory
*/
EVP_PKEY *cl_get_pkey_file(char *keypath);
/**
* @}
*/
#endif

View file

@ -35,6 +35,10 @@
#include <time.h>
#include <errno.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "clamav.h"
#include "others.h"
#include "dsig.h"
@ -42,7 +46,6 @@
#include "cvd.h"
#include "readdb.h"
#include "default.h"
#include "sha256.h"
#define TAR_BLOCKSIZE 512
@ -312,7 +315,12 @@ static int cli_tgzload(int fd, struct cl_engine *engine, unsigned int *signo, un
dbio->readsize = dbio->size < dbio->bufsize ? dbio->size : dbio->bufsize - 1;
dbio->bufpt = NULL;
dbio->readpt = dbio->buf;
sha256_init(&dbio->sha256ctx);
dbio->hashctx = EVP_MD_CTX_create();
if (!(dbio->hashctx)) {
cli_tgzload_cleanup(compr, dbio, fdd);
return CL_EMALFDB;;
}
EVP_DigestInit(dbio->hashctx, EVP_sha256());
dbio->bread = 0;
/* cli_dbgmsg("cli_tgzload: Loading %s, size: %u\n", name, size); */
@ -346,7 +354,7 @@ static int cli_tgzload(int fd, struct cl_engine *engine, unsigned int *signo, un
cli_tgzload_cleanup(compr, dbio, fdd);
return CL_EMALFDB;
}
sha256_final(&dbio->sha256ctx, hash);
EVP_DigestFinal(dbio->hashctx, hash, NULL);
if(memcmp(db->hash, hash, 32)) {
cli_errmsg("cli_tgzload: Invalid checksum for file %s\n", name);
cli_tgzload_cleanup(compr, dbio, fdd);

View file

@ -25,8 +25,6 @@
#include <zlib.h>
#include "clamav.h"
#include "sha256.h"
struct cli_dbio {
gzFile gzs;
FILE *fs;
@ -34,7 +32,7 @@ struct cli_dbio {
char *buf, *bufpt, *readpt;
unsigned int usebuf, bufsize, readsize;
unsigned int chkonly;
SHA256_CTX sha256ctx;
EVP_MD_CTX *hashctx;
};
int cli_cvdload(FILE *fs, struct cl_engine *engine, unsigned int *signo, unsigned int options, unsigned int dbtype, const char *filename, unsigned int chkonly);

View file

@ -29,6 +29,10 @@
#include <ctype.h>
#include <zlib.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "clamav.h"
#include "cltypes.h"
#include "dconf.h"

View file

@ -26,6 +26,10 @@
#include <string.h>
#include <assert.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "others.h"
#include "disasmpriv.h"

View file

@ -24,6 +24,10 @@
#include "clamav-config.h"
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include <stdio.h>
#include <ctype.h>
#include <string.h>

View file

@ -49,6 +49,10 @@
#include <libxml/xmlreader.h>
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "cltypes.h"
#include "others.h"
#include "dmg.h"

View file

@ -27,12 +27,15 @@
#include <stdlib.h>
#include <ctype.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "clamav.h"
#include "others.h"
#include "dsig.h"
#include "str.h"
#include "bignum.h"
#include "sha256.h"
#define CLI_NSTR "118640995551645342603070001658453189751527774412027743746599405743243142607464144767361060640655844749760788890022283424922762488917565551002467771109669598189410434699034532232228621591089508178591428456220796841621637175567590476666928698770143328137383952820383197532047771780196576957695822641224262693037"
@ -108,7 +111,6 @@ int cli_versig(const char *md5, const char *dsig)
mp_int n, e;
char *pt, *pt2;
if(strlen(md5) != 32 || !isalnum(md5[0])) {
/* someone is trying to fool us with empty/malformed MD5 ? */
cli_errmsg("SECURITY WARNING: MD5 basic test failure.\n");
@ -156,7 +158,7 @@ int cli_versig2(const unsigned char *sha256, const char *dsig_str, const char *n
unsigned char *decoded, digest1[HASH_LEN], digest2[HASH_LEN], digest3[HASH_LEN], *salt;
unsigned char mask[BLK_LEN], data[BLK_LEN], final[8 + 2 * HASH_LEN], c[4];
unsigned int i, rounds;
SHA256_CTX ctx;
EVP_MD_CTX *ctx;
mp_int n, e;
mp_init(&e);
@ -184,10 +186,16 @@ int cli_versig2(const unsigned char *sha256, const char *dsig_str, const char *n
for(i = 0; i < rounds; i++) {
c[2] = (unsigned char) (i / 256);
c[3] = (unsigned char) i;
sha256_init(&ctx);
sha256_update(&ctx, digest2, HASH_LEN);
sha256_update(&ctx, c, 4);
sha256_final(&ctx, digest3);
ctx = EVP_MD_CTX_create();
if (!(ctx))
return CL_EVERIFY;
EVP_DigestInit(ctx, EVP_sha256());
EVP_DigestUpdate(ctx, digest2, HASH_LEN);
EVP_DigestUpdate(ctx, c, 4);
EVP_DigestFinal(ctx, digest3, NULL);
EVP_MD_CTX_destroy(ctx);
if(i + 1 == rounds)
memcpy(&data[i * 32], digest3, BLK_LEN - i * HASH_LEN);
else
@ -209,9 +217,14 @@ int cli_versig2(const unsigned char *sha256, const char *dsig_str, const char *n
memcpy(&final[8], sha256, HASH_LEN);
memcpy(&final[8 + HASH_LEN], salt, SALT_LEN);
sha256_init(&ctx);
sha256_update(&ctx, final, sizeof(final));
sha256_final(&ctx, digest1);
ctx = EVP_MD_CTX_create();
if (!(ctx))
return CL_EVERIFY;
EVP_DigestInit(ctx, EVP_sha256());
EVP_DigestUpdate(ctx, final, sizeof(final));
EVP_DigestFinal(ctx, digest1, NULL);
EVP_MD_CTX_destroy(ctx);
return memcmp(digest1, digest2, HASH_LEN) ? CL_EVERIFY : CL_SUCCESS;
}

View file

@ -33,6 +33,10 @@
#endif
#include <time.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "cltypes.h"
#include "elf.h"
#include "clamav.h"

View file

@ -35,6 +35,10 @@
#include <assert.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "clamav.h"
#include "others.h"
#include "htmlnorm.h"

View file

@ -19,14 +19,20 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#ifndef _WIN32
#include <sys/time.h>
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "events.h"
#include "others.h"
#include "7z/7zCrc.h"
#include "str.h"
#include <string.h>
#ifndef _WIN32
#include <sys/time.h>
#endif
struct cli_event {
const char *name;

View file

@ -38,6 +38,10 @@
#include <string.h>
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "explode.h"
#include "others.h"

View file

@ -30,6 +30,10 @@
#include <unistd.h>
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "clamav.h"
#include "filetypes.h"
#include "others.h"

View file

@ -22,6 +22,11 @@
#if HAVE_CONFIG_H
#include "clamav-config.h"
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "filtering.h"
#include "matcher-ac.h"
#include <string.h>

View file

@ -41,6 +41,10 @@
#include <pthread.h>
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "others.h"
#include "cltypes.h"

View file

@ -18,6 +18,10 @@
* MA 02110-1301, USA.
*/
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "others.h"
#include "fpu.h"

View file

@ -40,6 +40,10 @@
#include <stdlib.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "cltypes.h"
#include "rebuildpe.h"
#include "others.h"

View file

@ -31,6 +31,10 @@
#include <fcntl.h>
#include <zlib.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "cltypes.h"
#include "others.h"
#include "gpt.h"

View file

@ -25,6 +25,10 @@
#include <stdio.h>
#include <string.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "cltypes.h"
#include "clamav.h"
#include "others.h"

View file

@ -22,6 +22,10 @@
#include "clamav-config.h"
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "cltypes.h"
#include "others.h"
#include "hfsplus.h"

View file

@ -53,8 +53,11 @@
#include <errno.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "hostid.h"
#include "libclamav/md5.h"
#include "libclamav/others.h"
struct device *get_device_entry(struct device *devices, size_t *ndevices, const char *name)
@ -245,8 +248,8 @@ char *internal_get_host_id(void)
size_t i;
unsigned char raw_md5[16];
char *printable_md5;
cli_md5_ctx ctx;
struct device *devices;
EVP_MD_CTX ctx;
devices = get_devices();
if (!(devices))
@ -256,11 +259,11 @@ char *internal_get_host_id(void)
if (!(printable_md5))
return NULL;
cli_md5_init(&ctx);
EVP_DigestInit(&ctx, EVP_md5());
for (i=0; devices[i].name != NULL; i++)
cli_md5_update(&ctx, devices[i].mac, sizeof(devices[i].mac));
EVP_DigestUpdate(&ctx, devices[i].mac, sizeof(devices[i].mac));
cli_md5_final(raw_md5, &ctx);
EVP_DigestFinal(&ctx, raw_md5, NULL);
for (i=0; devices[i].name != NULL; i++)
free(devices[i].name);

View file

@ -40,6 +40,10 @@
#include <stdio.h>
#include <ctype.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "fmap.h"
#include "others.h"
#include "htmlnorm.h"

View file

@ -48,6 +48,10 @@ const char inflate64_copyright[] =
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "inflate64_priv.h"
#include <stdlib.h> /* calloc/free */

View file

@ -20,6 +20,10 @@
#include <sys/types.h>
#include "is_tar.h"
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "others.h"
#define isodigit(c) ( ((c) >= '0') && ((c) <= '7') )

View file

@ -42,6 +42,10 @@
#endif
#include <zlib.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "scanners.h"
#include "cltypes.h"
#include "others.h"

View file

@ -19,6 +19,11 @@
*/
#include <string.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "scanners.h"
#include "iso9660.h"
#include "fmap.h"

View file

@ -33,6 +33,10 @@
#endif
#include <time.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "cltypes.h"
#include "jpeg.h"
#include "clamav.h"

View file

@ -29,6 +29,10 @@
#include <sys/types.h>
#include <errno.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "libclamav/others.h"
#include "libclamav/clamav.h"

View file

@ -34,6 +34,10 @@
#include <ctype.h>
#include <assert.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "cltypes.h"
#include "jsparse/lexglobal.h"
#include "hashtab.h"

View file

@ -164,12 +164,6 @@ CLAMAV_PRIVATE {
cli_ftw;
cli_unlink;
cli_writen;
SHA1Init;
SHA1Update;
SHA1Final;
sha256_init;
sha256_update;
sha256_final;
cli_url_canon;
cli_strerror;
decodeLine;
@ -204,6 +198,36 @@ CLAMAV_PRIVATE {
cli_disasm_one;
cli_utf16_to_utf8;
get_fpu_endian;
cl_initialize_crypto;
cl_cleanup_crypto;
cl_hash_data;
cl_hash_file_fd;
cl_hash_file_fp;
cl_hash_file_fd_ctx;
cl_sha256;
cl_sha1;
cl_verify_signature;
cl_verify_signature_x509_keyfile;
cl_verify_signature_x509;
cl_get_x509_from_mem;
cl_validate_certificate_chain_ts_dir;
cl_validate_certificate_chain;
cl_verify_signature_fd;
cl_verify_signature_fd_x509;
cl_verify_signature_fd_x509_keyfile;
cl_verify_signature_hash;
cl_verify_signature_hash_x509;
cl_verify_signature_hash_x509_keyfile;
cl_load_cert;
cl_ASN1_GetTimeT;
cl_load_crl;
sl_sign_data_keyfile;
cl_sign_data;
cl_sign_file_fd;
cl_sign_file_fp;
cl_get_pkey_file;
cl_base64_decode;
cl_base64_encode;
local:
*;
};

View file

@ -63,6 +63,10 @@ static char const rcsid[] = "$Id: line.c,v 1.11 2007/02/12 20:46:08 njh Exp $";
#include <string.h>
#include <assert.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "line.h"
#include "others.h"

View file

@ -24,6 +24,10 @@
#include "clamav-config.h"
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "lzma_iface.h"
void *__lzma_wrap_alloc(void *unused, size_t size) {

View file

@ -28,6 +28,10 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "libclamav/crypto.h"
#include "clamav.h"
#include "cltypes.h"
#include "others.h"

Some files were not shown because too many files have changed in this diff Show more