Hello community, here is the log from the commit of package dd_rescue for openSUSE:Factory checked in at 2017-11-14 14:22:28 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/dd_rescue (Old) and /work/SRC/openSUSE:Factory/.dd_rescue.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "dd_rescue" Tue Nov 14 14:22:28 2017 rev:36 rq:540708 version:1.99.7 Changes: -------- --- /work/SRC/openSUSE:Factory/dd_rescue/dd_rescue.changes 2017-09-13 21:34:01.858993699 +0200 +++ /work/SRC/openSUSE:Factory/.dd_rescue.new/dd_rescue.changes 2017-11-14 14:22:29.816073776 +0100 @@ -1,0 +2,20 @@ +Fri Nov 10 15:08:21 CET 2017 - [email protected] + +- Update to 1.99.7: + * Work around gentoo dash echo -n breakage (reported by whissi). + * Optimize away strlen() calls in format_int. + +------------------------------------------------------------------- +Sat Nov 4 10:29:09 CET 2017 - [email protected] + +- Update to 1.99.7-pre2: + * ddr_crypt: compat for openssl enc -md sha256 KDF (openssl 1.1 + default) with new opbkdf11 option + +------------------------------------------------------------------- +Thu Nov 2 17:22:06 CET 2017 - [email protected] + +- Update to 1.99.7-pre: + * Fix for segfault on multi-overwrite with -2/-3/-4. + +------------------------------------------------------------------- Old: ---- dd_rescue-1.99.6.tar.bz2 dd_rescue-1.99.6.tar.bz2.asc libddr_hash-round-down-static.diff New: ---- dd_rescue-1.99.7.tar.bz2 dd_rescue-1.99.7.tar.bz2.asc ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ dd_rescue.spec ++++++ --- /var/tmp/diff_new_pack.MdkIzu/_old 2017-11-14 14:22:30.396052617 +0100 +++ /var/tmp/diff_new_pack.MdkIzu/_new 2017-11-14 14:22:30.396052617 +0100 @@ -1,7 +1,7 @@ # # spec file for package dd_rescue # -# Copyright (c) 2017 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: dd_rescue -Version: 1.99.6 +Version: 1.99.7 Release: 0 Summary: Data copying in the presence of I/O Errors License: GPL-2.0 or GPL-3.0 @@ -27,10 +27,11 @@ Source1: http://garloff.de/kurt/linux/ddrescue/%{name}-%{version}.tar.bz2.asc Source2: %{name}.keyring Source99: %{name}.changes -Patch1: libddr_hash-round-down-static.diff BuildRequires: autoconf BuildRequires: libattr-devel +%if 0%{?is_opensuse} BuildRequires: libfallocate-devel +%endif BuildRequires: lzo-devel BuildRequires: lzop BuildRequires: pkgconfig @@ -113,7 +114,6 @@ %prep %setup -q -%patch1 -p0 # Remove build time references so build-compare can do its work FAKE_BUILDTIME=$(LC_ALL=C date -u -r %{SOURCE99} '+%%H:%%M') ++++++ dd_rescue-1.99.6.tar.bz2 -> dd_rescue-1.99.7.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dd_rescue-1.99.6/Makefile new/dd_rescue-1.99.7/Makefile --- old/dd_rescue-1.99.6/Makefile 2017-08-25 12:45:44.096453332 +0200 +++ new/dd_rescue-1.99.7/Makefile 2017-11-10 14:01:20.666155672 +0100 @@ -2,7 +2,7 @@ # (c) [email protected], 99/10/09, GNU GPL # (c) [email protected], 2010 -- 2015, GNU GPL v2 or v3 -VERSION = 1.99.6 +VERSION = 1.99.7 DESTDIR = SRCDIR = . @@ -461,9 +461,14 @@ cmp zero zero2 @rm zero zero2 @rm -f TEST TEST2 + @echo "***** dd_rescue RND overwrite tests *****" + $(VG) ./dd_rescue -m 97263283 /dev/zero TEST + $(VG) ./dd_rescue -MA -Z 0 TEST + $(VG) ./dd_rescue -MA -2 /dev/urandom TEST + @rm TEST @echo "***** dd_rescue ratecontrol test *****" # Test system must be fast enough to achieve ~20MB/s ... - OLDDT=`date +%s`; $(VG) ./dd_rescue -m 64M -C 20M /dev/zero /dev/null; DT=`date +%s`; test $$(($$DT-$$OLDDT)) = 3 -o $$(($$DT-$$OLDDT)) = 4 + OLDDT=`date +%s`; $(VG) ./dd_rescue -m 64M -C 20M /dev/zero /dev/null; DT=`date +%s`; ARCH=$$(uname -m); test $$(($$DT-$$OLDDT)) = 3 -o $$(($$DT-$$OLDDT)) = 4 || test $$(($$DT-$$OLDDT)) -ge 5 -a $${ARCH:0:3} = ppc @echo "***** dd_rescue MD5 plugin tests *****" $(VG) ./md5 /dev/null $(VG) ./md5 /dev/null | md5sum -c @@ -500,9 +505,9 @@ # Extra xattrs (should be preserved) #make check_xattr_copy # Tests with HMAC - echo -n "what do ya want for nothing?" > TEST - echo "750c783e6ab0b503eaa86e310a5db738 *TEST" > HMACS.md5 - $(VG) ./dd_rescue -L ./libddr_hash.so=md5:hmacpwd=Jefe:chknm= TEST /dev/null + echo "what do ya want for nothing?" > TEST + echo "09d6428f7ebaf21a6b53d86c9699cca0 *TEST" > HMACS.md5 + if test `stat -c %s TEST` == 29; then $(VG) ./dd_rescue -L ./libddr_hash.so=md5:hmacpwd=Jefe:chknm= TEST /dev/null; else echo "WARN: TEST file has unexpected size, skipping HMAC test"; hexdump -C TEST; fi rm -f /tmp/dd_rescue CHECKSUMS.sha512 TEST HMACS.md5 if ./calchmac.py sha1 pass dd_rescue; then $(MAKE) check_hmac; else echo "Sorry, no more HMAC test due to missing python-hashlib support"; true; fi $(MAKE) check_fault diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dd_rescue-1.99.6/REL-ID new/dd_rescue-1.99.7/REL-ID --- old/dd_rescue-1.99.6/REL-ID 1970-01-01 01:00:00.000000000 +0100 +++ new/dd_rescue-1.99.7/REL-ID 2017-11-10 14:03:21.893156979 +0100 @@ -0,0 +1 @@ +DD_RESCUE_1_99_7 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dd_rescue-1.99.6/dd_rescue.1 new/dd_rescue-1.99.7/dd_rescue.1 --- old/dd_rescue-1.99.6/dd_rescue.1 2017-06-23 13:24:14.518269729 +0200 +++ new/dd_rescue-1.99.7/dd_rescue.1 2017-11-04 10:03:51.457201111 +0100 @@ -743,7 +743,8 @@ Please note that the md5 algorithm is NOT recommended any more for good protection against malicious attempts to hide data modification; it's not considered strong enough any more to prevent hash collisions. -sha1 is better, but the recommendation is to use the SHA-2 family of hashes. +sha1 is a bit better, but has been broken as well as of 2017. +The recommendation is to use the SHA-2 family of hashes. On 32bit machines, I'd recommend sha256, while on 64bit machines, sha512 is faster and thus the best choice. .PP diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dd_rescue-1.99.6/dd_rescue.c new/dd_rescue-1.99.7/dd_rescue.c --- old/dd_rescue-1.99.6/dd_rescue.c 2016-12-29 22:01:40.574184147 +0100 +++ new/dd_rescue-1.99.7/dd_rescue.c 2017-11-02 12:28:14.714044307 +0100 @@ -1418,7 +1418,7 @@ opt_t *op, fstate_t *fst, progress_t *prg); int real_cleanup(opt_t *op, fstate_t *fst, progress_t *prg, - dpopt_t *dop, dpstate_t *dst, char closelog) + dpopt_t *dop, dpstate_t *dst, char closelog) { int rc, errs = 0; if (!op->dosplice && !dop->bsim715) { @@ -1615,14 +1615,6 @@ dpopt_t *dop, dpstate_t *dst) { /* TODO: Handle plugin input here ... */ - if (dop->prng_libc) - return fill_rand(bf, sz); - if (dop->prng_frnd) { - if (!dop->bsim715_2ndpass) - return frandom_bytes(dst->prng_state, (unsigned char*) bf, sz); - else - return frandom_bytes_inv(dst->prng_state, (unsigned char*) bf, sz); - } /* Handle fault injection here */ int fault = in_fault_list(read_faults, off/op->hardbs, (off+(loff_t)sz+(loff_t)(op->hardbs-1))/op->hardbs); @@ -1648,6 +1640,15 @@ else rep->i_rep_init = 1; } + /* Random numbers */ + if (dop->prng_libc) + return fill_rand(bf, sz); + if (dop->prng_frnd) { + if (!dop->bsim715_2ndpass) + return frandom_bytes(dst->prng_state, (unsigned char*) bf, sz); + else + return frandom_bytes_inv(dst->prng_state, (unsigned char*) bf, sz); + } /* We won't make progress beyond EOF */ ssize_t rd; /* OK, regular read ... */ @@ -2334,7 +2335,8 @@ struct timeval orig_starttime; LISTTYPE(ofile_t) *of; memcpy(&orig_starttime, &starttime, sizeof(starttime)); - fprintf(stderr, "%s%s%s%s" DDR_INFO "Triple overwrite (BSI M7.15): first pass ... (frandom) \n\n\n\n\n", up, up, up, up); + //fprintf(stderr, "%s%s%s%s" DDR_INFO "Triple overwrite (BSI M7.15): first pass ... (frandom) \n\n\n\n\n", up, up, up, up); + fprintf(stderr, DDR_INFO "Triple overwrite (BSI M7.15): first pass ... (frandom) \n"); ret += copyfile_softbs(max, op, fst, prg, rep, dop, dst); fprintf(stderr, "syncing ... \n%s", up); ret += fsync(fst->odes); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dd_rescue-1.99.6/ddr_crypt.1 new/dd_rescue-1.99.7/ddr_crypt.1 --- old/dd_rescue-1.99.6/ddr_crypt.1 2016-12-28 22:57:39.409696420 +0100 +++ new/dd_rescue-1.99.7/ddr_crypt.1 2017-11-04 10:03:51.461201109 +0100 @@ -289,7 +289,16 @@ Note that this is not recommended; only one round of md5 hashing is used which makes brute-forcing very effective. Using this option also has the side-effect of writing (encryption) or parsing -(decryption) an openSSL style Salted__ header. +(decryption) an openSSL style Salted__ header. Note the openssl +version 1.1 started to default to one round of sha256 hashing +instead which can be forced on older openssl versions with +-md sha256 and overriden by specifying -md md5 on the openssl +command line. You can instruct dd_rescue to use an openssl +compatible KDF with sha256 by specifying +.B opbkdf11 . +One round of sha256 can of course still be very efficiently +brute-forced, so use high-entropy passwords if you really +need to use this. .P The salt can be derived automatically from the name (and length) of the encrypted file; this allows to work with just one password diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dd_rescue-1.99.6/fmt_no.c new/dd_rescue-1.99.7/fmt_no.c --- old/dd_rescue-1.99.6/fmt_no.c 2016-12-28 22:17:50.562765920 +0100 +++ new/dd_rescue-1.99.7/fmt_no.c 2017-11-09 15:20:21.354250668 +0100 @@ -46,13 +46,12 @@ * or a single (visible) character or empty/NULL */ char* fmt_int_b(unsigned char pre, unsigned char post, unsigned int scale, - loff_t no, const char* bold, const char* norm, + loff_t no, const char* bold, const int blen, + const char* norm, const int nlen, const char boldinvis, const unsigned char base, const unsigned char group) { static int fbno = -1; - const int blen = bold? strlen(bold): 0; - const int nlen = norm? strlen(norm): 0; int idx = sizeof(fmtbufs[0])-1; char pos; loff_t my_no; @@ -154,15 +153,16 @@ fmt_int( 5, 0, 1024, l, ",", ",", 0), fmt_int( 4, 0, 1024, l, ",", ",", 0), fmt_int(13, 0, 1024, l, ",", ",", 0)); + const int bln = strlen(BOLD), nln = strlen(NORM); printf("\n%s\n", fmt_int(0, 1, 1024, l, BOLD, NORM, 1)); - printf("%s\n", fmt_int_b(0, 1, 1024, l, BOLD, NORM, 1, 10, 0)); - printf("0x%s\n\n", fmt_int_b(0, 1, 1024, l, BOLD, NORM, 1, 16, 4)); - printf("%s\n", fmt_int_b(0, 0, 1024, l, BOLD, NORM, 1, 10, 3)); - printf("%s\n\n", fmt_int_b(0, 0, 1024, l, BOLD, NORM, 0, 10, 3)); - printf("%s\n", fmt_int_b(0, 0, 1024, l, "", "", 1, 10, 3)); - printf("%s\n", fmt_int_b(0, 0, 1024, l, "", "", 0, 10, 3)); - printf("%s\n", fmt_int_b(0, 0, 1024, l, NULL, NULL, 1, 10, 3)); - printf("%s\n", fmt_int_b(0, 0, 1024, l, NULL, NULL, 0, 10, 3)); + printf("%s\n", fmt_int_b(0, 1, 1024, l, BOLD, bln, NORM, nln, 1, 10, 0)); + printf("0x%s\n\n", fmt_int_b(0, 1, 1024, l, BOLD, bln, NORM, nln, 1, 16, 4)); + printf("%s\n", fmt_int_b(0, 0, 1024, l, BOLD, bln, NORM, nln, 1, 10, 3)); + printf("%s\n\n", fmt_int_b(0, 0, 1024, l, BOLD, bln, NORM, nln, 0, 10, 3)); + printf("%s\n", fmt_int_b(0, 0, 1024, l, "", 0, "", 0, 1, 10, 3)); + printf("%s\n", fmt_int_b(0, 0, 1024, l, "", 0, "", 0, 0, 10, 3)); + printf("%s\n", fmt_int_b(0, 0, 1024, l, NULL, 0, NULL, 0, 1, 10, 3)); + printf("%s\n", fmt_int_b(0, 0, 1024, l, NULL, 0, NULL, 0, 0, 10, 3)); } return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dd_rescue-1.99.6/fmt_no.h new/dd_rescue-1.99.7/fmt_no.h --- old/dd_rescue-1.99.6/fmt_no.h 2015-04-15 10:56:38.885315324 +0200 +++ new/dd_rescue-1.99.7/fmt_no.h 2017-11-09 14:09:58.780774637 +0100 @@ -5,15 +5,18 @@ #include <sys/types.h> char* fmt_int_b(unsigned char pre, unsigned char post, unsigned int scale, - loff_t no, const char* bold, const char* norm, + loff_t no, const char* bold, const int blen, + const char* norm, const int nlen, const char boldinvis, const unsigned char base, const unsigned char group); +#include <string.h> static inline char* fmt_int(unsigned char pre, unsigned char post, unsigned int scale, loff_t no, const char* bold, const char* norm, const char boldinvis) { - return fmt_int_b(pre, post, scale, no, bold, norm, boldinvis, 10, 3); + return fmt_int_b(pre, post, scale, no, bold, (bold? strlen(bold): 0), + norm, (norm? strlen(norm): 0), boldinvis, 10, 3); } #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dd_rescue-1.99.6/libddr_crypt.c new/dd_rescue-1.99.7/libddr_crypt.c --- old/dd_rescue-1.99.6/libddr_crypt.c 2017-06-23 13:12:11.070290784 +0200 +++ new/dd_rescue-1.99.7/libddr_crypt.c 2017-11-04 10:03:51.477201111 +0100 @@ -102,6 +102,7 @@ char opbkdf; char outkeyiv; char ctrbug198; + char opbkdf11; } crypt_state; /* aes modules rely on avail of global crypto symbol to point to sec_fields ... */ @@ -121,7 +122,7 @@ #ifdef HAVE_ATTR_XATTR_H ":saltxattr[=xattr_name]:sxfallback" #endif - "\n\t:pbkdf2[=INT]:opbkdf:debug:bench[mark]:skiphole:weakrnd:outkeyiv:ctrbug198\n" + "\n\t:pbkdf2[=INT]:opbkdf[11]:debug:bench[mark]:skiphole:weakrnd:outkeyiv:ctrbug198\n" " Use algorithm=help to get a list of supported crypt algorithms\n"; /* TODO: @@ -376,7 +377,9 @@ state->pbkdf2r = 17000; else if (!strcmp(param, "opbkdf")) state->opbkdf = 1; - else if (!strcmp(param, "skiphole")) + else if (!strcmp(param, "opbkdf11")) { + state->opbkdf = 1; state->opbkdf11 = 1; + } else if (!strcmp(param, "skiphole")) state->skiphole = 1; else if (!strcmp(param, "weakrnd")) state->weakrnd = 1; @@ -795,6 +798,10 @@ if (rnd != state->pbkdf2r && state->opts->verbose) FPLOG(INFO, "Setting pbkdf2 KDF with %i rounds\n", rnd); state->pbkdf2r = rnd; state->opbkdf = 0; + } else if (sscanf(state->sec->charbuf1, "opbkdf11") == 0) { + if (!state->opbkdf && state->opts->verbose) + FPLOG(INFO, "Setting opbkdf11\n"); + state->opbkdf = 1; state->opbkdf11 = 1; state->pbkdf2r = 0; } else if (sscanf(state->sec->charbuf1, "opbkdf") == 0) { if (!state->opbkdf && state->opts->verbose) FPLOG(INFO, "Setting opbkdf\n"); @@ -814,6 +821,8 @@ char buf[32]; if (state->pbkdf2r) snprintf(buf, 32, "pbkdf2=%i", state->pbkdf2r); + else if (state->opbkdf11) + sprintf(buf, "opbkdf11"); else if (state->opbkdf) sprintf(buf, "opbkdf"); else @@ -1039,11 +1048,19 @@ err = pbkdf2(&sha256_halg, state->sec->passphr, 128, state->sec->salt, 8, state->pbkdf2r, state->sec->userkey1, state->alg->keylen/8); } else { - hashalg_t md5_halg = MD5_HALG_T; - err = pbkdf_ossl(&md5_halg, state->sec->passphr, strlen((char*)state->sec->passphr), + if (state->opbkdf11) { + hashalg_t hash_halg = SHA256_HALG_T; + err = pbkdf_ossl(&hash_halg, state->sec->passphr, strlen((char*)state->sec->passphr), + state->sec->salt, 8, 1, + state->sec->userkey1, state->alg->keylen/8, + state->sec->nonce1, BLKSZ); + } else { + hashalg_t hash_halg = MD5_HALG_T; + err = pbkdf_ossl(&hash_halg, state->sec->passphr, strlen((char*)state->sec->passphr), state->sec->salt, 8, 1, state->sec->userkey1, state->alg->keylen/8, state->sec->nonce1, BLKSZ); + } } if (err) { FPLOG(FATAL, "Key generation with pass+salt failed!\n", NULL); @@ -1223,23 +1240,27 @@ return err; } -char holememcpy(void* dst, const void* src, size_t ln) +/* Copy memory block and test for it being all zero at the same time + * Will always return 0 for blocks that are not multiples of sizeof(long) in size + */ +char memcpy_testzero(void* dst, const void* src, size_t ln) { unsigned long *ldst = (unsigned long*)dst; - unsigned long *lsrc = (unsigned long*)src; + const unsigned long *lsrc = (const unsigned long*)src; unsigned int left = ln/sizeof(long); - if (*lsrc || ln%sizeof(long)) { + if (*lsrc || ln%sizeof(long) || !ln) { memcpy(dst, src, ln); return 0; } while (left--) { - unsigned long val = *lsrc++; + const unsigned long val = *lsrc++; *ldst++ = val; if (val) { memcpy(ldst, lsrc, left*sizeof(long)); return 0; } } + asm volatile ("":::"memory"); return 1; } @@ -1330,7 +1351,7 @@ int left = MIN(512, *towr-i); left -= left%BLKSZ; //memcpy(state->sec->databuf2, bf+i, left); - char zero = (state->skiphole? holememcpy(state->sec->databuf2, bf+i, left): (memcpy(state->sec->databuf2, bf+i, left), 0)); + const char zero = (state->skiphole? memcpy_testzero(state->sec->databuf2, bf+i, left): (memcpy(state->sec->databuf2, bf+i, left), 0)); /* Last block on decryption ? */ unsigned int unpad = (eof || (lastdec && i+left == *towr))? state->pad: PAD_ZERO; if (state->debug && unpad) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dd_rescue-1.99.6/libddr_hash.c new/dd_rescue-1.99.7/libddr_hash.c --- old/dd_rescue-1.99.6/libddr_hash.c 2017-08-25 09:51:38.170686244 +0200 +++ new/dd_rescue-1.99.7/libddr_hash.c 2017-08-25 17:14:33.308431613 +0200 @@ -398,7 +398,7 @@ #error __WORDSIZE unknown #endif -inline int round_down(int val, const int gran) +static inline int round_down(int val, const int gran) { return val-val%gran; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dd_rescue-1.99.6/libddr_lzo.c new/dd_rescue-1.99.7/libddr_lzo.c --- old/dd_rescue-1.99.6/libddr_lzo.c 2016-12-28 22:18:31.897764718 +0100 +++ new/dd_rescue-1.99.7/libddr_lzo.c 2017-11-04 10:14:24.781207938 +0100 @@ -977,11 +977,11 @@ #define QUIT { raise(SIGQUIT); ++do_break; break; } #define BREAK if (!state->nodiscard) ++do_break; break -#define DRAIN(x) do { ++do_break; *recall=1; \ +#define DRAIN(x) { do { ++do_break; *recall=1; \ LZO_DEBUG(FPLOG(DEBUG, "Drain %i bytes before %s error handling\n", d_off, x)); \ eof = 0; \ break; } while(0); \ - if (do_break) break + if (do_break) break; } /* TODO: * - Debug: Output block boundaries diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dd_rescue-1.99.6/md5.c new/dd_rescue-1.99.7/md5.c --- old/dd_rescue-1.99.6/md5.c 2016-12-28 22:17:50.569765920 +0100 +++ new/dd_rescue-1.99.7/md5.c 2017-11-04 10:03:51.482201111 +0100 @@ -192,9 +192,13 @@ { assert(buf); int i; - /* FIXME !!! */ for (i = 0; i < 4; ++i) - *((uint32_t*)buf+i) = htonl(BSWAP32(ctx->md5_h[i])); + //*((uint32_t*)buf+i) = htonl(BSWAP32(ctx->md5_h[i])); +#if __BYTE_ORDER == __BIG_ENDIAN + *((uint32_t*)buf+i) = BSWAP32(ctx->md5_h[i]); +#else + *((uint32_t*)buf+i) = ctx->md5_h[i]; +#endif return buf; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dd_rescue-1.99.6/pbkdf_ossl.c new/dd_rescue-1.99.7/pbkdf_ossl.c --- old/dd_rescue-1.99.6/pbkdf_ossl.c 2015-09-08 23:37:02.829010065 +0200 +++ new/dd_rescue-1.99.7/pbkdf_ossl.c 2017-11-04 10:03:51.485201111 +0100 @@ -16,28 +16,18 @@ #define MIN(a,b) ((a)<(b)? (a): (b)) -#if __BYTE_ORDER == __BIG_ENDIAN -static inline void to_bytes(uint32_t val, uint8_t *bytes) +static inline void memcpy_nhash(hashalg_t *hash, uint8_t *buf, hash_t *hv, size_t hln, size_t off) { - bytes[0] = (uint8_t)val; - bytes[1] = (uint8_t)(val >> 8); - bytes[2] = (uint8_t)(val >> 16); - bytes[3] = (uint8_t)(val >> 24); + if (off == 0 && hln == hash->hashln) + hash->hash_beout(buf, hv); + else { + uint8_t tmp[64]; + hash->hash_beout(tmp, hv); + memcpy(buf, tmp+off, hln); + memset(tmp, 0, hash->hashln); + asm("":::"memory"); + } } -static inline void memcpy_hash(uint8_t *buf, hash_t *hv, size_t hln) -{ - int i; - assert(hln%sizeof(uint32_t) == 0); - for (i=0; i<hln/sizeof(uint32_t); ++i) - to_bytes(hv->sha256_h[i], buf+i*sizeof(uint32_t)); -} -#else -static inline void memcpy_hash(uint8_t *buf, hash_t *hv, size_t hln) -{ - memcpy(buf, hv, hln); -} - -#endif int pbkdf_ossl(hashalg_t *hash, unsigned char* pwd, int plen, unsigned char* salt, int slen, @@ -57,8 +47,8 @@ if (slen) memcpy(hbuf+plen, salt, slen); } else { - hbln += hash->hashln; - memcpy_hash(hbuf, &hv, hash->hashln); + hbln = plen+slen+hash->hashln; + hash->hash_beout(hbuf, &hv); memcpy(hbuf+hash->hashln, pwd, plen); if (slen) memcpy(hbuf+hash->hashln+plen, salt, slen); @@ -67,13 +57,13 @@ //for (int i = 0; i <= cnt; ++i) hash->hash_calc(hbuf, hbln, hbln, &hv); /* Fill in result */ - if (off+hash->hashln < klen) - memcpy_hash(key+off, &hv, hash->hashln); - else if (off >= klen) - memcpy_hash(iv+off-klen, &hv, MIN(hash->hashln, ivlen+klen-off)); - else { - memcpy_hash(key+off, &hv, klen-off); - memcpy_hash(iv, (hash_t*)(((unsigned char*)&hv)+klen-off), MIN(hash->hashln-klen+off, ivlen)); + if (off+hash->hashln < klen) + memcpy_nhash(hash, key+off, &hv, hash->hashln, 0); + else if (off >= klen) { + memcpy_nhash(hash, iv+off-klen, &hv, MIN(hash->hashln, ivlen+klen-off), 0); + } else { + memcpy_nhash(hash, key+off, &hv, klen-off, 0); + memcpy_nhash(hash, iv, &hv, MIN(hash->hashln-klen+off, ivlen), klen-off); } off += hash->hashln; ++cnt; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dd_rescue-1.99.6/rdrand.c new/dd_rescue-1.99.7/rdrand.c --- old/dd_rescue-1.99.6/rdrand.c 2016-12-28 22:17:50.608765918 +0100 +++ new/dd_rescue-1.99.7/rdrand.c 2017-11-02 12:14:51.484035646 +0100 @@ -3,9 +3,17 @@ * * (c) Kurt Garloff <[email protected]>, 8/2014 * License: GNU GPL v2 or v3 + * + * Can also be compiled as selfstanding program to just retrive one random number + * using the rdrand CPU instruction unconditionally (will SIGILL is not supported) + * gcc -O2 -Wall -mrdrnd -DRDRAND_MAIN -o rdrand rdrand.c */ -#include "archdep.h" +#ifdef HAVE_CONFIG_H +# include "archdep.h" +#else +# define have_rdrand 1 +#endif #ifdef __RDRND__ #include <immintrin.h> @@ -66,3 +74,17 @@ } #endif +#ifdef RDRAND_MAIN +#include <stdio.h> +int main(int argc, char* argv[]) +{ +#ifdef __x86_64__ + unsigned long rnd = rdrand64(); + printf("%lu\n", rnd); +#else + unsigned int rnd = rdrand32(); + printf("%u\n", rnd); +#endif + return 0; +} +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dd_rescue-1.99.6/test_aes.c new/dd_rescue-1.99.7/test_aes.c --- old/dd_rescue-1.99.6/test_aes.c 2017-08-25 12:45:55.975452971 +0200 +++ new/dd_rescue-1.99.7/test_aes.c 2017-11-02 17:38:10.048830448 +0100 @@ -55,7 +55,7 @@ have_aesni = !!__builtin_cpu_supports("avx"); } #else -# warn no runtime detection for aesni +# warning no runtime detection for aesni static void detect_cpu_cap(); #endif #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dd_rescue-1.99.6/test_crypt.sh new/dd_rescue-1.99.7/test_crypt.sh --- old/dd_rescue-1.99.6/test_crypt.sh 2016-12-29 22:14:41.411161429 +0100 +++ new/dd_rescue-1.99.7/test_crypt.sh 2017-11-04 10:03:51.489201111 +0100 @@ -129,11 +129,15 @@ rm -f dd_rescue.enc.o fi # Salted__ tests ... -if openssl enc -aes-192-ctr -pass pass:PASWD -S f61059ec2d87a410 -p -in dd_rescue -out dd_rescue.enc.o; then +if openssl enc -aes-192-ctr -pass pass:PASWD -S f61059ec2d87a410 -md md5 -p -in dd_rescue -out dd_rescue.enc.o; then enc_dec_compare dd_rescue AES192-CTR "" pass=PASWD:salthex=f61059ec2d87a410:opbkdf:outkeyiv cmp dd_rescue.enc dd_rescue.enc.o || exit 4 fi -if openssl enc -aes-192-cbc -pass pass:PASWD -S f61059ec2d87a410 -p -in dd_rescue -out dd_rescue.enc.o; then +if openssl enc -aes-192-ctr -pass pass:PASWD -S f61059ec2d87a410 -md sha256 -p -in dd_rescue -out dd_rescue.enc.o; then + enc_dec_compare dd_rescue AES192-CTR "" pass=PASWD:salthex=f61059ec2d87a410:opbkdf11:outkeyiv + cmp dd_rescue.enc dd_rescue.enc.o || exit 4 +fi +if openssl enc -aes-192-cbc -pass pass:PASWD -S f61059ec2d87a410 -md md5 -p -in dd_rescue -out dd_rescue.enc.o; then enc_dec_compare dd_rescue AES192-CBC "" pass=PASWD:salthex=f61059ec2d87a410:opbkdf:outkeyiv cmp dd_rescue.enc dd_rescue.enc.o || exit 4 rm -f dd_rescue.enc.o
