compute sha256
sha collector - build system
... | ... |
@@ -404,6 +404,9 @@ |
404 | 404 |
/* This value is set to 1 to indicate that the system argz facility works */ |
405 | 405 |
#undef HAVE_WORKING_ARGZ |
406 | 406 |
|
407 |
+/* For internal use only - DO NOT DEFINE */ |
|
408 |
+#undef HAVE__INTERNAL__SHA_COLLECT |
|
409 |
+ |
|
407 | 410 |
/* "Full library version number" */ |
408 | 411 |
#undef LIBCLAMAV_FULLVER |
409 | 412 |
|
... | ... |
@@ -754,6 +754,8 @@ am__EXEEXT_FALSE |
754 | 754 |
am__EXEEXT_TRUE |
755 | 755 |
LTLIBOBJS |
756 | 756 |
LIBOBJS |
757 |
+BUILD_SHA1_FALSE |
|
758 |
+BUILD_SHA1_TRUE |
|
757 | 759 |
subdirs |
758 | 760 |
HAVE_CURSES_FALSE |
759 | 761 |
HAVE_CURSES_TRUE |
... | ... |
@@ -985,6 +987,7 @@ with_libncurses_prefix |
985 | 985 |
with_libpdcurses_prefix |
986 | 986 |
enable_distcheck_werror |
987 | 987 |
enable_llvm |
988 |
+enable_sha_collector_for_internal_use |
|
988 | 989 |
' |
989 | 990 |
ac_precious_vars='build_alias |
990 | 991 |
host_alias |
... | ... |
@@ -1660,6 +1663,7 @@ Optional Features: |
1660 | 1660 |
enable warnings as error for distcheck [default=no] |
1661 | 1661 |
--enable-llvm Enable 'llvm' JIT/verifier support [default=auto] |
1662 | 1662 |
|
1663 |
+ |
|
1663 | 1664 |
Optional Packages: |
1664 | 1665 |
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes] |
1665 | 1666 |
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) |
... | ... |
@@ -5167,13 +5171,13 @@ if test "${lt_cv_nm_interface+set}" = set; then : |
5167 | 5167 |
else |
5168 | 5168 |
lt_cv_nm_interface="BSD nm" |
5169 | 5169 |
echo "int some_variable = 0;" > conftest.$ac_ext |
5170 |
- (eval echo "\"\$as_me:5170: $ac_compile\"" >&5) |
|
5170 |
+ (eval echo "\"\$as_me:5174: $ac_compile\"" >&5) |
|
5171 | 5171 |
(eval "$ac_compile" 2>conftest.err) |
5172 | 5172 |
cat conftest.err >&5 |
5173 |
- (eval echo "\"\$as_me:5173: $NM \\\"conftest.$ac_objext\\\"\"" >&5) |
|
5173 |
+ (eval echo "\"\$as_me:5177: $NM \\\"conftest.$ac_objext\\\"\"" >&5) |
|
5174 | 5174 |
(eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) |
5175 | 5175 |
cat conftest.err >&5 |
5176 |
- (eval echo "\"\$as_me:5176: output\"" >&5) |
|
5176 |
+ (eval echo "\"\$as_me:5180: output\"" >&5) |
|
5177 | 5177 |
cat conftest.out >&5 |
5178 | 5178 |
if $GREP 'External.*some_variable' conftest.out > /dev/null; then |
5179 | 5179 |
lt_cv_nm_interface="MS dumpbin" |
... | ... |
@@ -6368,7 +6372,7 @@ ia64-*-hpux*) |
6368 | 6368 |
;; |
6369 | 6369 |
*-*-irix6*) |
6370 | 6370 |
# Find out which ABI we are using. |
6371 |
- echo '#line 6371 "configure"' > conftest.$ac_ext |
|
6371 |
+ echo '#line 6375 "configure"' > conftest.$ac_ext |
|
6372 | 6372 |
if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 |
6373 | 6373 |
(eval $ac_compile) 2>&5 |
6374 | 6374 |
ac_status=$? |
... | ... |
@@ -7896,11 +7900,11 @@ else |
7896 | 7896 |
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ |
7897 | 7897 |
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ |
7898 | 7898 |
-e 's:$: $lt_compiler_flag:'` |
7899 |
- (eval echo "\"\$as_me:7899: $lt_compile\"" >&5) |
|
7899 |
+ (eval echo "\"\$as_me:7903: $lt_compile\"" >&5) |
|
7900 | 7900 |
(eval "$lt_compile" 2>conftest.err) |
7901 | 7901 |
ac_status=$? |
7902 | 7902 |
cat conftest.err >&5 |
7903 |
- echo "$as_me:7903: \$? = $ac_status" >&5 |
|
7903 |
+ echo "$as_me:7907: \$? = $ac_status" >&5 |
|
7904 | 7904 |
if (exit $ac_status) && test -s "$ac_outfile"; then |
7905 | 7905 |
# The compiler can only warn and ignore the option if not recognized |
7906 | 7906 |
# So say no if there are warnings other than the usual output. |
... | ... |
@@ -8235,11 +8239,11 @@ else |
8235 | 8235 |
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ |
8236 | 8236 |
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ |
8237 | 8237 |
-e 's:$: $lt_compiler_flag:'` |
8238 |
- (eval echo "\"\$as_me:8238: $lt_compile\"" >&5) |
|
8238 |
+ (eval echo "\"\$as_me:8242: $lt_compile\"" >&5) |
|
8239 | 8239 |
(eval "$lt_compile" 2>conftest.err) |
8240 | 8240 |
ac_status=$? |
8241 | 8241 |
cat conftest.err >&5 |
8242 |
- echo "$as_me:8242: \$? = $ac_status" >&5 |
|
8242 |
+ echo "$as_me:8246: \$? = $ac_status" >&5 |
|
8243 | 8243 |
if (exit $ac_status) && test -s "$ac_outfile"; then |
8244 | 8244 |
# The compiler can only warn and ignore the option if not recognized |
8245 | 8245 |
# So say no if there are warnings other than the usual output. |
... | ... |
@@ -8340,11 +8344,11 @@ else |
8340 | 8340 |
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ |
8341 | 8341 |
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ |
8342 | 8342 |
-e 's:$: $lt_compiler_flag:'` |
8343 |
- (eval echo "\"\$as_me:8343: $lt_compile\"" >&5) |
|
8343 |
+ (eval echo "\"\$as_me:8347: $lt_compile\"" >&5) |
|
8344 | 8344 |
(eval "$lt_compile" 2>out/conftest.err) |
8345 | 8345 |
ac_status=$? |
8346 | 8346 |
cat out/conftest.err >&5 |
8347 |
- echo "$as_me:8347: \$? = $ac_status" >&5 |
|
8347 |
+ echo "$as_me:8351: \$? = $ac_status" >&5 |
|
8348 | 8348 |
if (exit $ac_status) && test -s out/conftest2.$ac_objext |
8349 | 8349 |
then |
8350 | 8350 |
# The compiler can only warn and ignore the option if not recognized |
... | ... |
@@ -8395,11 +8399,11 @@ else |
8395 | 8395 |
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ |
8396 | 8396 |
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ |
8397 | 8397 |
-e 's:$: $lt_compiler_flag:'` |
8398 |
- (eval echo "\"\$as_me:8398: $lt_compile\"" >&5) |
|
8398 |
+ (eval echo "\"\$as_me:8402: $lt_compile\"" >&5) |
|
8399 | 8399 |
(eval "$lt_compile" 2>out/conftest.err) |
8400 | 8400 |
ac_status=$? |
8401 | 8401 |
cat out/conftest.err >&5 |
8402 |
- echo "$as_me:8402: \$? = $ac_status" >&5 |
|
8402 |
+ echo "$as_me:8406: \$? = $ac_status" >&5 |
|
8403 | 8403 |
if (exit $ac_status) && test -s out/conftest2.$ac_objext |
8404 | 8404 |
then |
8405 | 8405 |
# The compiler can only warn and ignore the option if not recognized |
... | ... |
@@ -10779,7 +10783,7 @@ else |
10779 | 10779 |
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 |
10780 | 10780 |
lt_status=$lt_dlunknown |
10781 | 10781 |
cat > conftest.$ac_ext <<_LT_EOF |
10782 |
-#line 10782 "configure" |
|
10782 |
+#line 10786 "configure" |
|
10783 | 10783 |
#include "confdefs.h" |
10784 | 10784 |
|
10785 | 10785 |
#if HAVE_DLFCN_H |
... | ... |
@@ -10875,7 +10879,7 @@ else |
10875 | 10875 |
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 |
10876 | 10876 |
lt_status=$lt_dlunknown |
10877 | 10877 |
cat > conftest.$ac_ext <<_LT_EOF |
10878 |
-#line 10878 "configure" |
|
10878 |
+#line 10882 "configure" |
|
10879 | 10879 |
#include "confdefs.h" |
10880 | 10880 |
|
10881 | 10881 |
#if HAVE_DLFCN_H |
... | ... |
@@ -11547,7 +11551,7 @@ else |
11547 | 11547 |
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 |
11548 | 11548 |
lt_status=$lt_dlunknown |
11549 | 11549 |
cat > conftest.$ac_ext <<_LT_EOF |
11550 |
-#line 11550 "configure" |
|
11550 |
+#line 11554 "configure" |
|
11551 | 11551 |
#include "confdefs.h" |
11552 | 11552 |
|
11553 | 11553 |
#if HAVE_DLFCN_H |
... | ... |
@@ -19878,6 +19882,27 @@ subdirs="$subdirs libclamav/c++" |
19878 | 19878 |
|
19879 | 19879 |
fi |
19880 | 19880 |
|
19881 |
+# Check whether --enable-sha-collector-for-internal-use was given. |
|
19882 |
+if test "${enable_sha_collector_for_internal_use+set}" = set; then : |
|
19883 |
+ enableval=$enable_sha_collector_for_internal_use; enable_sha_collector="yes" |
|
19884 |
+else |
|
19885 |
+ enable_sha_collector="no" |
|
19886 |
+fi |
|
19887 |
+ |
|
19888 |
+if test "$enable_sha_collector" != "no"; then |
|
19889 |
+ |
|
19890 |
+$as_echo "#define HAVE__INTERNAL__SHA_COLLECT 1" >>confdefs.h |
|
19891 |
+ |
|
19892 |
+fi |
|
19893 |
+ if test "$enable_sha_collector" != "no"; then |
|
19894 |
+ BUILD_SHA1_TRUE= |
|
19895 |
+ BUILD_SHA1_FALSE='#' |
|
19896 |
+else |
|
19897 |
+ BUILD_SHA1_TRUE='#' |
|
19898 |
+ BUILD_SHA1_FALSE= |
|
19899 |
+fi |
|
19900 |
+ |
|
19901 |
+ |
|
19881 | 19902 |
ac_config_files="$ac_config_files clamscan/Makefile database/Makefile docs/Makefile clamd/Makefile clamdscan/Makefile clamav-milter/Makefile freshclam/Makefile sigtool/Makefile clamconf/Makefile etc/Makefile test/Makefile unit_tests/Makefile clamdtop/Makefile clambc/Makefile Makefile clamav-config libclamav.pc platform.h docs/man/clamav-milter.8 docs/man/clamconf.1 docs/man/clamd.8 docs/man/clamd.conf.5 docs/man/clamdscan.1 docs/man/clamscan.1 docs/man/freshclam.1 docs/man/freshclam.conf.5 docs/man/sigtool.1 docs/man/clamdtop.1" |
19882 | 19903 |
|
19883 | 19904 |
cat >confcache <<\_ACEOF |
... | ... |
@@ -20055,6 +20080,10 @@ if test -z "${HAVE_CURSES_TRUE}" && test -z "${HAVE_CURSES_FALSE}"; then |
20055 | 20055 |
as_fn_error "conditional \"HAVE_CURSES\" was never defined. |
20056 | 20056 |
Usually this means the macro was only invoked conditionally." "$LINENO" 5 |
20057 | 20057 |
fi |
20058 |
+if test -z "${BUILD_SHA1_TRUE}" && test -z "${BUILD_SHA1_FALSE}"; then |
|
20059 |
+ as_fn_error "conditional \"BUILD_SHA1\" was never defined. |
|
20060 |
+Usually this means the macro was only invoked conditionally." "$LINENO" 5 |
|
20061 |
+fi |
|
20058 | 20062 |
|
20059 | 20063 |
: ${CONFIG_STATUS=./config.status} |
20060 | 20064 |
ac_write_fail=0 |
... | ... |
@@ -22630,6 +22659,10 @@ if test -z "${HAVE_CURSES_TRUE}" && test -z "${HAVE_CURSES_FALSE}"; then |
22630 | 22630 |
as_fn_error "conditional \"HAVE_CURSES\" was never defined. |
22631 | 22631 |
Usually this means the macro was only invoked conditionally." "$LINENO" 5 |
22632 | 22632 |
fi |
22633 |
+if test -z "${BUILD_SHA1_TRUE}" && test -z "${BUILD_SHA1_FALSE}"; then |
|
22634 |
+ as_fn_error "conditional \"BUILD_SHA1\" was never defined. |
|
22635 |
+Usually this means the macro was only invoked conditionally." "$LINENO" 5 |
|
22636 |
+fi |
|
22633 | 22637 |
if test -z "${am__EXEEXT_TRUE}" && test -z "${am__EXEEXT_FALSE}"; then |
22634 | 22638 |
as_fn_error "conditional \"am__EXEEXT\" was never defined. |
22635 | 22639 |
Usually this means the macro was only invoked conditionally." "$LINENO" 5 |
... | ... |
@@ -1579,6 +1579,12 @@ if test "$enable_llvm" != "no"; then |
1579 | 1579 |
AC_CONFIG_SUBDIRS_OPTIONAL([libclamav/c++]) |
1580 | 1580 |
fi |
1581 | 1581 |
|
1582 |
+AC_ARG_ENABLE([sha-collector-for-internal-use], [], [enable_sha_collector="yes"], [enable_sha_collector="no"]) |
|
1583 |
+if test "$enable_sha_collector" != "no"; then |
|
1584 |
+ AC_DEFINE([HAVE__INTERNAL__SHA_COLLECT], 1, [For internal use only - DO NOT DEFINE]) |
|
1585 |
+fi |
|
1586 |
+AM_CONDITIONAL([BUILD_SHA1],[test "$enable_sha_collector" != "no"]) |
|
1587 |
+ |
|
1582 | 1588 |
AC_OUTPUT([ |
1583 | 1589 |
clamscan/Makefile |
1584 | 1590 |
database/Makefile |
... | ... |
@@ -66,6 +66,7 @@ target_triplet = @target@ |
66 | 66 |
@LINK_TOMMATH_FALSE@am__append_7 = bignum.c \ |
67 | 67 |
@LINK_TOMMATH_FALSE@ bignum_class.h |
68 | 68 |
|
69 |
+@BUILD_SHA1_TRUE@am__append_8 = sha1.c sha1.h |
|
69 | 70 |
subdir = libclamav |
70 | 71 |
DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \ |
71 | 72 |
$(srcdir)/Makefile.in |
... | ... |
@@ -156,8 +157,9 @@ am__libclamav_la_SOURCES_DIST = clamav.h matcher-ac.c matcher-ac.h \ |
156 | 156 |
clambc.h cpio.c cpio.h macho.c macho.h ishield.c ishield.h \ |
157 | 157 |
type_desc.h bcfeatures.h bytecode_api.c bytecode_api_decl.c \ |
158 | 158 |
bytecode_api.h bytecode_api_impl.h bytecode_hooks.h cache.c \ |
159 |
- cache.h bignum.c bignum_class.h |
|
159 |
+ cache.h bignum.c bignum_class.h sha1.c sha1.h |
|
160 | 160 |
@LINK_TOMMATH_FALSE@am__objects_1 = libclamav_la-bignum.lo |
161 |
+@BUILD_SHA1_TRUE@am__objects_2 = libclamav_la-sha1.lo |
|
161 | 162 |
am_libclamav_la_OBJECTS = libclamav_la-matcher-ac.lo \ |
162 | 163 |
libclamav_la-matcher-bm.lo libclamav_la-matcher.lo \ |
163 | 164 |
libclamav_la-others.lo libclamav_la-readdb.lo \ |
... | ... |
@@ -206,7 +208,7 @@ am_libclamav_la_OBJECTS = libclamav_la-matcher-ac.lo \ |
206 | 206 |
libclamav_la-bytecode_vm.lo libclamav_la-cpio.lo \ |
207 | 207 |
libclamav_la-macho.lo libclamav_la-ishield.lo \ |
208 | 208 |
libclamav_la-bytecode_api.lo libclamav_la-bytecode_api_decl.lo \ |
209 |
- libclamav_la-cache.lo $(am__objects_1) |
|
209 |
+ libclamav_la-cache.lo $(am__objects_1) $(am__objects_2) |
|
210 | 210 |
libclamav_la_OBJECTS = $(am_libclamav_la_OBJECTS) |
211 | 211 |
AM_V_lt = $(am__v_lt_$(V)) |
212 | 212 |
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) |
... | ... |
@@ -656,7 +658,7 @@ libclamav_la_SOURCES = clamav.h matcher-ac.c matcher-ac.h matcher-bm.c \ |
656 | 656 |
clambc.h cpio.c cpio.h macho.c macho.h ishield.c ishield.h \ |
657 | 657 |
type_desc.h bcfeatures.h bytecode_api.c bytecode_api_decl.c \ |
658 | 658 |
bytecode_api.h bytecode_api_impl.h bytecode_hooks.h cache.c \ |
659 |
- cache.h $(am__append_7) |
|
659 |
+ cache.h $(am__append_7) $(am__append_8) |
|
660 | 660 |
noinst_LTLIBRARIES = libclamav_internal_utils.la libclamav_internal_utils_nothreads.la libclamav_nocxx.la |
661 | 661 |
COMMON_CLEANFILES = version.h version.h.tmp *.gcda *.gcno |
662 | 662 |
@MAINTAINER_MODE_TRUE@BUILT_SOURCES = jsparse/generated/operators.h jsparse/generated/keywords.h jsparse-keywords.gperf |
... | ... |
@@ -853,6 +855,7 @@ distclean-compile: |
853 | 853 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-regex_suffix.Plo@am__quote@ |
854 | 854 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-rtf.Plo@am__quote@ |
855 | 855 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-scanners.Plo@am__quote@ |
856 |
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-sha1.Plo@am__quote@ |
|
856 | 857 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-sha256.Plo@am__quote@ |
857 | 858 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-sis.Plo@am__quote@ |
858 | 859 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_la-special.Plo@am__quote@ |
... | ... |
@@ -1692,6 +1695,14 @@ libclamav_la-bignum.lo: bignum.c |
1692 | 1692 |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
1693 | 1693 |
@am__fastdepCC_FALSE@ $(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-bignum.lo `test -f 'bignum.c' || echo '$(srcdir)/'`bignum.c |
1694 | 1694 |
|
1695 |
+libclamav_la-sha1.lo: sha1.c |
|
1696 |
+@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 |
|
1697 |
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_la-sha1.Tpo $(DEPDIR)/libclamav_la-sha1.Plo |
|
1698 |
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ |
|
1699 |
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sha1.c' object='libclamav_la-sha1.lo' libtool=yes @AMDEPBACKSLASH@ |
|
1700 |
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
1701 |
+@am__fastdepCC_FALSE@ $(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 |
|
1702 |
+ |
|
1695 | 1703 |
libclamav_internal_utils_la-str.lo: str.c |
1696 | 1704 |
@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-str.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_la-str.Tpo -c -o libclamav_internal_utils_la-str.lo `test -f 'str.c' || echo '$(srcdir)/'`str.c |
1697 | 1705 |
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libclamav_internal_utils_la-str.Tpo $(DEPDIR)/libclamav_internal_utils_la-str.Plo |
... | ... |
@@ -51,6 +51,11 @@ |
51 | 51 |
#include "filtering.h" |
52 | 52 |
#include "perflogging.h" |
53 | 53 |
|
54 |
+#ifdef HAVE__INTERNAL__SHA_COLLECT |
|
55 |
+#include "sha256.h" |
|
56 |
+#include "sha1.h" |
|
57 |
+#endif |
|
58 |
+ |
|
54 | 59 |
#ifdef CLI_PERF_LOGGING |
55 | 60 |
|
56 | 61 |
static inline void PERF_LOG_FILTER(int32_t pos, int32_t length, int8_t trie) |
... | ... |
@@ -387,6 +392,36 @@ int cli_checkfp(unsigned char *digest, size_t size, cli_ctx *ctx) |
387 | 387 |
sprintf(md5 + i * 2, "%02x", digest[i]); |
388 | 388 |
md5[32] = 0; |
389 | 389 |
cli_dbgmsg("FP SIGNATURE: %s:%u:%s\n", md5, (unsigned int) size, *ctx->virname ? *ctx->virname : "Name"); |
390 |
+ |
|
391 |
+#ifdef HAVE__INTERNAL__SHA_COLLECT |
|
392 |
+ if(ctx->sha_collect>0) { |
|
393 |
+ SHA1Context sha1; |
|
394 |
+ SHA256_CTX sha256; |
|
395 |
+ fmap_t *map = *ctx->fmap; |
|
396 |
+ char *ptr; |
|
397 |
+ uint8_t shash1[SHA1_HASH_SIZE*2+1]; |
|
398 |
+ uint8_t shash256[SHA256_HASH_SIZE*2+1]; |
|
399 |
+ |
|
400 |
+ if((ptr = fmap_need_off_once(map, 0, size))) { |
|
401 |
+ sha256_init(&sha256); |
|
402 |
+ sha256_update(&sha256, ptr, size); |
|
403 |
+ sha256_final(&sha256, &shash256[SHA256_HASH_SIZE]); |
|
404 |
+ for(i=0; i<SHA256_HASH_SIZE; i++) |
|
405 |
+ sprintf((char *)shash256+i*2, "%02x", shash256[SHA256_HASH_SIZE+i]); |
|
406 |
+ |
|
407 |
+ SHA1Init(&sha1); |
|
408 |
+ SHA1Update(&sha1, ptr, size); |
|
409 |
+ SHA1Final(&sha1, &shash1[SHA1_HASH_SIZE]); |
|
410 |
+ for(i=0; i<SHA1_HASH_SIZE; i++) |
|
411 |
+ sprintf((char *)shash1+i*2, "%02x", shash1[SHA1_HASH_SIZE+i]); |
|
412 |
+ |
|
413 |
+ cli_errmsg("COLLECT:%s:%s:%u:%s:%s\n", shash256, shash1, size, *ctx->virname, ctx->entry_filename); |
|
414 |
+ } else |
|
415 |
+ cli_errmsg("can't compute sha\n!"); |
|
416 |
+ ctx->sha_collect = -1; |
|
417 |
+ } |
|
418 |
+#endif |
|
419 |
+ |
|
390 | 420 |
return CL_VIRUS; |
391 | 421 |
} |
392 | 422 |
|
... | ... |
@@ -108,6 +108,14 @@ if((ndesc = open(tempfile, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU)) < 0) { \ |
108 | 108 |
} \ |
109 | 109 |
} |
110 | 110 |
|
111 |
+#ifdef HAVE__INTERNAL__SHA_COLLECT |
|
112 |
+#define SHA_OFF do { ctx->sha_collect = -1; } while(0) |
|
113 |
+#define SHA_RESET do { ctx->sha_collect = sha_collect; } while(0) |
|
114 |
+#else |
|
115 |
+#define SHA_OFF do {} while(0) |
|
116 |
+#define SHA_RESET do {} while(0) |
|
117 |
+#endif |
|
118 |
+ |
|
111 | 119 |
#define FSGCASE(NAME,FREESEC) \ |
112 | 120 |
case 0: /* Unpacked and NOT rebuilt */ \ |
113 | 121 |
cli_dbgmsg(NAME": Successfully decompressed\n"); \ |
... | ... |
@@ -148,12 +156,15 @@ if((ndesc = open(tempfile, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU)) < 0) { \ |
148 | 148 |
free(exe_sections); \ |
149 | 149 |
lseek(ndesc, 0, SEEK_SET); \ |
150 | 150 |
cli_dbgmsg("***** Scanning rebuilt PE file *****\n"); \ |
151 |
+ SHA_OFF; \ |
|
151 | 152 |
if(cli_magic_scandesc(ndesc, ctx) == CL_VIRUS) { \ |
152 | 153 |
close(ndesc); \ |
153 | 154 |
CLI_TMPUNLK(); \ |
154 | 155 |
free(tempfile); \ |
156 |
+ SHA_RESET; \ |
|
155 | 157 |
return CL_VIRUS; \ |
156 | 158 |
} \ |
159 |
+ SHA_RESET; \ |
|
157 | 160 |
close(ndesc); \ |
158 | 161 |
CLI_TMPUNLK(); \ |
159 | 162 |
free(tempfile); \ |
... | ... |
@@ -519,7 +530,9 @@ int cli_scanpe(cli_ctx *ctx, icon_groupset *iconset) |
519 | 519 |
struct cli_bc_ctx *bc_ctx; |
520 | 520 |
fmap_t *map; |
521 | 521 |
struct cli_pe_hook_data pedata; |
522 |
- |
|
522 |
+#ifdef HAVE__INTERNAL__SHA_COLLECT |
|
523 |
+ int sha_collect = ctx->sha_collect; |
|
524 |
+#endif |
|
523 | 525 |
|
524 | 526 |
if(!ctx) { |
525 | 527 |
cli_errmsg("cli_scanpe: ctx == NULL\n"); |
... | ... |
@@ -1922,13 +1935,16 @@ int cli_scanpe(cli_ctx *ctx, icon_groupset *iconset) |
1922 | 1922 |
cli_dbgmsg("UPX/FSG: Decompressed data saved in %s\n", tempfile); |
1923 | 1923 |
|
1924 | 1924 |
cli_dbgmsg("***** Scanning decompressed file *****\n"); |
1925 |
+ SHA_OFF; |
|
1925 | 1926 |
if((ret = cli_magic_scandesc(ndesc, ctx)) == CL_VIRUS) { |
1926 | 1927 |
close(ndesc); |
1927 | 1928 |
CLI_TMPUNLK(); |
1928 | 1929 |
free(tempfile); |
1930 |
+ SHA_RESET; |
|
1929 | 1931 |
return CL_VIRUS; |
1930 | 1932 |
} |
1931 | 1933 |
|
1934 |
+ SHA_RESET; |
|
1932 | 1935 |
close(ndesc); |
1933 | 1936 |
CLI_TMPUNLK(); |
1934 | 1937 |
free(tempfile); |
... | ... |
@@ -1905,6 +1905,10 @@ int cli_magic_scandesc(int desc, cli_ctx *ctx) |
1905 | 1905 |
unsigned char hash[16]; |
1906 | 1906 |
bitset_t *old_hook_lsig_matches; |
1907 | 1907 |
|
1908 |
+#ifdef HAVE__INTERNAL__SHA_COLLECT |
|
1909 |
+ if(ctx->sha_collect>0) ctx->sha_collect = 0; |
|
1910 |
+#endif |
|
1911 |
+ |
|
1908 | 1912 |
cli_dbgmsg("in cli_magic_scandesc (reclevel: %u/%u)\n", ctx->recursion, ctx->engine->maxreclevel); |
1909 | 1913 |
if(ctx->engine->maxreclevel && ctx->recursion > ctx->engine->maxreclevel) { |
1910 | 1914 |
cli_dbgmsg("cli_magic_scandesc: Archive recursion limit exceeded (%u, max: %u)\n", ctx->recursion, ctx->engine->maxreclevel); |
... | ... |
@@ -1982,6 +1986,10 @@ int cli_magic_scandesc(int desc, cli_ctx *ctx) |
1982 | 1982 |
ctx->hook_lsig_matches = old_hook_lsig_matches; |
1983 | 1983 |
ret_from_magicscan(CL_EREAD); |
1984 | 1984 |
} |
1985 |
+ |
|
1986 |
+#ifdef HAVE__INTERNAL__SHA_COLLECT |
|
1987 |
+ if(!ctx->sha_collect && type==CL_TYPE_MSEXE) ctx->sha_collect = 1; |
|
1988 |
+#endif |
|
1985 | 1989 |
lseek(desc, 0, SEEK_SET); /* FIXMEFMAP: remove ? */ |
1986 | 1990 |
|
1987 | 1991 |
ctx->hook_lsig_matches = cli_bitset_init(); |
... | ... |
@@ -2336,6 +2344,21 @@ int cl_scandesc(int desc, const char **virname, unsigned long int *scanned, cons |
2336 | 2336 |
return CL_EMEM; |
2337 | 2337 |
ctx.hook_lsig_matches = cli_bitset_init(); |
2338 | 2338 |
|
2339 |
+#ifdef HAVE__INTERNAL__SHA_COLLECT |
|
2340 |
+ do { |
|
2341 |
+ char link[32]; |
|
2342 |
+ ssize_t linksz; |
|
2343 |
+ |
|
2344 |
+ snprintf(link, sizeof(link), "/proc/self/fd/%u", desc); |
|
2345 |
+ link[sizeof(link)-1]='\0'; |
|
2346 |
+ if((linksz=readlink(link, ctx.entry_filename, sizeof(ctx.entry_filename)))==-1) { |
|
2347 |
+ cli_errmsg("failed to resolve filename for descriptor %d (%s)\n", desc, link); |
|
2348 |
+ strcpy(ctx.entry_filename, "NO_IDEA"); |
|
2349 |
+ } else |
|
2350 |
+ ctx.entry_filename[linksz]='\0'; |
|
2351 |
+ } while(0); |
|
2352 |
+#endif |
|
2353 |
+ |
|
2339 | 2354 |
rc = cli_magic_scandesc(desc, &ctx); |
2340 | 2355 |
|
2341 | 2356 |
cli_bitset_free(ctx.hook_lsig_matches); |
2342 | 2357 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,626 @@ |
0 |
+/*- |
|
1 |
+ * Copyright (c) 2001-2003 Allan Saddi <allan@saddi.com> |
|
2 |
+ * All rights reserved. |
|
3 |
+ * |
|
4 |
+ * Redistribution and use in source and binary forms, with or without |
|
5 |
+ * modification, are permitted provided that the following conditions |
|
6 |
+ * are met: |
|
7 |
+ * 1. Redistributions of source code must retain the above copyright |
|
8 |
+ * notice, this list of conditions and the following disclaimer. |
|
9 |
+ * 2. Redistributions in binary form must reproduce the above copyright |
|
10 |
+ * notice, this list of conditions and the following disclaimer in the |
|
11 |
+ * documentation and/or other materials provided with the distribution. |
|
12 |
+ * |
|
13 |
+ * THIS SOFTWARE IS PROVIDED BY ALLAN SADDI AND HIS CONTRIBUTORS ``AS IS'' |
|
14 |
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
15 |
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
16 |
+ * ARE DISCLAIMED. IN NO EVENT SHALL ALLAN SADDI OR HIS CONTRIBUTORS BE |
|
17 |
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
18 |
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
19 |
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
20 |
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
21 |
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
22 |
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
23 |
+ * POSSIBILITY OF SUCH DAMAGE. |
|
24 |
+ * |
|
25 |
+ * $Id: sha1.c 680 2003-07-25 21:57:38Z asaddi $ |
|
26 |
+ */ |
|
27 |
+ |
|
28 |
+/* |
|
29 |
+ * Define WORDS_BIGENDIAN if compiling on a big-endian architecture. |
|
30 |
+ * |
|
31 |
+ * Define SHA1_TEST to test the implementation using the NIST's |
|
32 |
+ * sample messages. The output should be: |
|
33 |
+ * |
|
34 |
+ * a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d |
|
35 |
+ * 84983e44 1c3bd26e baae4aa1 f95129e5 e54670f1 |
|
36 |
+ * 34aa973c d4c4daa4 f61eeb2b dbad2731 6534016f |
|
37 |
+ */ |
|
38 |
+ |
|
39 |
+#ifdef HAVE_CONFIG_H |
|
40 |
+#include "clamav-config.h" |
|
41 |
+#endif /* HAVE_CONFIG_H */ |
|
42 |
+ |
|
43 |
+#if HAVE_INTTYPES_H |
|
44 |
+# include <inttypes.h> |
|
45 |
+#else |
|
46 |
+# if HAVE_STDINT_H |
|
47 |
+# include <stdint.h> |
|
48 |
+# endif |
|
49 |
+#endif |
|
50 |
+ |
|
51 |
+#include <string.h> |
|
52 |
+ |
|
53 |
+#include "sha1.h" |
|
54 |
+ |
|
55 |
+#ifndef lint |
|
56 |
+static const char rcsid[] = |
|
57 |
+ "$Id: sha1.c 680 2003-07-25 21:57:38Z asaddi $"; |
|
58 |
+#endif /* !lint */ |
|
59 |
+ |
|
60 |
+#define ROTL(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) |
|
61 |
+#define ROTR(x, n) (((x) >> (n)) | ((x) << (32 - (n)))) |
|
62 |
+ |
|
63 |
+#define F_0_19(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) |
|
64 |
+#define F_20_39(x, y, z) ((x) ^ (y) ^ (z)) |
|
65 |
+#define F_40_59(x, y, z) (((x) & ((y) | (z))) | ((y) & (z))) |
|
66 |
+#define F_60_79(x, y, z) ((x) ^ (y) ^ (z)) |
|
67 |
+ |
|
68 |
+#define DO_ROUND(F, K) { \ |
|
69 |
+ temp = ROTL(a, 5) + F(b, c, d) + e + *(W++) + K; \ |
|
70 |
+ e = d; \ |
|
71 |
+ d = c; \ |
|
72 |
+ c = ROTL(b, 30); \ |
|
73 |
+ b = a; \ |
|
74 |
+ a = temp; \ |
|
75 |
+} |
|
76 |
+ |
|
77 |
+#define K_0_19 0x5a827999L |
|
78 |
+#define K_20_39 0x6ed9eba1L |
|
79 |
+#define K_40_59 0x8f1bbcdcL |
|
80 |
+#define K_60_79 0xca62c1d6L |
|
81 |
+ |
|
82 |
+#ifndef RUNTIME_ENDIAN |
|
83 |
+ |
|
84 |
+#if WORDS_BIGENDIAN == 1 |
|
85 |
+ |
|
86 |
+#define BYTESWAP(x) (x) |
|
87 |
+#define BYTESWAP64(x) (x) |
|
88 |
+ |
|
89 |
+#else /* WORDS_BIGENDIAN */ |
|
90 |
+ |
|
91 |
+#define BYTESWAP(x) ((ROTR((x), 8) & 0xff00ff00L) | \ |
|
92 |
+ (ROTL((x), 8) & 0x00ff00ffL)) |
|
93 |
+#define BYTESWAP64(x) _byteswap64(x) |
|
94 |
+ |
|
95 |
+static inline uint64_t _byteswap64(uint64_t x) |
|
96 |
+{ |
|
97 |
+ uint32_t a = x >> 32; |
|
98 |
+ uint32_t b = (uint32_t) x; |
|
99 |
+ return ((uint64_t) BYTESWAP(b) << 32) | (uint64_t) BYTESWAP(a); |
|
100 |
+} |
|
101 |
+ |
|
102 |
+#endif /* WORDS_BIGENDIAN */ |
|
103 |
+ |
|
104 |
+#else /* !RUNTIME_ENDIAN */ |
|
105 |
+ |
|
106 |
+#define BYTESWAP(x) _byteswap(sc->littleEndian, x) |
|
107 |
+#define BYTESWAP64(x) _byteswap64(sc->littleEndian, x) |
|
108 |
+ |
|
109 |
+#define _BYTESWAP(x) ((ROTR((x), 8) & 0xff00ff00L) | \ |
|
110 |
+ (ROTL((x), 8) & 0x00ff00ffL)) |
|
111 |
+#define _BYTESWAP64(x) __byteswap64(x) |
|
112 |
+ |
|
113 |
+static inline uint64_t __byteswap64(uint64_t x) |
|
114 |
+{ |
|
115 |
+ uint32_t a = x >> 32; |
|
116 |
+ uint32_t b = (uint32_t) x; |
|
117 |
+ return ((uint64_t) _BYTESWAP(b) << 32) | (uint64_t) _BYTESWAP(a); |
|
118 |
+} |
|
119 |
+ |
|
120 |
+static inline uint32_t _byteswap(int littleEndian, uint32_t x) |
|
121 |
+{ |
|
122 |
+ if (!littleEndian) |
|
123 |
+ return x; |
|
124 |
+ else |
|
125 |
+ return _BYTESWAP(x); |
|
126 |
+} |
|
127 |
+ |
|
128 |
+static inline uint64_t _byteswap64(int littleEndian, uint64_t x) |
|
129 |
+{ |
|
130 |
+ if (!littleEndian) |
|
131 |
+ return x; |
|
132 |
+ else |
|
133 |
+ return _BYTESWAP64(x); |
|
134 |
+} |
|
135 |
+ |
|
136 |
+static inline void setEndian(int *littleEndianp) |
|
137 |
+{ |
|
138 |
+ union { |
|
139 |
+ uint32_t w; |
|
140 |
+ uint8_t b[4]; |
|
141 |
+ } endian; |
|
142 |
+ |
|
143 |
+ endian.w = 1L; |
|
144 |
+ *littleEndianp = endian.b[0] != 0; |
|
145 |
+} |
|
146 |
+ |
|
147 |
+#endif /* !RUNTIME_ENDIAN */ |
|
148 |
+ |
|
149 |
+static const uint8_t padding[64] = { |
|
150 |
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
|
151 |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
|
152 |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
|
153 |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
|
154 |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
|
155 |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
|
156 |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
|
157 |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
|
158 |
+}; |
|
159 |
+ |
|
160 |
+void |
|
161 |
+SHA1Init (SHA1Context *sc) |
|
162 |
+{ |
|
163 |
+#ifdef RUNTIME_ENDIAN |
|
164 |
+ setEndian (&sc->littleEndian); |
|
165 |
+#endif /* RUNTIME_ENDIAN */ |
|
166 |
+ |
|
167 |
+ sc->totalLength = 0LL; |
|
168 |
+ sc->hash[0] = 0x67452301L; |
|
169 |
+ sc->hash[1] = 0xefcdab89L; |
|
170 |
+ sc->hash[2] = 0x98badcfeL; |
|
171 |
+ sc->hash[3] = 0x10325476L; |
|
172 |
+ sc->hash[4] = 0xc3d2e1f0L; |
|
173 |
+ sc->bufferLength = 0L; |
|
174 |
+} |
|
175 |
+ |
|
176 |
+static void |
|
177 |
+burnStack (int size) |
|
178 |
+{ |
|
179 |
+ char buf[128]; |
|
180 |
+ |
|
181 |
+ memset (buf, 0, sizeof (buf)); |
|
182 |
+ size -= sizeof (buf); |
|
183 |
+ if (size > 0) |
|
184 |
+ burnStack (size); |
|
185 |
+} |
|
186 |
+ |
|
187 |
+static void |
|
188 |
+SHA1Guts (SHA1Context *sc, const uint32_t *cbuf) |
|
189 |
+{ |
|
190 |
+ uint32_t buf[80]; |
|
191 |
+ uint32_t *W, *W3, *W8, *W14, *W16; |
|
192 |
+ uint32_t a, b, c, d, e, temp; |
|
193 |
+ int i; |
|
194 |
+ |
|
195 |
+ W = buf; |
|
196 |
+ |
|
197 |
+ for (i = 15; i >= 0; i--) { |
|
198 |
+ *(W++) = BYTESWAP(*cbuf); |
|
199 |
+ cbuf++; |
|
200 |
+ } |
|
201 |
+ |
|
202 |
+ W16 = &buf[0]; |
|
203 |
+ W14 = &buf[2]; |
|
204 |
+ W8 = &buf[8]; |
|
205 |
+ W3 = &buf[13]; |
|
206 |
+ |
|
207 |
+ for (i = 63; i >= 0; i--) { |
|
208 |
+ *W = *(W3++) ^ *(W8++) ^ *(W14++) ^ *(W16++); |
|
209 |
+ *W = ROTL(*W, 1); |
|
210 |
+ W++; |
|
211 |
+ } |
|
212 |
+ |
|
213 |
+ a = sc->hash[0]; |
|
214 |
+ b = sc->hash[1]; |
|
215 |
+ c = sc->hash[2]; |
|
216 |
+ d = sc->hash[3]; |
|
217 |
+ e = sc->hash[4]; |
|
218 |
+ |
|
219 |
+ W = buf; |
|
220 |
+ |
|
221 |
+#ifndef SHA1_UNROLL |
|
222 |
+#define SHA1_UNROLL 20 |
|
223 |
+#endif /* !SHA1_UNROLL */ |
|
224 |
+ |
|
225 |
+#if SHA1_UNROLL == 1 |
|
226 |
+ for (i = 19; i >= 0; i--) |
|
227 |
+ DO_ROUND(F_0_19, K_0_19); |
|
228 |
+ |
|
229 |
+ for (i = 19; i >= 0; i--) |
|
230 |
+ DO_ROUND(F_20_39, K_20_39); |
|
231 |
+ |
|
232 |
+ for (i = 19; i >= 0; i--) |
|
233 |
+ DO_ROUND(F_40_59, K_40_59); |
|
234 |
+ |
|
235 |
+ for (i = 19; i >= 0; i--) |
|
236 |
+ DO_ROUND(F_60_79, K_60_79); |
|
237 |
+#elif SHA1_UNROLL == 2 |
|
238 |
+ for (i = 9; i >= 0; i--) { |
|
239 |
+ DO_ROUND(F_0_19, K_0_19); |
|
240 |
+ DO_ROUND(F_0_19, K_0_19); |
|
241 |
+ } |
|
242 |
+ |
|
243 |
+ for (i = 9; i >= 0; i--) { |
|
244 |
+ DO_ROUND(F_20_39, K_20_39); |
|
245 |
+ DO_ROUND(F_20_39, K_20_39); |
|
246 |
+ } |
|
247 |
+ |
|
248 |
+ for (i = 9; i >= 0; i--) { |
|
249 |
+ DO_ROUND(F_40_59, K_40_59); |
|
250 |
+ DO_ROUND(F_40_59, K_40_59); |
|
251 |
+ } |
|
252 |
+ |
|
253 |
+ for (i = 9; i >= 0; i--) { |
|
254 |
+ DO_ROUND(F_60_79, K_60_79); |
|
255 |
+ DO_ROUND(F_60_79, K_60_79); |
|
256 |
+ } |
|
257 |
+#elif SHA1_UNROLL == 4 |
|
258 |
+ for (i = 4; i >= 0; i--) { |
|
259 |
+ DO_ROUND(F_0_19, K_0_19); |
|
260 |
+ DO_ROUND(F_0_19, K_0_19); |
|
261 |
+ DO_ROUND(F_0_19, K_0_19); |
|
262 |
+ DO_ROUND(F_0_19, K_0_19); |
|
263 |
+ } |
|
264 |
+ |
|
265 |
+ for (i = 4; i >= 0; i--) { |
|
266 |
+ DO_ROUND(F_20_39, K_20_39); |
|
267 |
+ DO_ROUND(F_20_39, K_20_39); |
|
268 |
+ DO_ROUND(F_20_39, K_20_39); |
|
269 |
+ DO_ROUND(F_20_39, K_20_39); |
|
270 |
+ } |
|
271 |
+ |
|
272 |
+ for (i = 4; i >= 0; i--) { |
|
273 |
+ DO_ROUND(F_40_59, K_40_59); |
|
274 |
+ DO_ROUND(F_40_59, K_40_59); |
|
275 |
+ DO_ROUND(F_40_59, K_40_59); |
|
276 |
+ DO_ROUND(F_40_59, K_40_59); |
|
277 |
+ } |
|
278 |
+ |
|
279 |
+ for (i = 4; i >= 0; i--) { |
|
280 |
+ DO_ROUND(F_60_79, K_60_79); |
|
281 |
+ DO_ROUND(F_60_79, K_60_79); |
|
282 |
+ DO_ROUND(F_60_79, K_60_79); |
|
283 |
+ DO_ROUND(F_60_79, K_60_79); |
|
284 |
+ } |
|
285 |
+#elif SHA1_UNROLL == 5 |
|
286 |
+ for (i = 3; i >= 0; i--) { |
|
287 |
+ DO_ROUND(F_0_19, K_0_19); |
|
288 |
+ DO_ROUND(F_0_19, K_0_19); |
|
289 |
+ DO_ROUND(F_0_19, K_0_19); |
|
290 |
+ DO_ROUND(F_0_19, K_0_19); |
|
291 |
+ DO_ROUND(F_0_19, K_0_19); |
|
292 |
+ } |
|
293 |
+ |
|
294 |
+ for (i = 3; i >= 0; i--) { |
|
295 |
+ DO_ROUND(F_20_39, K_20_39); |
|
296 |
+ DO_ROUND(F_20_39, K_20_39); |
|
297 |
+ DO_ROUND(F_20_39, K_20_39); |
|
298 |
+ DO_ROUND(F_20_39, K_20_39); |
|
299 |
+ DO_ROUND(F_20_39, K_20_39); |
|
300 |
+ } |
|
301 |
+ |
|
302 |
+ for (i = 3; i >= 0; i--) { |
|
303 |
+ DO_ROUND(F_40_59, K_40_59); |
|
304 |
+ DO_ROUND(F_40_59, K_40_59); |
|
305 |
+ DO_ROUND(F_40_59, K_40_59); |
|
306 |
+ DO_ROUND(F_40_59, K_40_59); |
|
307 |
+ DO_ROUND(F_40_59, K_40_59); |
|
308 |
+ } |
|
309 |
+ |
|
310 |
+ for (i = 3; i >= 0; i--) { |
|
311 |
+ DO_ROUND(F_60_79, K_60_79); |
|
312 |
+ DO_ROUND(F_60_79, K_60_79); |
|
313 |
+ DO_ROUND(F_60_79, K_60_79); |
|
314 |
+ DO_ROUND(F_60_79, K_60_79); |
|
315 |
+ DO_ROUND(F_60_79, K_60_79); |
|
316 |
+ } |
|
317 |
+#elif SHA1_UNROLL == 10 |
|
318 |
+ for (i = 1; i >= 0; i--) { |
|
319 |
+ DO_ROUND(F_0_19, K_0_19); |
|
320 |
+ DO_ROUND(F_0_19, K_0_19); |
|
321 |
+ DO_ROUND(F_0_19, K_0_19); |
|
322 |
+ DO_ROUND(F_0_19, K_0_19); |
|
323 |
+ DO_ROUND(F_0_19, K_0_19); |
|
324 |
+ DO_ROUND(F_0_19, K_0_19); |
|
325 |
+ DO_ROUND(F_0_19, K_0_19); |
|
326 |
+ DO_ROUND(F_0_19, K_0_19); |
|
327 |
+ DO_ROUND(F_0_19, K_0_19); |
|
328 |
+ DO_ROUND(F_0_19, K_0_19); |
|
329 |
+ } |
|
330 |
+ |
|
331 |
+ for (i = 1; i >= 0; i--) { |
|
332 |
+ DO_ROUND(F_20_39, K_20_39); |
|
333 |
+ DO_ROUND(F_20_39, K_20_39); |
|
334 |
+ DO_ROUND(F_20_39, K_20_39); |
|
335 |
+ DO_ROUND(F_20_39, K_20_39); |
|
336 |
+ DO_ROUND(F_20_39, K_20_39); |
|
337 |
+ DO_ROUND(F_20_39, K_20_39); |
|
338 |
+ DO_ROUND(F_20_39, K_20_39); |
|
339 |
+ DO_ROUND(F_20_39, K_20_39); |
|
340 |
+ DO_ROUND(F_20_39, K_20_39); |
|
341 |
+ DO_ROUND(F_20_39, K_20_39); |
|
342 |
+ } |
|
343 |
+ |
|
344 |
+ for (i = 1; i >= 0; i--) { |
|
345 |
+ DO_ROUND(F_40_59, K_40_59); |
|
346 |
+ DO_ROUND(F_40_59, K_40_59); |
|
347 |
+ DO_ROUND(F_40_59, K_40_59); |
|
348 |
+ DO_ROUND(F_40_59, K_40_59); |
|
349 |
+ DO_ROUND(F_40_59, K_40_59); |
|
350 |
+ DO_ROUND(F_40_59, K_40_59); |
|
351 |
+ DO_ROUND(F_40_59, K_40_59); |
|
352 |
+ DO_ROUND(F_40_59, K_40_59); |
|
353 |
+ DO_ROUND(F_40_59, K_40_59); |
|
354 |
+ DO_ROUND(F_40_59, K_40_59); |
|
355 |
+ } |
|
356 |
+ |
|
357 |
+ for (i = 1; i >= 0; i--) { |
|
358 |
+ DO_ROUND(F_60_79, K_60_79); |
|
359 |
+ DO_ROUND(F_60_79, K_60_79); |
|
360 |
+ DO_ROUND(F_60_79, K_60_79); |
|
361 |
+ DO_ROUND(F_60_79, K_60_79); |
|
362 |
+ DO_ROUND(F_60_79, K_60_79); |
|
363 |
+ DO_ROUND(F_60_79, K_60_79); |
|
364 |
+ DO_ROUND(F_60_79, K_60_79); |
|
365 |
+ DO_ROUND(F_60_79, K_60_79); |
|
366 |
+ DO_ROUND(F_60_79, K_60_79); |
|
367 |
+ DO_ROUND(F_60_79, K_60_79); |
|
368 |
+ } |
|
369 |
+#elif SHA1_UNROLL == 20 |
|
370 |
+ DO_ROUND(F_0_19, K_0_19); |
|
371 |
+ DO_ROUND(F_0_19, K_0_19); |
|
372 |
+ DO_ROUND(F_0_19, K_0_19); |
|
373 |
+ DO_ROUND(F_0_19, K_0_19); |
|
374 |
+ DO_ROUND(F_0_19, K_0_19); |
|
375 |
+ DO_ROUND(F_0_19, K_0_19); |
|
376 |
+ DO_ROUND(F_0_19, K_0_19); |
|
377 |
+ DO_ROUND(F_0_19, K_0_19); |
|
378 |
+ DO_ROUND(F_0_19, K_0_19); |
|
379 |
+ DO_ROUND(F_0_19, K_0_19); |
|
380 |
+ DO_ROUND(F_0_19, K_0_19); |
|
381 |
+ DO_ROUND(F_0_19, K_0_19); |
|
382 |
+ DO_ROUND(F_0_19, K_0_19); |
|
383 |
+ DO_ROUND(F_0_19, K_0_19); |
|
384 |
+ DO_ROUND(F_0_19, K_0_19); |
|
385 |
+ DO_ROUND(F_0_19, K_0_19); |
|
386 |
+ DO_ROUND(F_0_19, K_0_19); |
|
387 |
+ DO_ROUND(F_0_19, K_0_19); |
|
388 |
+ DO_ROUND(F_0_19, K_0_19); |
|
389 |
+ DO_ROUND(F_0_19, K_0_19); |
|
390 |
+ |
|
391 |
+ DO_ROUND(F_20_39, K_20_39); |
|
392 |
+ DO_ROUND(F_20_39, K_20_39); |
|
393 |
+ DO_ROUND(F_20_39, K_20_39); |
|
394 |
+ DO_ROUND(F_20_39, K_20_39); |
|
395 |
+ DO_ROUND(F_20_39, K_20_39); |
|
396 |
+ DO_ROUND(F_20_39, K_20_39); |
|
397 |
+ DO_ROUND(F_20_39, K_20_39); |
|
398 |
+ DO_ROUND(F_20_39, K_20_39); |
|
399 |
+ DO_ROUND(F_20_39, K_20_39); |
|
400 |
+ DO_ROUND(F_20_39, K_20_39); |
|
401 |
+ DO_ROUND(F_20_39, K_20_39); |
|
402 |
+ DO_ROUND(F_20_39, K_20_39); |
|
403 |
+ DO_ROUND(F_20_39, K_20_39); |
|
404 |
+ DO_ROUND(F_20_39, K_20_39); |
|
405 |
+ DO_ROUND(F_20_39, K_20_39); |
|
406 |
+ DO_ROUND(F_20_39, K_20_39); |
|
407 |
+ DO_ROUND(F_20_39, K_20_39); |
|
408 |
+ DO_ROUND(F_20_39, K_20_39); |
|
409 |
+ DO_ROUND(F_20_39, K_20_39); |
|
410 |
+ DO_ROUND(F_20_39, K_20_39); |
|
411 |
+ |
|
412 |
+ DO_ROUND(F_40_59, K_40_59); |
|
413 |
+ DO_ROUND(F_40_59, K_40_59); |
|
414 |
+ DO_ROUND(F_40_59, K_40_59); |
|
415 |
+ DO_ROUND(F_40_59, K_40_59); |
|
416 |
+ DO_ROUND(F_40_59, K_40_59); |
|
417 |
+ DO_ROUND(F_40_59, K_40_59); |
|
418 |
+ DO_ROUND(F_40_59, K_40_59); |
|
419 |
+ DO_ROUND(F_40_59, K_40_59); |
|
420 |
+ DO_ROUND(F_40_59, K_40_59); |
|
421 |
+ DO_ROUND(F_40_59, K_40_59); |
|
422 |
+ DO_ROUND(F_40_59, K_40_59); |
|
423 |
+ DO_ROUND(F_40_59, K_40_59); |
|
424 |
+ DO_ROUND(F_40_59, K_40_59); |
|
425 |
+ DO_ROUND(F_40_59, K_40_59); |
|
426 |
+ DO_ROUND(F_40_59, K_40_59); |
|
427 |
+ DO_ROUND(F_40_59, K_40_59); |
|
428 |
+ DO_ROUND(F_40_59, K_40_59); |
|
429 |
+ DO_ROUND(F_40_59, K_40_59); |
|
430 |
+ DO_ROUND(F_40_59, K_40_59); |
|
431 |
+ DO_ROUND(F_40_59, K_40_59); |
|
432 |
+ |
|
433 |
+ DO_ROUND(F_60_79, K_60_79); |
|
434 |
+ DO_ROUND(F_60_79, K_60_79); |
|
435 |
+ DO_ROUND(F_60_79, K_60_79); |
|
436 |
+ DO_ROUND(F_60_79, K_60_79); |
|
437 |
+ DO_ROUND(F_60_79, K_60_79); |
|
438 |
+ DO_ROUND(F_60_79, K_60_79); |
|
439 |
+ DO_ROUND(F_60_79, K_60_79); |
|
440 |
+ DO_ROUND(F_60_79, K_60_79); |
|
441 |
+ DO_ROUND(F_60_79, K_60_79); |
|
442 |
+ DO_ROUND(F_60_79, K_60_79); |
|
443 |
+ DO_ROUND(F_60_79, K_60_79); |
|
444 |
+ DO_ROUND(F_60_79, K_60_79); |
|
445 |
+ DO_ROUND(F_60_79, K_60_79); |
|
446 |
+ DO_ROUND(F_60_79, K_60_79); |
|
447 |
+ DO_ROUND(F_60_79, K_60_79); |
|
448 |
+ DO_ROUND(F_60_79, K_60_79); |
|
449 |
+ DO_ROUND(F_60_79, K_60_79); |
|
450 |
+ DO_ROUND(F_60_79, K_60_79); |
|
451 |
+ DO_ROUND(F_60_79, K_60_79); |
|
452 |
+ DO_ROUND(F_60_79, K_60_79); |
|
453 |
+#else /* SHA1_UNROLL */ |
|
454 |
+#error SHA1_UNROLL must be 1, 2, 4, 5, 10 or 20! |
|
455 |
+#endif |
|
456 |
+ |
|
457 |
+ sc->hash[0] += a; |
|
458 |
+ sc->hash[1] += b; |
|
459 |
+ sc->hash[2] += c; |
|
460 |
+ sc->hash[3] += d; |
|
461 |
+ sc->hash[4] += e; |
|
462 |
+} |
|
463 |
+ |
|
464 |
+void |
|
465 |
+SHA1Update (SHA1Context *sc, const void *vdata, uint32_t len) |
|
466 |
+{ |
|
467 |
+ const uint8_t *data = vdata; |
|
468 |
+ uint32_t bufferBytesLeft; |
|
469 |
+ uint32_t bytesToCopy; |
|
470 |
+ int needBurn = 0; |
|
471 |
+ |
|
472 |
+#ifdef SHA1_FAST_COPY |
|
473 |
+ if (sc->bufferLength) { |
|
474 |
+ bufferBytesLeft = 64L - sc->bufferLength; |
|
475 |
+ |
|
476 |
+ bytesToCopy = bufferBytesLeft; |
|
477 |
+ if (bytesToCopy > len) |
|
478 |
+ bytesToCopy = len; |
|
479 |
+ |
|
480 |
+ memcpy (&sc->buffer.bytes[sc->bufferLength], data, bytesToCopy); |
|
481 |
+ |
|
482 |
+ sc->totalLength += bytesToCopy * 8L; |
|
483 |
+ |
|
484 |
+ sc->bufferLength += bytesToCopy; |
|
485 |
+ data += bytesToCopy; |
|
486 |
+ len -= bytesToCopy; |
|
487 |
+ |
|
488 |
+ if (sc->bufferLength == 64L) { |
|
489 |
+ SHA1Guts (sc, sc->buffer.words); |
|
490 |
+ needBurn = 1; |
|
491 |
+ sc->bufferLength = 0L; |
|
492 |
+ } |
|
493 |
+ } |
|
494 |
+ |
|
495 |
+ while (len > 63) { |
|
496 |
+ sc->totalLength += 512L; |
|
497 |
+ |
|
498 |
+ SHA1Guts (sc, data); |
|
499 |
+ needBurn = 1; |
|
500 |
+ |
|
501 |
+ data += 64L; |
|
502 |
+ len -= 64L; |
|
503 |
+ } |
|
504 |
+ |
|
505 |
+ if (len) { |
|
506 |
+ memcpy (&sc->buffer.bytes[sc->bufferLength], data, len); |
|
507 |
+ |
|
508 |
+ sc->totalLength += len * 8L; |
|
509 |
+ |
|
510 |
+ sc->bufferLength += len; |
|
511 |
+ } |
|
512 |
+#else /* SHA1_FAST_COPY */ |
|
513 |
+ while (len) { |
|
514 |
+ bufferBytesLeft = 64L - sc->bufferLength; |
|
515 |
+ |
|
516 |
+ bytesToCopy = bufferBytesLeft; |
|
517 |
+ if (bytesToCopy > len) |
|
518 |
+ bytesToCopy = len; |
|
519 |
+ |
|
520 |
+ memcpy (&sc->buffer.bytes[sc->bufferLength], data, bytesToCopy); |
|
521 |
+ |
|
522 |
+ sc->totalLength += bytesToCopy * 8L; |
|
523 |
+ |
|
524 |
+ sc->bufferLength += bytesToCopy; |
|
525 |
+ data += bytesToCopy; |
|
526 |
+ len -= bytesToCopy; |
|
527 |
+ |
|
528 |
+ if (sc->bufferLength == 64L) { |
|
529 |
+ SHA1Guts (sc, sc->buffer.words); |
|
530 |
+ needBurn = 1; |
|
531 |
+ sc->bufferLength = 0L; |
|
532 |
+ } |
|
533 |
+ } |
|
534 |
+#endif /* SHA1_FAST_COPY */ |
|
535 |
+ |
|
536 |
+ if (needBurn) |
|
537 |
+ burnStack (sizeof (uint32_t[86]) + sizeof (uint32_t *[5]) + sizeof (int)); |
|
538 |
+} |
|
539 |
+ |
|
540 |
+void |
|
541 |
+SHA1Final (SHA1Context *sc, uint8_t hash[SHA1_HASH_SIZE]) |
|
542 |
+{ |
|
543 |
+ uint32_t bytesToPad; |
|
544 |
+ uint64_t lengthPad; |
|
545 |
+ int i; |
|
546 |
+ |
|
547 |
+ bytesToPad = 120L - sc->bufferLength; |
|
548 |
+ if (bytesToPad > 64L) |
|
549 |
+ bytesToPad -= 64L; |
|
550 |
+ |
|
551 |
+ lengthPad = BYTESWAP64(sc->totalLength); |
|
552 |
+ |
|
553 |
+ SHA1Update (sc, padding, bytesToPad); |
|
554 |
+ SHA1Update (sc, &lengthPad, 8L); |
|
555 |
+ |
|
556 |
+ if (hash) { |
|
557 |
+ for (i = 0; i < SHA1_HASH_WORDS; i++) { |
|
558 |
+#ifdef SHA1_FAST_COPY |
|
559 |
+ *((uint32_t *) hash) = BYTESWAP(sc->hash[i]); |
|
560 |
+#else /* SHA1_FAST_COPY */ |
|
561 |
+ hash[0] = (uint8_t) (sc->hash[i] >> 24); |
|
562 |
+ hash[1] = (uint8_t) (sc->hash[i] >> 16); |
|
563 |
+ hash[2] = (uint8_t) (sc->hash[i] >> 8); |
|
564 |
+ hash[3] = (uint8_t) sc->hash[i]; |
|
565 |
+#endif /* SHA1_FAST_COPY */ |
|
566 |
+ hash += 4; |
|
567 |
+ } |
|
568 |
+ } |
|
569 |
+} |
|
570 |
+ |
|
571 |
+#ifdef SHA1_TEST |
|
572 |
+ |
|
573 |
+#include <stdio.h> |
|
574 |
+#include <stdlib.h> |
|
575 |
+#include <string.h> |
|
576 |
+ |
|
577 |
+int |
|
578 |
+main (int argc, char *argv[]) |
|
579 |
+{ |
|
580 |
+ SHA1Context foo; |
|
581 |
+ uint8_t hash[SHA1_HASH_SIZE]; |
|
582 |
+ char buf[1000]; |
|
583 |
+ int i; |
|
584 |
+ |
|
585 |
+ SHA1Init (&foo); |
|
586 |
+ SHA1Update (&foo, "abc", 3); |
|
587 |
+ SHA1Final (&foo, hash); |
|
588 |
+ |
|
589 |
+ for (i = 0; i < SHA1_HASH_SIZE;) { |
|
590 |
+ printf ("%02x", hash[i++]); |
|
591 |
+ if (!(i % 4)) |
|
592 |
+ printf (" "); |
|
593 |
+ } |
|
594 |
+ printf ("\n"); |
|
595 |
+ |
|
596 |
+ SHA1Init (&foo); |
|
597 |
+ SHA1Update (&foo, |
|
598 |
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", |
|
599 |
+ 56); |
|
600 |
+ SHA1Final (&foo, hash); |
|
601 |
+ |
|
602 |
+ for (i = 0; i < SHA1_HASH_SIZE;) { |
|
603 |
+ printf ("%02x", hash[i++]); |
|
604 |
+ if (!(i % 4)) |
|
605 |
+ printf (" "); |
|
606 |
+ } |
|
607 |
+ printf ("\n"); |
|
608 |
+ |
|
609 |
+ SHA1Init (&foo); |
|
610 |
+ memset (buf, 'a', sizeof (buf)); |
|
611 |
+ for (i = 0; i < 1000; i++) |
|
612 |
+ SHA1Update (&foo, buf, sizeof (buf)); |
|
613 |
+ SHA1Final (&foo, hash); |
|
614 |
+ |
|
615 |
+ for (i = 0; i < SHA1_HASH_SIZE;) { |
|
616 |
+ printf ("%02x", hash[i++]); |
|
617 |
+ if (!(i % 4)) |
|
618 |
+ printf (" "); |
|
619 |
+ } |
|
620 |
+ printf ("\n"); |
|
621 |
+ |
|
622 |
+ exit (0); |
|
623 |
+} |
|
624 |
+ |
|
625 |
+#endif /* SHA1_TEST */ |
0 | 626 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,72 @@ |
0 |
+/*- |
|
1 |
+ * Copyright (c) 2001-2003 Allan Saddi <allan@saddi.com> |
|
2 |
+ * All rights reserved. |
|
3 |
+ * |
|
4 |
+ * Redistribution and use in source and binary forms, with or without |
|
5 |
+ * modification, are permitted provided that the following conditions |
|
6 |
+ * are met: |
|
7 |
+ * 1. Redistributions of source code must retain the above copyright |
|
8 |
+ * notice, this list of conditions and the following disclaimer. |
|
9 |
+ * 2. Redistributions in binary form must reproduce the above copyright |
|
10 |
+ * notice, this list of conditions and the following disclaimer in the |
|
11 |
+ * documentation and/or other materials provided with the distribution. |
|
12 |
+ * |
|
13 |
+ * THIS SOFTWARE IS PROVIDED BY ALLAN SADDI AND HIS CONTRIBUTORS ``AS IS'' |
|
14 |
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
15 |
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
16 |
+ * ARE DISCLAIMED. IN NO EVENT SHALL ALLAN SADDI OR HIS CONTRIBUTORS BE |
|
17 |
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
18 |
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
19 |
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
20 |
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
21 |
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
22 |
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
23 |
+ * POSSIBILITY OF SUCH DAMAGE. |
|
24 |
+ * |
|
25 |
+ * $Id: sha1.h 347 2003-02-23 22:11:49Z asaddi $ |
|
26 |
+ */ |
|
27 |
+ |
|
28 |
+#ifndef _SHA1_H |
|
29 |
+#define _SHA1_H |
|
30 |
+ |
|
31 |
+#if HAVE_INTTYPES_H |
|
32 |
+# include <inttypes.h> |
|
33 |
+#else |
|
34 |
+# if HAVE_STDINT_H |
|
35 |
+# include <stdint.h> |
|
36 |
+# endif |
|
37 |
+#endif |
|
38 |
+ |
|
39 |
+#define SHA1_HASH_SIZE 20 |
|
40 |
+ |
|
41 |
+/* Hash size in 32-bit words */ |
|
42 |
+#define SHA1_HASH_WORDS 5 |
|
43 |
+ |
|
44 |
+struct _SHA1Context { |
|
45 |
+ uint64_t totalLength; |
|
46 |
+ uint32_t hash[SHA1_HASH_WORDS]; |
|
47 |
+ uint32_t bufferLength; |
|
48 |
+ union { |
|
49 |
+ uint32_t words[16]; |
|
50 |
+ uint8_t bytes[64]; |
|
51 |
+ } buffer; |
|
52 |
+#ifdef RUNTIME_ENDIAN |
|
53 |
+ int littleEndian; |
|
54 |
+#endif /* RUNTIME_ENDIAN */ |
|
55 |
+}; |
|
56 |
+ |
|
57 |
+typedef struct _SHA1Context SHA1Context; |
|
58 |
+ |
|
59 |
+#ifdef __cplusplus |
|
60 |
+extern "C" { |
|
61 |
+#endif |
|
62 |
+ |
|
63 |
+void SHA1Init (SHA1Context *sc); |
|
64 |
+void SHA1Update (SHA1Context *sc, const void *data, uint32_t len); |
|
65 |
+void SHA1Final (SHA1Context *sc, uint8_t hash[SHA1_HASH_SIZE]); |
|
66 |
+ |
|
67 |
+#ifdef __cplusplus |
|
68 |
+} |
|
69 |
+#endif |
|
70 |
+ |
|
71 |
+#endif /* _SHA1_H */ |